jsf中的数据访问问题
我有以下类文件:
class RowData {
...
ArrayList<String> valueMap;
...
}
class Bean {
...
public List<RowData> getData() {
...
}
}
jsf 代码片段:
...
<h:form>
<rich:dataTable id="overviewTable" value="#{bean.getData()}" var="row">
<c:forEach items="#{row.valueMap}" var="r">
<rich:column>
<h:outputText value="#{r}" />
</rich:column>
</c:forEach>
</rich:dataTable>
</h:form>
...
不幸的是,该表没有出现。怎么了?该页面没有显示错误或其他内容,表格只是不存在(在这个版本中我跳过了所有的 getter 和 setter...)。当我想从 bean 访问其他数据时,它可以工作,所以整个设置应该没问题。
I have the following class-files:
class RowData {
...
ArrayList<String> valueMap;
...
}
class Bean {
...
public List<RowData> getData() {
...
}
}
jsf code snippet:
...
<h:form>
<rich:dataTable id="overviewTable" value="#{bean.getData()}" var="row">
<c:forEach items="#{row.valueMap}" var="r">
<rich:column>
<h:outputText value="#{r}" />
</rich:column>
</c:forEach>
</rich:dataTable>
</h:form>
...
Unfortunately, the table doesn't appear. What's wrong? The page doesn't show an error or something, the table is just not there (in this version I skipped all the getter and setter...). When I want to access other data from the bean, it works, so the whole setup should be ok.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不应该在“getData()”中写“get”和“()”,
另外,我认为您不需要数据表中的“foreach”,
请查看此示例
http://richfaces-showcase .appspot.com/richfaces/component-sample.jsf?demo=dataTable&sample=tableStyling&skin=blueSky
you should not write the "get" and the "()" in "getData()",
also, I dont think you need the "foreach" in a datatable
look at this example from
http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=dataTable&sample=tableStyling&skin=blueSky
请改用
value="#{bean.data}"
。请记住,您使用的是 EL,并且假定您通过 getter 方法getData()
引用名为data
的 java bean 属性。 data 属性可能不存在,但命名的方法绝对应该这样命名。另外,为了使用
items="#{row.valueMap}"
习惯用法,您的 bean 类中必须有一个getValueMap()
方法。你明白了吗?
Use
value="#{bean.data}"
instead. Remember, you're using E.L and it is assumed that you're referencing a java bean property nameddata
through the getter methodgetData()
. The data property might not exists but the method named should definitely be named like this.Also, in order to use the
items="#{row.valueMap}"
idiom, you must have agetValueMap()
method present in your bean class.Do you get the idea?