4 Replies Latest reply on Jun 7, 2010 1:22 PM by mkienenb

    component.resetValue() has no effect for a4j reRender

    mkienenb

      I have an existing JSF non-ajax page that I have been converting to use a4j.

       

      The original page had a subform with several fields on it that were cleared on each successful submit.

      The input fields were bound to the backing bean containing the action, and the method called

       

                component.resetValue()

       

      on each component, which is the JSF 1.2 equivalent of

       

                component.setSubmittedValue(null);
                component.setLocalValueSet(false);

       

      This forced the component fields to refetch the default model values, as if the page were being rendered the first time.

       

      Now that I've converted the action to an actionListener, and use a4j:support on my submitting button, reRendering the input fields does not reflect the backing model value.   Each component's submitted value remains displayed.

       

      Updated:

      I should have mentioned that I am using the following jar files:

       

      myfaces-api-1.2.8.jar
      myfaces-impl-1.2.8.jar
      richfaces-api-3.3.3.Final.jar
      richfaces-impl-3.3.3.Final.jar
      richfaces-ui-3.3.3.Final.jar
      tomahawk-1.1.9.jar
      tomahawk-sandbox-1.1.9.jar
      jsf-facelets-1.1.14.jar

       

      Message was edited by: Mike Kienenberger

        • 1. Re: component.resetValue() has no effect for a4j reRender
          ilya_shaikovsky
          and use a4j:support on my submitting button.

          seems you made common mistake - defining support on action component will cause two concurrent requests. One from command component itself and second from support. components with built-in ajax like a4j:command* should not have nested support in order to rise requests.

          • 2. Re: component.resetValue() has no effect for a4j reRender
            mkienenb

            Thanks for your response.   I am already using 'disableDefault="true"' so that only the ajax request will be sent.

            Even if I had made that mistake and was submitting the request twice, the original problem would remain.

             

            Updated (mlk):  I see now that you are also assuming that I am using a4j:commandButton.  I am using a non-ajax command button (tomahawk command button in this particular case).

            • 3. Re: component.resetValue() has no effect for a4j reRender
              mkienenb

              Since no one has responded, there's apparently is no simple obvious answer.

               

              Thus, I have created a standalone minimal example application demonstrating this problem, which uses only Myfaces 1.2.8 core, facelets, and Richfaces 3.3.3 Final.

               

              SimpleRichFacesProject-no-jar-dependencies.zip (10kb) does not include any of the jar files in the lib for those who just want to quickly look at the code.  The jar files used are listed in the Eclipse .classpath file in the root of the project.

               

              SimpleRichFacesProject.zip (7.6Mb) includes the jar files, but no container to run the project.

               

              I ran it using jetty-6.1.14.   environment-specific-libraries.user-library.xml contains the pointers to my jetty container jar files.  This file is an exported Eclipse user-library.   An eclipse user can install jetty somewhere on their system, modify the path to jetty in environment-specific-libraries.user-library.xml and import the user-library as "environment-specific-libraries" and run the "Jetty jsf project.launch" configuration target from Eclipse.

               

              I put both an ajax submit button (h:commandButton containing a4j:support) and a standard h:commandButton in a form with an h:inputText field, both of which call the same actionListener.   Both add the value of the inputText field to the list of added items, but only the non-ajax button clears the input field value.

              • 4. Re: component.resetValue() has no effect for a4j reRender
                mkienenb

                One more addition before I open a bug tracking issue.


                Adding <a4j:log> yields this error ""New node for ID j_id5:addItemForm is not present  in response" which would seem to be related to the rerendering of the input fields in addItemForm.

                 

                debug[13:18:54,566]: Update  part of page for Id: j_id1 successful
                debug[13:18:54,566]: Update page part from call  parameter for ID j_id5:addItemForm
                debug[13:18:54,567]: call getElementById for id=  j_id5:addItemForm
                error[13:18:54,567]:  New node for ID j_id5:addItemForm is not present in response
                debug[13:18:54,567]: Update page part  from call parameter for ID itemListContainer
                debug[13:18:54,567]: call getElementById  for id= itemListContainer