在发布它之前我真的给了这个相当长的时间,但我似乎并没有缩小到问题的根源。
我有这个“基本上”简单的代码,让我们说,一旦我点击 a <p:commandButton>
,就会触发一个动作来填充要在 a 上调用的 ArrayList <p:dataTable>
。
我<p:commandButton>
的是:
<p:commandButton value="Afficher" actionListener="#{fieldController.fillListFields()}" ajax="false"/>
至于我的<p:dataTable>
,是这样的:
<p:dataTable var="car" value="#{fieldController.listFields}" id="carList" editable="true">
这#{fieldController.listFields}
是一个#{fieldController.fillListFields()}
必须负责填充的 ArrayList。的代码fillListFields()
是:
public void fillListFields() throws NamingException, SQLException {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("postgresJNDI");
Connection connection = ds.getConnection();
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM " + consultCarto.getForm());
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
for (int i = 1; i < columnCount + 1; i++) {
listFields.add(new Field(rsmd.getColumnName(i), ""));
}
rs.close();
st.close();
connection.close();
}
现在我已经调试了这个方法并且 ArrayListlistFields
被很好地填充了,我可以向你保证。问题是一旦我部署应用程序并单击<p:commandButton>
我得到一个java.lang.IllegalArgumentException
,我不知道 JSF 页面上的哪个组件没有收到正确的参数(顺便说一句,我知道它在 JSF 页面中,因为我得到了
SEVERE: Error Rendering View[/consult_carto.xhtml]
java.lang.IllegalArgumentException
)
我检查了 setter 和 getter,它们看起来还不错。
关于我应该看哪里的任何迹象?
堆栈:
java.lang.IllegalArgumentException
at com.sun.faces.renderkit.SelectItemsIterator.initializeItems(SelectItemsIterator.java:216)
at com.sun.faces.renderkit.SelectItemsIterator.hasNext(SelectItemsIterator.java:135)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:762)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:844)
at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:298)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at org.primefaces.component.celleditor.CellEditorRenderer.encodeEnd(CellEditorRenderer.java:43)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at org.primefaces.component.datatable.DataTableRenderer.encodeCell(DataTableRenderer.java:808)
at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:773)
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:651)
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:234)
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:196)
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeDynamicBody(PanelGridRenderer.java:92)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeBody(PanelGridRenderer.java:60)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeEnd(PanelGridRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeDynamicBody(PanelGridRenderer.java:92)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeBody(PanelGridRenderer.java:60)
at org.primefaces.component.panelgrid.PanelGridRenderer.encodeEnd(PanelGridRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
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 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
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:722)
Thanks.
我的标记的重要部分:
<h:form id="form" style="font-size: 13px;">
<p:panelGrid columns="2">
<f:facet name="header">
Consulter les données cartographiques
</f:facet>
<p:panelGrid columns="1">
<p:panelGrid columns="2" style="width: 100%;text-align: center">
<p:outputPanel>
<h:outputText value="Choisir un formulaire : " />
<br></br>
<br></br>
<p:selectOneMenu value="#{consultCarto.form}" >
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{consultCarto.forms}" />
</p:selectOneMenu>
</p:outputPanel>
<p:commandButton value="Afficher" actionListener="#{fieldController.fillListFields()}" ajax="false"/>
</p:panelGrid>
<!-- start of filter panel -->
<div id="filter_datatable" >
<p:dataTable var="car" value="#{fieldController.listFields}" id="carList" editable="true">
<f:facet name="header">
Requête
</f:facet>
<p:ajax event="rowEdit" listener="#{fieldController.onEdit(event)}" />
<p:ajax event="rowEditCancel" listener="#{fieldController.onCancel(event)}" />
<p:column style="width:6%">
</p:column>
<p:column headerText="Champ" style="width:24%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.field}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{car.field}" >
<f:selectItems value="#{car.field}"
var="man"
itemLabel="#{man}"
itemValue="#{man}" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Valeur" style="width:20%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.value}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.value}" style="width:100%" label="pseudo"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:6%">
<p:rowEditor />
</p:column>
</p:dataTable>
<p:commandButton value="Filtrer"/>
</div>
<!-- end of filter panel -->
</p:panelGrid>
<iframe name="iframe" src="carto.jsp" height="500" width="950" id="iframe"></iframe>
</p:panelGrid>
</h:form>