这是我的xhtml,我有渲染属性的问题。我收到关于" size"的错误我的清单。我只想在找到一些数据的情况下渲染数据表。可以找到解决方法。谢谢你的时间。
<ui:composition template="/pages/admin/admin.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:define name="center">
<h:form id="updateform">
<p:growl id="messages"/>
<p:panel id="pnlUpdateUser" header="#{menu['menu.admin.usermanager.updateuser']}">
<p:panelGrid columns="2" styleClass="cm_ui-panel-grid">
<p:outputLabel value="#{menu['menu.admin.createuser.name']}" styleClass="cm_ui-output-label"/>
<p:inputText styleClass="cm_input-text" value="#{userMB.userQuery.name}" required="true" />
<p:outputLabel value="#{menu['menu.admin.createuser.surname']}" styleClass="cm_ui-output-label"/>
<p:inputText styleClass="cm_input-text" value="#{userMB.userQuery.surname}" />
<f:facet name="footer">
<p:commandButton value="#{menu.search}" actionListener="#{userMB.queryUsers}" update="pnluserresult"/>
</f:facet>
</p:panelGrid>
</p:panel>
<p:panelGrid id="pnluserresult" columns="1"
rendered="#{(userMB.users.size eq 0) or (userMB.users.size > 0)} ">
<p:dataTable id="userresulttable" var="user" value="#{userMB.users}">
<f:facet name="header">
<p:outputLabel value="#{menu['menu.admin.updateuser.list']}"/>
</f:facet>
<p:column headerText="#{menu['menu.admin.createuser.id']}">
<h:outputText value="#{user.id}" />
</p:column>
<p:column headerText="#{menu['menu.admin.createuser.name']}">
<h:outputText value="#{user.name}" />
</p:column>
<p:column headerText="#{menu['menu.admin.createuser.surname']}">
<h:outputText value="#{user.surname}" />
</p:column>
<p:column headerText="#{menu['menu.admin.createuser.grade']}">
<h:outputText value="#{user.grade}" />
</p:column>
</p:dataTable>
</p:panelGrid>
</h:form>
</ui:define>
</ui:composition>
这是我的异常堆栈跟踪...
java.lang.NumberFormatException: For input string: "size"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
at javax.el.ListELResolver.coerce(ListELResolver.java:157)
at javax.el.ListELResolver.getValue(ListELResolver.java:70)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:167)
at org.apache.el.parser.AstEqual.getValue(AstEqual.java:37)
at org.apache.el.parser.AstOr.getValue(AstOr.java:37)
at org.apache.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:43)
at org.apache.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:49)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:457)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1850)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:79)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:66)
at org.primefaces.component.layout.LayoutUnitRenderer.encodeEnd(LayoutUnitRenderer.java:49)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.software.cm.others.filters.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:23)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:8)
您的问题是您在#{userMB.users.size}之后缺少括号。它应该修改为:
<p:panelGrid id="pnluserresult" columns="1"
rendered="#{(userMB.users.size() eq 0) or (userMB.users.size() gt 0)} ">
答案 1 :(得分:0)
在某些情况下,像我一样,有必要以另一种方式检查,我有同样的问题,但出于某种原因,我仍然得到:
rendered="#{(varProcInstance.products != null)}"
我正在使用Java 8和JSF 2.0(这可能是原因吗?)
另一种检查方法是list属性是否为null,如果没有元素,请确保返回null,并在JSF Page中检查如下:
type Foo struct {
w byte //1 byte
x byte //1 byte
y uint64 //8 bytes
}
type Bar struct {
x byte //1 byte
y uint64 //8 bytes
w byte// 1 byte
}
func main() {
fmt.Println(runtime.GOARCH)
newFoo := new(Foo)
fmt.Println(unsafe.Sizeof(*newFoo))
newBar := new(Bar)
fmt.Println(unsafe.Sizeof(*newBar))
}
正如我所说,这对我有用,因为唯一的答案没有。
此致