9 Replies Latest reply on Jul 9, 2009 7:06 AM by ilya_shaikovsky

    Problem with a4j:support ?

    shandor

      Hi,

      I found out that when a value of a backing bean changes outside the INVOKE_APPLICATION phase ( for example when a UIInput value is submitted to the server via a4j:support with AjaxSingle=true and some logic in the setValue method on the backing bean will change the user submitted value) the user submitted value will be rendered rather than the updated one.

      Reading the source code of

      com.sun.faces.renderkit.html_basic.TextRenderer


      and

      com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer


      reveals that the encodeEnd(...) method will use the submittedValue if it is there regardless if the bound value of my bean changed:

       protected String getCurrentValue(FacesContext context, UIComponent component) {
      
       if (component instanceof UIInput) {
       Object submittedValue = ((UIInput) component).getSubmittedValue();
       if (submittedValue != null) {
       return (String) submittedValue;
       }
       }
      
       String currentValue = null;
       Object currentObj = getValue(component);
       if (currentObj != null) {
       currentValue = getFormattedValue(context, component, currentObj);
       }
       return currentValue;
       }


      Am I missing something here or is it a problem with the design of a4j:support ?


      BTW, I am using jsf 1.1_02 with richfaces 3.1.4.


      If it is not clear enough I will try to supply an example

      Will appreciate any help

        • 1. Re: Problem with a4j:support ?
          shandor

          Here is an example of what does not work. The outputText ( a2 ) and disabled inputText (a3) updates correctly. Enabled inputText (a1) will not update.

          <h:form id="myform">
          start here <h:inputText value="#{bean.text}" id="here">
          <a4j:support event="onkeyup" ajaxSingle="true" reRender="a1,a2,a3"/>
          </h:inputText>
          <br/>
          update a1 <h:inputText id="a1" value="#{bean.text}"/>
          <br/>
          update a2 <h:outputText id="a2" value="#{bean.text}"/>
          
          <br/>
          update a3 <h:inputText id="a3" value="#{bean.text}" disabled="true"/>
          
          
          </h:form>
          



          And the backing bean:

          public class TestBean {
          
           private String text="hello";
          
           public String getText() {
           return text;
           }
          
           public void setText(String text) {
           this.text = text;
           }
          }
          


          • 2. Re: Problem with a4j:support ?
            nbelaevski

            Hi,

            Please try 3.1.6.SR1.

            • 3. Re: Problem with a4j:support ?
              shandor

              Thanks for your advice. I tried with 3.1.6SR1 and got exactly the same behavior as in 3.1.4.

              Any other ideas ?

              Thanks
              Shandor

              • 4. Re: Problem with a4j:support ?
                nbelaevski

                Hi Shandor,

                Looks like, this won't work in 3.1.x. What about upgrading to JSF 1.2/RF 3.3.1?

                • 5. Re: Problem with a4j:support ?
                  shandor

                  Hello nbelaevski,

                  This does not work also after upgrading to JSF 1.2/RF 3.3.1.

                  Do you have any other ideas ?

                  It might be an oversight in the design of the a4j:support component. It is strange that not many people came across this one before.
                  My application is highly dynamic. It is actually a port of a swing based application to jsf so the behavior is much more dynamic than a regular web application... But this is where the power of jsf and richfaces really is, no ?

                  Will appreciate a response from the RichFaces team for this one.

                  Shandor

                  • 6. Re: Problem with a4j:support ?
                    nbelaevski

                    Shandor,

                    I cannot confirm this. Your code works ok with 3.3.1.GA.

                    • 7. Re: Problem with a4j:support ?

                      Yes , I have tested this is working fine with JSF 1.2/RF 3.3.1.
                      But if ajaxSingle="true" not there then event if updating it not not take the effect as page value will be submitted and shown instead of updated value though id's are mentioned in reRender

                      • 8. Re: Problem with a4j:support ?
                        shandor

                        Hi nbelaevski,

                        Thanks - It does work on 3.3.1. I had some config problems..
                        Any chances this is going to be fixed for 3.1.6 ?
                        Maybe I can help.

                        Thanks
                        shandor

                        • 9. Re: Problem with a4j:support ?
                          ilya_shaikovsky

                          try to use region around the component instead of ajaxSingle.