2 Replies Latest reply on Jun 12, 2007 9:00 AM by anescu

    Problem with immediate="true" and refresh page display

      Hi,

      I have this situation:
      It's a Seam-gen application (1.2.1). On one screen (Got entity Abc, managed by AbcHome), I added a checkbox:

      <h:selectBooleanCheckbox value="#{abcHome.instance.useExisting}" onclick="doRefresh()">
       </h:selectBooleanCheckbox>
      <h:commandButton id="submitter" style="visibility:hidden;" action="#{abcHome.refresh}" immediate="true">
      </h:commandButton>
      
      <script language="javascript">
       function doRefresh(){
       document.getElementById("abc:submitter").click();
       }
      </script>


      So, i have some fields that are rendered or hidden based on the #{abcHome.instance.useExisting} value. I added the
      refresh()
      method in the AbcHome class:
      public String refresh()
       {
       return "refresh";
       }


      The code works almost ok, I mean if I change any of the fields that are displayed the first time and click the checkbox the values are kept, but the page is not rerendered (meaning all field hidden remain hidden, all field that should become hidden remain visible).
      If I remove the
      immediate="true"
      part, then I find myself in another problem, the form validation is performed and the page is not sent to the server.

      I also tried to use an
      s:link
      instead, that would have sent me to the same page, but then I lost all the modifications I have already done.

      Any idea what is wrong? Is this a known problem with Seam? Or any other solution/workaround.

        • 1. Re: Problem with immediate=
          pmuir

           

          "anescu" wrote:
          If I remove the
          immediate="true"
          part, then I find myself in another problem, the form validation is performed and the page is not sent to the server.


          Placing immediate=true on a commandButton causes the action to be run during the APPLY_REQUEST_VALUES phase, resulting in the model update not occuring.

          I also tried to use an
          s:link
          instead, that would have sent me to the same page, but then I lost all the modifications I have already done.


          s:link doesn't submit the form.

          Is this a known problem with Seam? Or any other solution/workaround.


          This is really a JSF issue. Try also putting immediate=true on your checkbox, the model should then be updated (for that component only) during APPLY_REQUEST_VALUES. A better solution is to use more than one form (one for your hide/show, another for the data entry), then you don't need to use the immediate hack on the JSF lifecycle.

          • 2. Re: Problem with immediate=

            Thanks,

            I already tried the "two" forms option and it works. Only that the page looks like hell. But I can make it look ok, thats a design issue now :D.

            So, for the public:
            1) one form containing only the checkbox, javascript and the hidden button to do the refresh
            2) another to keep all the other fields.