JSF DataModel vs Java List问题(无可用行异常) [英] Jsf DataModel vs Java List problem ( no row available exception )

查看:87
本文介绍了JSF DataModel vs Java List问题(无可用行异常)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JSF 1.2中,一个正在使用Java List列出项目:

In JSF 1.2 One was listing Items using Java List :

private List<Customer> customerItems = null;

,但是在JSF 2.0中,要使用JSf DataModel(ListDataModel). (我正在使用JSF 2.0)

, but in JSF 2.0 JSf DataModel (ListDataModel) is the way to go. (I am using JSF 2.0)

private DataModel customerItems = null;
 public abstract DataModel createPageDataModel();

但是,我仍然不知道如何有效地使用它.确切地说,我什至无法实现一个简单而强制的情况,即导航.

However, I still don't get how to efficiently work with it. Rather say, I can't even implement a simple and mandatory case which is, navigation.

我有一个<h:datatable value =#{customerController}" var ="customer">,它从名为"customerController"的客户托管bean中获取行对象.

I have a <h:datatable value="#{customerController}" var="customer"> that gets its row objects from Customer managed bean named "customerController".

最后一列包含一个命令链接,该链接调用一种方法来查看所选行的详细信息页面.一切正常.

the last column holds a command link that calls a method to viewing the details page of the selected row. It is working fine.

<h:column>
<h:commandButton value="View me"  action="#{customerController.prepareDetails}"/>
</h:column>

在给定风俗的详细视图页面中,我有一个数据表,其中包含一个订单列表 一切都很好,表格已填充,订单中显示了与订单属性相对应的几列.

When in the detail view page of given custom, I have a data table that holds a list of orders Everything is fine, the table is populated and the orders are displayed with several columns corresponding to the order attributes.

.....
<h:outputText value="customer.selected.name"  />
 <h:datatable value="#{customer.selected.orderList}" var="order">
......

同一数据表的最后一列包含一个命令链接,可导航到所选订单的详细信息页面:

This same datatable's last column holds a command link to navigating to the detail page of the selected order:

痛苦来了.我收到没有可用行异常:

And here comes the pain. I get No Row Available Exception :

javax.faces.model.NoRowAvailableException
- Stack Trace

javax.faces.el.EvaluationException: javax.faces.model.NoRowAvailableException
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIData.broadcast(UIData.java:1093)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.model.NoRowAvailableException
    at javax.faces.model.ListDataModel.getRowData(ListDataModel.java:150)
    at jsf.EvaluationController.prepareView(EvaluationController.java:82)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 34 more

谢谢您的帮助.

推荐答案

首先检查您的customerBean的范围,它应该是 viewScoped SessionScoped .

Firstly check the scope of your customerBean it should be either a viewScoped or SessionScoped.

另一件事可能是 glassfish 的问题,该问题需要在xml文件中配置 maven依赖.请参阅此链接. http://mavenhub.com/c/javax/faces/model/norowavailableexception 最后要检查的是您的列表.尝试对其进行调试,以查看其中列出了所有属性并在UI上进行填充.

Another thing could be a problem of glassfish which needs a maven dependency configured in the xml files.See this link. http://mavenhub.com/c/javax/faces/model/norowavailableexception Last thing to check is your list.Try to debug it and see it has all the properties listed in it which you are populating it on the UI.

这篇关于JSF DataModel vs Java List问题(无可用行异常)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆