Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#{bean.list.size} causes java.lang.NumberFormatException: For input string: "size"

Tags:

list

jsf

size

el

Here is my xhtml , i have problem with rendered attribute. I get an error about "size" of my list. I want to render the datatable only if some data found.Couldnt find how to fix it.Thank you for your time.

<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>

Here is my exception stack trace...

    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)
like image 778
Mesut Can Avatar asked Dec 15 '22 16:12

Mesut Can


1 Answers

Your problem is that you are missing brackets after #{userMB.users.size}. It should be modified to this:

<p:panelGrid id="pnluserresult" columns="1"
                rendered="#{(userMB.users.size() eq 0) or (userMB.users.size() gt 0)} ">
like image 148
Denorm Avatar answered Dec 20 '22 20:12

Denorm