7 Replies Latest reply on May 15, 2013 8:06 AM by alsha

    RF4: problem with rich:orderingList and converter

    alsha

      Hello,

       

      i use rich:orderingList to represent the list of objects. Name of each object is a command link. When clicking the link, the corresponding object must be passed in java bean using setter method.

       

       

      <rich:orderingList value="#{bean.objects}" var="object" converter="someConverter">
          <rich:column>
            <f:facet name="header">
              <h:outputText value="Objects" />
            </f:facet>
            <a4j:commandLink value="#{object.name}">
              <f:setPropertyActionListener value="#{object}" target="#{bean.selectedObject}" />
            </a4j:commandLink>
          </rich:column>
        </rich:orderingList>
      

       

      Re-ordering of objects works perfectly. The problem is object selection - null is always passed in java bean setter method.

       

      With RF3.3.x this snippet worked correctly.

       

      What am i doing wrong?

       

      Thanks for any help,

       

      Alexey

        • 1. Re: RF4: problem with rich:orderingList and converter
          michpetrov

          I think the #{object} is null by the time the expression evaluates (because the list has already been generated). I'm not sure why it works that way.

           

          Anyway, you can use <a4j:param> instead of <f:setPropertyActionListener>.

          • 2. Re: RF4: problem with rich:orderingList and converter
            alsha

            Hi Michal,

             

            thanks for your help. Unfortunately, <a4j:param> does not work - setter in java bean is not getting called at all (when link is clicked).

             

            Greetings,

             

            Alexey

            • 3. Re: RF4: problem with rich:orderingList and converter
              michpetrov

              I only changed this part:

               

              <a4j:commandLink value="#{object.name}" execute="@this">
                  <a4j:param value="#{object}" assignTo="#{bean.selectedObject}" />
              </a4j:commandLink>
              

               

              and it works. What is the scope of your bean?

              • 4. Re: RF4: problem with rich:orderingList and converter
                alsha

                I use Apache Orchestra's conversation scope.

                • 5. Re: RF4: problem with rich:orderingList and converter
                  michpetrov

                  Can you show me the bean?

                   

                  One thing that you're doing is that you are converting the objects from the bean to the list but you're not using the convertor to revert the object back when you send it to the bean. I missed that, but if you were trying to set a variable with something that has different type you should see an exception in the console.

                  • 6. Re: RF4: problem with rich:orderingList and converter
                    alsha

                    The bean has too much presentation logic,  which is nonrelevant to this case.

                    Actually I used a converter for a4j:param (the same as with rich:orderingList). Without converter I am getting Exception during render phase.

                    The point is: converter methods are not called, after commandLink was clicked, and the setter-method in java bean is not called as well.

                    • 7. Re: RF4: problem with rich:orderingList and converter
                      alsha

                      By the way, i have a workaround for the problem, which looks ugly, but works for me.

                       

                       

                      <rich:orderingList value="#{bean.objects}" var="object" converter="someConverter">
                          <rich:column>
                              <f:facet name="header">
                                  <h:outputText value="Objects" />
                              </f:facet>   
                              <a4j:outputPanel onclick="_js_#{object.id}()">
                                  <h:outputText value="#{object.name}" />
                              </a4j:outputPanel>
                          </rich:column>
                      </rich:orderingList>
                      
                      <a4j:repeat value="#{bean.objects}" var="object">
                          <a4j:jsFunction name="_js_#{object.id}">
                            <f:setPropertyActionListener value="#{object}" target="#{bean.selectedObject}" />
                          </a4j:jsFunction>
                      </a4j:repeat>