1 2 Previous Next 16 Replies Latest reply on Apr 16, 2007 2:16 PM by Stuart Robertson

    Problem using Expression language enhancements

    Samuel Mendenhall Apprentice

      I've had this problem in CR1 and now CR2.

      I follow the instructions in Chapter 18: Expression language enhancements but I still get exceptions when trying whatever.doMethod() in the expression language. Any pointers would be appreciated.

      faces-config.xml

      <faces-config>
       <application>
       <view-handler>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</view-handler>
       </application>
      
       <application>
       <message-bundle>messages</message-bundle>
       <view-handler>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</view-handler>
       </application>
      
       <lifecycle>
       <phase-listener>
       org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener
       </phase-listener>
       </lifecycle>
      </faces-config>
      


      Purchase.java
      @Entity
      @Role(name="tempPurchase", scope=ScopeType.EVENT)
      @Table(name="purchases")
      public class Purchase implements Serializable {
      
       ...
      
       private String status;
      
       ...
      
       public String getStatus() {
       return status;
       }
       public void setStatus(String status) {
       this.status = status;
       }
      
       ...
      
      }
      


      viewPurchases.xhtml
       <h:column>
       <f:facet name="header">
       <h:commandLink value="Status" action="#{viewPurchases.reorder}">
       <f:param name="orderBy" value="status"/>
       </h:commandLink>
       </f:facet>
       <h:outputText value="#{purchase.getStatus()}" />
       </h:column>
      



      10:43:01,944 ERROR [STDERR] Dec 1, 2006 10:43:01 AM com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/viewPurchases.xhtml]
      com.sun.facelets.tag.TagAttributeException: /viewPurchases.xhtml @151,55 value="#{purchase.getStatus()}" Error Parsing: #{purchase.getStatus()}
       at com.sun.facelets.tag.TagAttribute.getValueExpression(TagAttribute.java:259)
       at com.sun.facelets.tag.jsf.ValueHolderRule$DynamicValueBindingMetadata.applyMetadata(ValueHolderRule.java:115)
       at com.sun.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:36)
       at com.sun.facelets.tag.MetaTagHandler.setAttributes(MetaTagHandler.java:62)
       at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:140)
       at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
       at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
       at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
       at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
       at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
       at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
       at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
       at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
       at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
       at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
       at com.sun.facelets.tag.ui.DefineHandler.apply(DefineHandler.java:58)
       at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:128)
       at com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:306)
       at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:279)
       at com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
       at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
       at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
       at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
       at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
       at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
       at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
       at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
       at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:143)
       at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
       at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
       at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
       at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
       at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:510)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:553)
       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.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
       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.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       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:619)
      Caused by: javax.el.ELException: Error Parsing: #{purchase.getStatus()}
       at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:140)
       at com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:157)
       at com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:201)
       at com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:74)
       at com.sun.facelets.tag.TagAttribute.getValueExpression(TagAttribute.java:256)
       ... 60 more
      Caused by: com.sun.el.parser.ParseException: Encountered "(" at line 1, column 21.
      Was expecting one of:
       "}" ...
       "." ...
       "[" ...
       ">" ...
       "gt" ...
       "<" ...
       "lt" ...
       ">=" ...
       "ge" ...
       "<=" ...
       "le" ...
       "==" ...
       "eq" ...
       "!=" ...
       "ne" ...
       "&&" ...
       "and" ...
       "||" ...
       "or" ...
       "*" ...
       "+" ...
       "-" ...
       "?" ...
       "/" ...
       "div" ...
       "%" ...
       "mod" ...
      
       at com.sun.el.parser.ELParser.generateParseException(ELParser.java:1651)
       at com.sun.el.parser.ELParser.jj_consume_token(ELParser.java:1531)
       at com.sun.el.parser.ELParser.DeferredExpression(ELParser.java:134)
       at com.sun.el.parser.ELParser.CompositeExpression(ELParser.java:61)
       at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:103)
       ... 64 more
      


        • 1. Re: Problem using Expression language enhancements
          Pete Muir Master

          I think the enhancements only apply when you are invoking a action not a value binding. So, use the normal...

          <h:outputText value="#{purchase.status}" />


          • 2. Re: Problem using Expression language enhancements
            ngeadah Newbie

            I was facing the same problem and also realized that the EL enhancements are not for value binding - which raises the question: wouldn't those EL enhancement be very useful for value bindings as well?

            As an example:

            <f:selectItems value="#{aReferenceDataManager.getSomeReferenceData('state')}" />
            


            • 3. Re: Problem using Expression language enhancements
              Samuel Mendenhall Apprentice

              I am also getting exceptions when I try to invoke action methods. I actually reproduced the docs example of print.println('Hello World!')

              However, when I go invoke an action method with parameters, it craps out. Any idea of what could cause this, because the documentation says I can do the following syntax:

              <s:link value="Cancel" action="#{hotelBooking.cancel()}"/>
              


              I changed the getStatus() to status and it works, I was just using that as an example previously, but here is what I really want to get working:

              Purchase.java
              ...
              @Transient
               public Double totalUnitCost() {
               double total = 0;
               for(Item item : items) {
               total += item.getUnitCost();
               }
               return total;
               }
              ...
              


              viewPurchases.xhtml
              ...
              <!-- Total Unit Cost-->
               <h:column>
               <f:facet name="header">
               <h:outputText value="Total Unit Cost" />
               </f:facet>
               <h:outputText value="#{purchase.totalUnitCost()}" />
               </h:column>
              ...
              


              12:13:31,140 ERROR [STDERR] Dec 1, 2006 12:13:31 PM com.sun.facelets.FaceletViewHandler handleRenderException
              SEVERE: Error Rendering View[/viewPurchases.xhtml]
              com.sun.facelets.tag.TagAttributeException: /viewPurchases.xhtml @159,58 value="#{purchase.totalUnitCost()}" Error Parsing: #{purchase.totalUnitCost()}
               at com.sun.facelets.tag.TagAttribute.getValueExpression(TagAttribute.java:259)
               at com.sun.facelets.tag.jsf.ValueHolderRule$DynamicValueBindingMetadata.applyMetadata(ValueHolderRule.java:115)
               at com.sun.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:36)
               at com.sun.facelets.tag.MetaTagHandler.setAttributes(MetaTagHandler.java:62)
               at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:140)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
               at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
               at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
               at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.tag.ui.DefineHandler.apply(DefineHandler.java:58)
               at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:128)
               at com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:306)
               at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:279)
               at com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
               at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
               at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
               at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
               at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:143)
               at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
               at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
               at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
               at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
               at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:510)
               at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:553)
               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.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
               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.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
               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:619)
              Caused by: javax.el.ELException: Error Parsing: #{purchase.totalUnitCost()}
               at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:140)
               at com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:157)
               at com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:201)
               at com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:74)
               at com.sun.facelets.tag.TagAttribute.getValueExpression(TagAttribute.java:256)
               ... 60 more
              Caused by: com.sun.el.parser.ParseException: Encountered "(" at line 1, column 25.
              Was expecting one of:
               "}" ...
               "." ...
               "[" ...
               ">" ...
               "gt" ...
               "<" ...
               "lt" ...
               ">=" ...
               "ge" ...
               "<=" ...
               "le" ...
               "==" ...
               "eq" ...
               "!=" ...
               "ne" ...
               "&&" ...
               "and" ...
               "||" ...
               "or" ...
               "*" ...
               "+" ...
               "-" ...
               "?" ...
               "/" ...
               "div" ...
               "%" ...
               "mod" ...
              
               at com.sun.el.parser.ELParser.generateParseException(ELParser.java:1651)
               at com.sun.el.parser.ELParser.jj_consume_token(ELParser.java:1531)
               at com.sun.el.parser.ELParser.DeferredExpression(ELParser.java:134)
               at com.sun.el.parser.ELParser.CompositeExpression(ELParser.java:61)
               at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:103)
               ... 64 more
              


              • 4. Re: Problem using Expression language enhancements
                Samuel Mendenhall Apprentice

                Hmm, I think I know the problem. I am trying to access action methods with the Enhanced EL in an Entity, which probaly is not going to work since I'm assuming EL assumes everything is field level access.

                So the reason I got one of the examples working before is because I did it from an EJB3 and not an entity.

                If I am right, maybe the docs should be specific that action methods can not be accessed within entity beans.

                • 5. Re: Problem using Expression language enhancements
                  Samuel Mendenhall Apprentice

                  Actually, the way I'm getting around this is to define a Transient field with the name of the action method.

                  so:

                  ...
                  @Transient private Double totalUnitCost;
                  ...
                  @Transient
                   public Double getTotalUnitCost() {
                   double total = 0;
                   for(Item item : items) {
                   total += item.getUnitCost();
                   }
                   return total;
                   }
                  ...
                  


                  and in the EL:
                  <!-- Total Unit Cost-->
                   <h:column>
                   <f:facet name="header">
                   <h:outputText value="Total Unit Cost" />
                   </f:facet>
                   <h:outputText value="#{purchase.totalUnitCost}" />
                   </h:column>
                  


                  • 6. Re: Problem using Expression language enhancements
                    Pete Muir Master

                    No.

                    Starting from the beginning, most JSF components attributes take ValueBindings.A ValueBinding references either a public field or a getter/setter method pair (a 'property') - in other words a JavaBean. EL automatically translates foo.bar into foo.getBar() and foo.setBar().

                    Some attributes take MethodBindings - action methods, action listeners, valuechange listeners. These reference the method directly i.e. action="#{foo.bar}" would call foo.bar() in the INVOKE_APPLICATION phase of JSF.

                    All the code you are trying to get work is valuebinding, which, correct me if I'm wrong, doesn't support the EL enhancement. Nothing to do with Entities, fields, sessions beans etc.

                    • 7. Re: Problem using Expression language enhancements
                      Samuel Mendenhall Apprentice

                      I was originally trying to get an action method working:

                      I wanted purchase.totalUnitCost() to map to the method public Double totalUnitCost()

                      I only had to convert it to ValueBinding because I couldn't get the action method to work.

                      • 8. Re: Problem using Expression language enhancements
                        Samuel Mendenhall Apprentice

                        Clarification: #{purchase.totalUnitCost()} to map to public Double totalUnitCost()

                        • 9. Re: Problem using Expression language enhancements
                          Gavin King Master

                          Right. Jacob is working on a new EL that will make all these hacks obsolete.

                          • 10. Re: Problem using Expression language enhancements
                            James Hays Novice

                            is this working now? I'm having trouble in my application getting to work and am wondering if the fix has been implemented, or if it is still in the works.

                            Thanks.

                            • 11. Re: Problem using Expression language enhancements
                              Pete Muir Master

                              Still in the works, slated for 1.3 currently

                              • 12. Re: Problem using Expression language enhancements
                                James Hays Novice

                                 

                                "petemuir" wrote:
                                Still in the works, slated for 1.3 currently


                                Do we have a timeframe for 1.3? I need to make a decision quickly on how to proceed.

                                Thanks.

                                • 13. Re: Problem using Expression language enhancements
                                  Pete Muir Master

                                  There should be a beta in early may

                                  • 14. Re: Problem using Expression language enhancements
                                    James Hays Novice

                                    Do we have a Jira issue for this?

                                    1 2 Previous Next