2 Replies Latest reply on Oct 28, 2009 6:08 PM by fmontezuma

    Conversation + modal + form submit issue

    fmontezuma

      Hi,


      I have a conversation working on a page and in this page I have a button that opens a modal.


      In this modal I have a form that does some search. (I use a separate bean here)


      In this modal form I have some data validation.


      The point is:



      • Type something wrong at an input field.

      • Type something right at another input field.

      • Submit the form

      • Seam returns me the errors in the modal.

      • Close the modal without correcting the values (I have an action triggered here to set null to bean properties).

      • Open the modal again and the typed values still there.



      I figured out that forcing the form submit using oncomplete=document.form.submit() when I close the panel clean the wrong typed inputs, but it still returns me the right typed values which I don't want.


      Debugging the code I can see that Seam set the right values (I don't know why or how) after I force this form submission, which happens after my cleaning method.


      What can I do to clean the panel everytime I open it?


      Thanks in advance.

        • 1. Re: Conversation + modal + form submit issue
          lvdberg

          Hi Fabio,


          Use am Ajax button to open the ModalPanel and so-some-action. The ajax-button (or link) has all the attributes you need to make it work:


          Small example;




          <a4j:commandButton 
          id="noteButton"
          image="../images/Edit.gif"
          action="#{WaheteverAction.doWhatYouNeedTodo}"
          eventsQueue="inputQueue"
          oncomplete="#{rich:component('yourModalPanel')}.show();"
          reRender="yourModalPanelContent, yourModalPanelHeader" />




          The rerender attributes references two different id's in the modalmodal (one for the content and one for the header. The action can be used to clean-up everything.


          Leo

          • 2. Re: Conversation + modal + form submit issue
            fmontezuma

            Thanks for the tip Leo.


            Actually I already had try that. This piece of code alone doesn't work.
            I got it working now, but I had to force submit and form reRender on modal close too. (so wrong fields are cleaned)


            I feel like this isn't right but that was the only way I could get it working as expected.