5 Replies Latest reply on Oct 25, 2011 6:46 AM by Antonio P

    EL value expression error javax.el.PropertyNotFoundException

    Chris Russell Newbie

      In jboss-as 5 (Seam 2 and jsf 1.2) something like this used to work and we used the concept extensivly:

       

      {code:xml}

      <form>

      <h:inputText value="#{myAction.dogManager.getDog('FRED').age}"/>

      <h:commandButton action="#{myAction.doSomething()}"/>

      </form>

      {code}

      Where Dog object has a setAge() and getAge() method

      and MyAction has a method getDogManager() which returns a DogManager class.

      DogManager has a getDog(String nam) method.

       

      Now we are trying to convert to 7.0.2.Final it fails telling me there is no property getDog

      when I press the commandButton.

       

      Error Rendering View[/developer/dog.xhtml]: javax.el.PropertyNotFoundException: /developer/home.xhtml @41,160 value="#{myAction.getDog('FRED').age": The class 'com.me.DogManager' does not have the property 'getDog'.

       

      I can make it work in this particular case using this

       

      {code:xml}

      <h:inportText value="#{myAction.dogManager.dogs['FRED'].age}"/>

      {code}

       

      But that is not really a good solution since in other cases I may not be able to rely on an Collection for my dogs or objects that make up an expression.

       

      So, it renders initially (I dont know if it considers it a method expression at this point) correctly.

      When form is validated and it is attempting to set values in the backing bean it fails.

       

      It seams as though maybe it is considering it a method expression? when in fact it is a lvalue expression.

      I have seen discussions where people claim that anything with ('s and params is a method expression

      but I disagree. The final .age should force it to a lvalue.

       

      Not sure what I am missing here but this is causing me major grief and would appreciate any helpful discussion/hints.

       

      Is there any way to "force" an expresion to be evaluated as a lvalue?

      For that mater what really determines lvalue, rvalue, or method expression?

       

       

       

       

       

       

       


        • 1. Re: EL value expression error javax.el.PropertyNotFoundException
          Antonio P Newbie

          Hi Chris,

           

          I'm maybe not answering your question but, do you really need to use that data structure? I see you have a Map of objects (Dogs), are you hardcoding for each Dog an inputText like this?

           

          <h:inportText value="#{myAction.dogManager.dogs['FRED1'].age}"/>

          <h:inportText value="#{myAction.dogManager.dogs['FRED2'].age}"/>

          <h:inportText value="#{myAction.dogManager.dogs['FRED3'].age}"/>

          <h:inportText value="#{myAction.dogManager.dogs['FRED4'].age}"/>

           

          Maybe you could use a List of objects (Dogs), and then make a loop with ui:repeat (facelets) or c:foreach (JSTL). Maybe you could also use a simple data bean (scope session or request) and just populate data on it when it is needed in the controller.

           

          for example "myAction" gets the dogs information and populates it on the bean "listOfDogs" which contains the attribute "list" (list of dogs)... so you would have something like (just pseudo-code):

           

           

          <ui:repeat value= "#{listOfDogs.list}" item="dog">

                   <h:inputText value="#{dog.age}"/>

          </ui:repeat>

           

          In any case, if you don't have a collection, you just could have a bean "dog" and use it directly like  <h:inputText value="#{dog.age}"/>

           

          Best regards,

          Antonio.

          • 2. Re: EL value expression error javax.el.PropertyNotFoundException
            Chris Russell Newbie

            As stated initially, I can work around the problem by using the underlying Collection but this

            may not always be the case.

            The DogManager class may be some sort of helper class or legacy system adapter that has to

            run an RPG program on an AS400 to get at or create Dog objects (who knows).

             

            Point being that method invocation allows more abstraction than having to rely on Collections.

             

            So yes, using Collections to access named objects works but using methods to access named objects

            no longer works in AS7.

             

            I'm curious why that functionality (regardless of its merits) went away?

            • 3. Re: EL value expression error javax.el.PropertyNotFoundException
              Tim Snyder Newbie

              I also am having the same issue. I am upgrading my prototype to AS7, CDI, JSF2 and Richfaces 4. It seems like Weld no longer allows EL method expressions. These worked fine with the Glassfish version of JSF 2 and EL. For example the following .xhtml snippet generates the following runtime error:

               

              <h:selectOneListbox id="profile_nav_type_list" value="#{profileAction.selectedType}" styleClass="profile_type_select">
                <f:selectItems value="#{profileAction.profileSelects}"/>
                <f:ajax event="click" execute="#{profileAction.addProfile()}" render="profileForm" bypassUpdates="false" />
              </h:selectOneListbox>

               

              The error:

              Servlet.service() for servlet Faces Servlet threw exception: javax.el.PropertyNotFoundException: /layout/profile/profile_nav_panel.xhtml @45,114 execute="#{profileAction.addProfile()}": The class 'com.zensa.vault.ui.action.ProfileHandler$Proxy$_$$_WeldClientProxy' does not have the property 'addProfile'.

               

              I would appreciate understanding what I need to do - if I am doing something wrong, or if there is a workaround.

              • 4. Re: EL value expression error javax.el.PropertyNotFoundException
                Chris Russell Newbie

                These tricks may be useful but they still suck to have to do.

                Through brute force and ignorance I found a couple of workarounds.

                We want to call an initialization routine when starting the page e.g.

                 

                {code}

                <h:outputText value="#{myBean.initialize()}"/>

                public void initialize();

                {code}

                Worked great in as5.

                Now in as7 I have to change the return type of initialize to String and have it return("")

                AND I have to rename my method getInitialize(). Then in the EL

                 

                {code}

                <h:outputText value="#{myBean.initialize}"/>

                public String getInitialize();

                {code}

                 

                AND YET

                {code}

                <h:outputText value="#{myBean.otherFunction('parm1','parm2')}"/>

                {code}

                works just fine

                Dont understand why we are not seeing more action on this issue. It has got to be hurting others.

                 

                These tricks DO NOT however solve the original problem of needing a method to dereference an object within an el expression.

                In your case just change your method name to getAddProfile() and have it return a blank String then use .addProfile no parens.

                You may be able to leave the return type as void.

                • 5. Re: EL value expression error javax.el.PropertyNotFoundException
                  Antonio P Newbie

                  Hi,

                   

                  mmm... so it's like a trick to simulate a method as it was a property, right?

                   

                  the thing is that... maybe EL in any JSF input/output field should be used with properties and the method actions should be use in JSF command elements.

                   

                  maybe it worked in AS5 because of a server implementation bug and I guess it's working now in AS7 because the server "thinks" is accessing a property instead of an action method...

                   

                  would it be possible to execute all the initialization methods as a controller, populate data into beans, and then redirect to the view where the input/output elements can access the bean properties. Firstly, before accessing a view, a controller should be invoked in order to populate the data to a bean and so it is available to the view.

                   

                  best regards,

                  antonio.