5 Replies Latest reply on Mar 2, 2007 10:36 AM by Peter Brewer

    Argh!  Attribute access

    Todd Main Newbie

      I have some attributes on my session bean, accessible via the local interface with getters and setters.

      For example:

      public int getPageSize();
      public void setPageSize(int size);


      I tried moving these to an Outjected named bean (session scope) and I got "NumberFormatException" when rendering the JSF component in my facelet:

      @Out private TableDataList page;


      <h:inputText id="pageSize" value="#{page.pageSize}" />


      I then tried making the "page" bean accessible via getters and setters on the session bean:

      public TableDataList getPage();


      and changed the JSF code to:

      <h:inputText id="pageSize" value="#{alertSession.page.pageSize}" />


      Ack - still getting the NumberFormatException. There is literally no difference in the getPageSize() and setPageSize() methods on the session bean vs the page bean. Any ideas?

      Here's the stack trace:

      
      [/coERROR {STDERR} LoggerStream.write - Aug 28, 2006 10:21:28 AM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/Alerts.xhtml]
      javax.el.ELException: /Alerts.xhtml: For input string: "pageSize"
       at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:50)
       at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:554)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.NumberFormatException: For input string: "pageSize"
       at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
       at java.lang.Integer.parseInt(Integer.java:447)
       at java.lang.Integer.parseInt(Integer.java:497)
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:138)
       at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
       at com.sun.facelets.el.ELText$ELTextVariable.writeText(ELText.java:184)
       at com.sun.facelets.el.ELText$ELTextComposite.writeText(ELText.java:108)
       at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
       ... 28 more
      de]


        • 1. Re: Argh!  Attribute access
          Todd Main Newbie

          Anyone? I'd settle for "you're a moron: read page XX in the manual"...

          • 2. Re: Argh!  Attribute access
            William Huang Newbie

            I am getting the same error with similar xhtml code, but my error is coming from <h:outputText "#{bean.firstName}"/> which is even more crazy... No one seen this? Texan, if you found the solution, please post it up. Thanks

            • 3. Re: Argh!  Attribute access
              Norman Richards Master

              This doesn't make sense. Can you post your entire xhtml page?

              • 4. Re: Argh!  Attribute access
                William Huang Newbie

                looks like I found the problem. the data list has inconsistent data types. therefore the unable to call methods.

                • 5. Re: Argh!  Attribute access
                  Peter Brewer Novice

                  For anyone else that runs into this problem - it occurs because it is not permitted to call a method of a List implementation - you can only access its index. The following example will fail with the error mentioned previously.

                  E.g. SummingList.java

                  public class SummingList extends ArrayList<Integer> {
                   ...
                   public Long getSum() {
                   Long sum = 0L ;
                   for (Integer value : this) {
                   if (value != null) {
                   sum += value ;
                   }
                   }
                   return sum ;
                   }
                   ...
                  }
                  


                  SummingList.xhtml
                   ...
                   <h:outputText value ="#{summingList.sum}" />
                   ...
                  


                  The workaround is to move the extra functionality to outside the list, e.g.
                  public class SummingList {
                  
                   public void setList(List<Integer> list) {...}
                   public List<Integer> getList() {...}
                  
                   public Long getSum() {...}
                  
                  }
                  



                  This looks like a facelets bug/ strange implementation choice to me:

                  LegacyELContext.java extract:
                  /* Line 137*/ if((base instanceof List) || base.getClass().isArray())
                  /* Line 138*/ return getPropertyResolver().getValue(base, Integer.parseInt(property.toString()));