6 Replies Latest reply on Feb 10, 2011 6:43 AM by Marton Horvath

    Rich suggestionbox issue with f:setPropertyActionListener

    Marton Horvath Newbie

      Hello,

       

      I'm trying to get a suggestionbox to work with f:setPropertyActionListener with no success. I'm doing it as it should be done, using the actionListener in an a4j:support element listening to the onselect event. But anyhow I set the value property of the actionListener, I always got a null for it at the end. I read about this problem in earlier posts, but as far as I saw this was a bug and got fixed around Richfaces 3.1.x. I'm using 3.3.3.Final now. Could this a bug again or could this be a problem somewhere in my enviroment? I'm developing portlets under Liferay with Richfaces.

       

      Thanks in advance,

      Marton

        • 2. Re: Rich suggestionbox issue with f:setPropertyActionListener
          Marton Horvath Newbie

          This is the code used in portlets. We just include it where it's needed.

           

          {code:xml}

          <ui:composition xmlns="http://www.w3.org/1999/xhtml"

                    xmlns:ui="http://java.sun.com/jsf/facelets"

                    xmlns:h="http://java.sun.com/jsf/html"

                    xmlns:f="http://java.sun.com/jsf/core"

                    xmlns:a4j="http://richfaces.org/a4j"

                    xmlns:rich="http://richfaces.org/rich">

           

                    <h:panelGroup>

                       <a4j:region id="region">

                            <table>

                                 <tr>

                                      <td><h:outputText value="*" rendered="#{required}" /></td>

                                      <td><h:outputLabel for="#{componentId}" value="#{label}" title="#{title}" /></td>

                                      <td><h:inputText id="#{componentId}"

                                                required="#{required and !readonly}" readonly="#{readonly}"

                                                   maxlength="#{maximum}" title="#{title}" >

                                          </h:inputText>

                                          <rich:suggestionbox for="#{componentId}" var="userActor"

                                                  suggestionAction="#{suggestionBean.autoCompleteActor}" width="350"

                                                  minChars="3" nothingLabel="#{msgCommon['noMatchesFound']}"

                                                  ignoreDupResponses="true">

                                                  <h:column>

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

                                                  </h:column>

                                                  <h:column>

                                                    <h:outputText value="#{userActor.label}" />

                                                  </h:column>

                                                  <a4j:support event="onselect" ajaxSingle="true">

                                                    <f:setPropertyActionListener target="#{targetProperty}" value="#{userActor.value}" />

                                               </a4j:support>

                                           </rich:suggestionbox></td>

                                       <td width="28">

                                            <a4j:status for="region">

                                                    <f:facet name="start">

                                                      <h:graphicImage value="/images/actions/suggestionStatus.gif"

                                                           style="padding-left: 3px;" />

                                                    </f:facet>

                                          </a4j:status>

                                       </td>

                                 </tr>

                            </table>

                       </a4j:region>

                    </h:panelGroup>

          </ui:composition>

          {code}

           

          The problem is that the #{userActor.value} expression expressed to a null value when the target property's setter is called. But the value is valid and not null as it is displayed by the suggestionbox as a result.

          • 3. Re: Rich suggestionbox issue with f:setPropertyActionListener
            Ilya Sorokoumov Master

            Please try a4j:actionparam instead of f:setPropertyActionListener

            • 4. Re: Rich suggestionbox issue with f:setPropertyActionListener
              Marton Horvath Newbie

              I changed the setPropertyActionListener to a4j:actionparam, but no success. The property's setter method didn't even get called. Used it the following way:

              {code:xml}<a4j:actionparam name="userActor" value="#{userActor.value}" assignTo="#{targetProperty}"/>{code}

              Tried to set the surrounding a4j:support tag's ajaxSingle and immediate attributes, but nothing changed.

              • 5. Re: Rich suggestionbox issue with f:setPropertyActionListener
                Marton Horvath Newbie

                Some more info about a4j:actionparam I found out: tried to use it without the assignTo parameter to set a request parameter value and process that with a method in my backing bean. If I use a static value as value parameter of the a4j:actionparam it works properly. But if I put an EL expression as value I only get an empty string as request parameter value.

                • 6. Re: Rich suggestionbox issue with f:setPropertyActionListener
                  Marton Horvath Newbie

                  Ok, I found the solution: we had the following context-param in our web.xml:

                  {code:xml}

                  <context-param>

                       <param-name>facelets.BUILD_BEFORE_RESTORE</param-name>

                       <param-value>true</param-value>

                  </context-param>{code}

                  After deleting this, everything works as expected.