本文整理汇总了Java中jodd.bean.BeanUtil.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtil.getProperty方法的具体用法?Java BeanUtil.getProperty怎么用?Java BeanUtil.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jodd.bean.BeanUtil
的用法示例。
在下文中一共展示了BeanUtil.getProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import jodd.bean.BeanUtil; //导入方法依赖的package包/类
@Override
public Object get(Object bean) {
PropertyNode currentNode = this;
Object currentBean = bean;
while (!currentNode.isLeafNode() && currentNode.next() != null) {
currentBean = BeanUtil.getProperty(currentBean, currentNode.name());
currentNode = currentNode.next();
}
if (currentNode.isLeafNode() && currentBean != null) {
return BeanUtil.getProperty(currentBean, currentNode.name());
} else {
return null;
}
}
示例2: set
import jodd.bean.BeanUtil; //导入方法依赖的package包/类
@Override
public void set(Object bean, Object value) {
if (!isLeaf) {
Object nodeBean = BeanUtil.getProperty(bean, name);
if (nodeBean == null) {
nodeBean = injector.getInstance(type);
BeanUtil.setProperty(bean, name, nodeBean);
}
next.set(nodeBean, value);
} else {
BeanUtil.setProperty(bean, name, validValue(value, type));
}
}
示例3: writeOptionsFromCollection
import jodd.bean.BeanUtil; //导入方法依赖的package包/类
protected void writeOptionsFromCollection(Collection<?> collectionValues) throws IOException, JspException {
JspWriter writer = jspContext.getOut();
ReflectionProvider reflectionProvider = injector.getInstance(ReflectionProvider.class);
Boolean isSimpleType = null;
for (Object obj : collectionValues) {
if (isSimpleType == null)
isSimpleType = reflectionProvider.isSimpleType(obj.getClass());
Object optionValue = null;
Object optionLabel = null;
if (isSimpleType) {
optionValue = obj;
optionLabel = obj;
} else {
if (value == null)
throw new JspException("When creating select-options from a collection of beans you must specifiy the attribute of that bean to use for the value. Please check you select-options for '" + parentName() + "'");
optionValue = BeanUtil.getProperty(obj, value);
optionLabel = BeanUtil.getProperty(obj, label == null ? value : label);
}
writeTag(jspContext.getOut(), "option", false, false);
writer.write(Char.SPACE);
writer.write("value");
writer.write(Char.EQUALS);
writer.write(Char.DOUBLE_QUOTE);
writer.write(String.valueOf(optionValue));
writer.write(Char.DOUBLE_QUOTE);
if (isValueSelected(optionValue)) {
writer.write(Char.SPACE);
writer.write("selected");
writer.write(Char.EQUALS);
writer.write(Char.DOUBLE_QUOTE);
writer.write("selected");
writer.write(Char.DOUBLE_QUOTE);
}
writer.write(Char.GREATER_THAN);
// See if there is a translated version of the label in the message properties.
String i18nOptionLabel = messageResolver.resolve(new StringBuilder(optionValue.getClass().getName()).append(Char.DOT).append(optionValue).toString(), requestContext(), true);
if (i18nOptionLabel == null)
i18nOptionLabel = messageResolver.resolve(new StringBuilder(optionValue.getClass().getSimpleName()).append(Char.DOT).append(optionValue).toString(), requestContext(), true);
if (!Str.isEmpty(i18nOptionLabel)) {
writer.write(i18nOptionLabel);
} else {
writer.write(optionLabel == null ? String.valueOf(optionValue) : String.valueOf(optionLabel));
}
writeCloseTag(writer, "option", true);
}
}
示例4: writeOptionsFromCollection
import jodd.bean.BeanUtil; //导入方法依赖的package包/类
protected void writeOptionsFromCollection(Collection<?> collectionValues) throws IOException, JspException {
JspWriter writer = jspContext.getOut();
ReflectionProvider reflectionProvider = injector.getInstance(ReflectionProvider.class);
Boolean isSimpleType = null;
for (Object obj : collectionValues) {
if (isSimpleType == null)
isSimpleType = reflectionProvider.isSimpleType(obj.getClass());
Object optionValue = null;
String optionLabel = null;
if (isSimpleType) {
optionValue = obj;
optionLabel = String.valueOf(obj);
} else {
if (value == null)
throw new JspException("When creating select-options from a collection of beans you must specifiy the attribute of that bean to use for the value. Please check your checobox-values for '" + name + "'");
optionValue = BeanUtil.getProperty(obj, value);
optionLabel = String.valueOf(BeanUtil.getProperty(obj, label == null ? value : label));
}
writer.write("<div class=\"");
writer.write((String) dynamicAttributes.get("type"));
writer.write("\">");
writeLabel(name, optionValue);
writeTag(jspContext.getOut(), "input", false, false);
appendTagAttributes(writer, optionValue);
writer.write(Char.SLASH);
writer.write(Char.GREATER_THAN);
String i18nOptionLabel = null;
// Attempt to find a translated version of the enum.
if (optionValue.getClass().isEnum()) {
messageResolver.resolve(new StringBuilder(optionValue.getClass().getName()).append(Char.DOT).append(optionValue).toString(), requestContext(), true);
if (i18nOptionLabel == null)
i18nOptionLabel = messageResolver.resolve(new StringBuilder(optionValue.getClass().getSimpleName()).append(Char.DOT).append(optionValue).toString(), requestContext(), true);
} else {
// See if there is a translated version of the label in the message properties.
i18nOptionLabel = messageResolver.resolve(new StringBuilder(name).append(Char.DOT).append(optionValue).toString(), requestContext(), true);
}
if (!Str.isEmpty(i18nOptionLabel)) {
writer.write(i18nOptionLabel);
} else {
writer.write(optionLabel);
}
writer.write("</label>\n");
writer.write("</div>\n");
}
}