异常类'java.lang.String'没有属性'type' [英] Exception The class 'java.lang.String' does not have the property 'type'
问题描述
尝试获取对象值时发生异常. 当我们的应用程序只包含Web应用程序时,它就起作用了,但是当我们将带有APP-INF/lib的ejb包添加到application.xml中时,出现了异常:javax.el.PropertyNotFoundException:类'java.lang.String'没有具有属性类型".在我的调查中:item的值为String,但不是getItems方法返回的对象.为什么可能发生此异常.
Exception occurs while trying to get object value. It worked before when our application has only web-application in ear, but when we add ejb package with APP-INF/lib into application.xml exception appears: javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'type'. In my investigation here: item value is String but not object returned by getItems method. Why this exception may occurs.
感谢任何想法.
这是jsp页面的代码.
Here is the code of jsp page.
<div id="report_items">
<c:forEach items="#{repcatTree.items}" var="item">
<div style="padding-top:7px; padding-bottom:7px; padding-right:15px;">
<span class="report_item_category_class">
<h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}"
styleClass="default_link">
<h:graphicImage url="/views/tree/images/folder_big.gif" />
<h:outputText value="#{item.attributes.FILE_NAME}" style="font-size:14px; font-weight:bold; padding-left:5px" />
</h:commandLink>
<h:commandLink rendered="#{item.type == 'report'}" styleClass="default_link"
action="action_report_run" title="#{item.cells['report_name'].toolTip}">
<h:graphicImage url="/icon?rdd_path=#{item.attributes.RDD_PATH}" />
<h:outputText value="#{item.cells['report_name'].display}"
style="font-size:14px; font-weight:bold; padding-left:5px" />
<f:param name="nodePath" value="#{item.attributes.RDD_PATH}" />
<f:param name="nodePrettyPath" value="#{item.attributes.CAT_PATH}" />
</h:commandLink>
</span>
</div>
</c:forEach>
</div>
这是我的课程.我不需要删除代码的一部分.
Here is my class. I remove no needed part of code.
public class RepcatTreeModel extends TreeModel implements Serializable {
public RepcatTreeModel() {
super();
}
public Collection getItems() {
items = new ArrayList();
items.addAll(getActiveNode().getChildren());
items.addAll(getTableModel().getRows());
Object[] _items = items.toArray();
Arrays.sort(_items, new Comparator() {
public int compare(Object o1, Object o2) {
int result = 0;
if (o1 instanceof TreeNodeModel && o2 instanceof TreeNodeModel) {
TreeNodeModel nodeA = (TreeNodeModel)o1;
TreeNodeModel nodeB = (TreeNodeModel)o2;
String strA = (String)nodeA.getAttributes().get(RepcatTreeModel.ATTR_NAME);
String strB = (String)nodeB.getAttributes().get(RepcatTreeModel.ATTR_NAME);
if (strB.compareToIgnoreCase(strA) < 0)
result = 1;
else
if (strB.compareToIgnoreCase(strA) > 0)
result = -1;
}
else
if (o1 instanceof RowModel && o2 instanceof RowModel) {
RowModel nodeA = (RowModel)o1;
RowModel nodeB = (RowModel)o2;
String strTmp = (String)nodeA.getAttributes().get(RepcatTreeModel.ROW_ATTR_RDD_PATH);
String strA = strTmp.substring(strTmp.lastIndexOf('/')+1);
strTmp = (String)nodeB.getAttributes().get(RepcatTreeModel.ROW_ATTR_RDD_PATH);
String strB = strTmp.substring(strTmp.lastIndexOf('/')+1);
if (strB.compareToIgnoreCase(strA) < 0)
result = 1;
else
if (strB.compareToIgnoreCase(strA) > 0)
result = -1;
}
return result;
}
});
items = new ArrayList(Arrays.asList(_items));
return items;
}
}
推荐答案
#{repcatTree.items}
返回字符串对象列表.
#{repcatTree.items}
returns a List of String objects.
在两个<h:commandLink>
组件上,从
rendered="#{item.type == 'category'}"
到
rendered="#{item eq 'category'}"
这篇关于异常类'java.lang.String'没有属性'type'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!