我一直在努力解决这个问题,尽管有很多关于这个主题的教程。我正在测试JSF 2.0中h:dataTable组件的功能。我有以下列表:
<h:dataTable border="1" styleClass="data zebra" value="#{testTableWB.testList}" var="items">
<h:column>
<f:facet name="header">
<h:outputText value="id"/>
</f:facet>
<h:outputText value="#{items.id}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="name"/>
</f:facet>
<h:outputText value="#{items.name}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="description"/>
</f:facet>
<h:outputText value="#{items.description}"/>
</h:column>
<h:column>
<f:facet name="header">
</f:facet>
<h:selectManyCheckbox id="ids" value="#{items.id}">
<f:selectItem value="#{ids}" itemLabel="" />
</h:selectManyCheckbox>
</h:column>
<h:column>
<f:facet name="header">
</f:facet>
<h:commandLink action="testTableWB.someStupidAction" value="Edit">
<f:param id="itemIDEdit" value="items.id"/>
</h:commandLink>
</h:column>
<h:column>
<f:facet name="header">
</f:facet>
<h:commandLink action="testTableWB.someStupidAction" value="Show">
<f:param id="itemIDShow" value="items.id"/>
</h:commandLink>
</h:column>
</h:dataTable>
My Managed Bean看起来像这样:
@ManagedBean(名称= “testTableWB”) @RequestScoped 公共类TestTableWBR扩展了VerificationWBR {
private List<TestElement> testList;
public List<TestElement> getTestList() {
testList = new ArrayList<TestElement>();
for (int i=0; i<5;i++){
testList.add(new TestElement(new Long(i),"name"+i, "descrition"+i));
}
testList.add(new TestElement(10L,"mark", "test element"));
return this.testList;
}
public void setTestList(List<TestElement> pTestList) {
this.testList = pTestList;
}
public void someStupidAction(){
String parameter = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("itemIDEdit");
}
所以当我点击其中一个命令链接 - 编辑或显示时,我希望调用该动作,我在那里有一个断点。相反,我得到一个错误:目标模型类型不是集合或数组以及以下堆栈跟踪:
javax.faces.FacesException: Target model Type is no a Collection or Array
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:390)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:127)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:313)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
at javax.faces.component.UIInput.validate(UIInput.java:934)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
at javax.faces.component.UIInput.processValidators(UIInput.java:691)
at javax.faces.component.UIData.iterate(UIData.java:1424)
at javax.faces.component.UIData.processValidators(UIData.java:1015)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIForm.processValidators(UIForm.java:243)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1179)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
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:310)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at com.bmw.verdict.web.fupload.UploadFilter.doFilter(UploadFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:291)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:666)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:597)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:872)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:382)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:264)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
根据文档,dataTable组件应该与List数据类型一起使用。我根本没有进入托管bean,所以我想在生命周期之前出现问题。那我在哪里错了?感谢您的帮助。
问候,al
答案 0 :(得分:1)