本文整理汇总了Java中org.apache.wicket.util.convert.IConverter.convertToString方法的典型用法代码示例。如果您正苦于以下问题:Java IConverter.convertToString方法的具体用法?Java IConverter.convertToString怎么用?Java IConverter.convertToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.util.convert.IConverter
的用法示例。
在下文中一共展示了IConverter.convertToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.apache.wicket.util.convert.IConverter; //导入方法依赖的package包/类
/**
*
* @param count count (name + count) to check
* @param converter optional converter to apply to value before comparison
* @return true IFF the {@link Count#getCount() } is more than {@link #getMinimalOccurence()
* } {@link Count#getName() } contains {@link #getName() } (case
* insensitive)
*/
@Override
public boolean matches(Count count, IConverter<String> converter) {
if (count.getCount() >= minimalOccurence) {
if (namePattern == null) {
// no pattern to compare to, always matches
return true;
} else {
// convert value if converter is provided
final String value;
if (converter == null) {
value = count.getName();
} else {
value = converter.convertToString(count.getName(), null);
}
return namePattern.matcher(value).find();
}
} else {
// too few occurences, no match
return false;
}
}
示例2: getModelValue
import org.apache.wicket.util.convert.IConverter; //导入方法依赖的package包/类
@Override
protected String getModelValue()
{
Number value = getModelObject();
if (value == null)
{
return "";
}
else
{
IConverter<Number> converter = (IConverter<Number>) getConverter(value.getClass());
if (converter != null) {
return converter.convertToString(value, this.getLocale());
} else {
return Objects.stringValue(value);
}
}
}
示例3: generateLabelForChoice
import org.apache.wicket.util.convert.IConverter; //导入方法依赖的package包/类
/**
* Generates the initial label that is displayed inside the button for the given choice.
*
* @param choice the choice being rendered
* @return the choice label
*/
@SuppressWarnings("unchecked")
protected String generateLabelForChoice(T choice) {
Object displayValue = getChoiceRenderer().getDisplayValue(choice);
Class<?> objectClass = displayValue == null ? null : displayValue.getClass();
String label = "";
if (objectClass != null && objectClass != String.class) {
IConverter converter = getConverter(objectClass);
label = converter.convertToString(displayValue, getLocale());
} else if (displayValue != null) {
label = displayValue.toString();
}
return label;
}
示例4: postprocessValue
import org.apache.wicket.util.convert.IConverter; //导入方法依赖的package包/类
private String postprocessValue(String value) {
if (value != null) {
final IConverter<String> converter = getFieldValueConverter();
if (converter != null) {
return converter.convertToString(value, null);
}
}
return value;
}
示例5: getObject
import org.apache.wicket.util.convert.IConverter; //导入方法依赖的package包/类
@Override
public String getObject() {
final IConverter<String> converter = VloWicketApplication.get().getFieldValueConverterProvider().getConverter(field);
if (converter == null) {
logger.warn("No converter for field {}", field);
return valueModel.getObject();
} else {
return converter.convertToString(valueModel.getObject(), Session.get().getLocale());
}
}
示例6: appendOptionHtml
import org.apache.wicket.util.convert.IConverter; //导入方法依赖的package包/类
@SuppressWarnings({"RefusedBequest", "unchecked"})
@Override
protected void appendOptionHtml(AppendingStringBuffer buffer, File choice, int index, String selected) {
IChoiceRenderer<? super File> renderer = getChoiceRenderer();
Object objectValue = renderer.getDisplayValue(choice);
String displayValue = "";
if (objectValue != null) {
IConverter converter = getConverter(objectValue.getClass());
displayValue = converter
.convertToString(objectValue, getLocale());
}
if ("".equals(displayValue)) {
displayValue = getString("file.browser.breadCrumbs.root", null);
}
buffer.append("\n<option ");
if (isSelected(choice, index, selected)) {
buffer.append("selected=\"selected\" ");
}
buffer.append("style=\"padding-left: " + (index * 10 + 18) + "px; " +
"background-position: " + index * 10 + "px\" ");
index++;
buffer.append("value=\"");
buffer.append(Strings.escapeMarkup(renderer.getIdValue(choice, index)));
buffer.append("\">");
CharSequence escaped = escapeOptionHtml(displayValue);
buffer.append(escaped);
buffer.append("</option>");
}
示例7: appendOptionHtml
import org.apache.wicket.util.convert.IConverter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void appendOptionHtml(final AppendingStringBuffer buffer, final T choice, int index,
final String selected) {
Object displayValue = getChoiceRenderer().getDisplayValue(choice);
Class<?> objectClass = displayValue == null ? null : displayValue.getClass();
// Get label for choice
String label = "";
if (objectClass != null && objectClass != String.class) {
@SuppressWarnings("rawtypes")
IConverter converter = getConverter(objectClass);
label = converter.convertToString(displayValue, getLocale());
} else if (displayValue != null) {
label = displayValue.toString();
}
// If there is a display value for the choice, then we know that the
// choice is automatic in some way. If label is /null/ then we know
// that the choice is a manually created checkbox tag at some random
// location in the page markup!
if (label != null) {
String id = getChoiceRenderer().getIdValue(choice, index);
final String idAttr = getCheckBoxMarkupId(id);
boolean isSlected = isSelected(choice, index, selected);
// Append option suffix
buffer.append(getPrefix(index, choice));
Tag tag = new Tag("label").attr("for", idAttr);
List<String> labelClasses = new ArrayList<>();
labelClasses.add("btn");
if (isSlected) {
labelClasses.add("active");
labelClasses.add(getActiveLabelClass(choice, index));
} else {
labelClasses.add(getLabelClass(choice, index));
}
tag.attr("class", labelClasses);
// Add checkbox element
Tag input = new Tag("input").attr("name", getInputName()).attr("type", "checkbox");
input.attr("value", id).attr("id", idAttr);
input.attr("checked", "checked", isSlected);
input.attr("disabled", "disabled", isDisabled(choice, index, selected) || !isEnabledInHierarchy());
// Allows user to add attributes to the <input..> tag
{
IValueMap attrs = getAdditionalAttributes(index, choice);
if (attrs != null) {
input.getAttributes().putAll(attrs);
}
}
if (getApplication().getDebugSettings().isOutputComponentPath()) {
CharSequence path = getPageRelativePath();
path = Strings.replaceAll(path, "_", "__");
path = Strings.replaceAll(path, ":", "_");
input.attr("wicketpath", path + "_input_" + index);
}
tag.add(input);
// Add label for checkbox
tag.add(getLabelText(label));
buffer.append(tag.toString());
// Append option suffix
buffer.append(getSuffix(index, choice));
}
// CHECKSTYLE:ON
}