2 Replies Latest reply on Jul 14, 2008 8:00 PM by madhav_inamti

    modal question.

      I have a modal panel. Upon pressing ok, I perform some actions and close the modal. At this time I want to display a message in the main page. How do I do it? Do I need to call FacesMessage.addToControl in the javascript?

      Any help is appreciated.

      The code I have is

      <a:commandButton id="save"
       value="Save Foo"
       action="#{foo.save}"
       reRender="foo-foo1"
       oncomplete="javascript:closeModalPanel('fooModal');"
       view="#"/>
      



        • 1. Re: modal question.
          ilya_shaikovsky

          so just update message on the main page with reRender or use rich:messages.

          • 2. Re: modal question.

            Ilya,

            Can you please explain with code. It has been holding me up for sometime.

            Here's what I have

            Main Page

            <ui:define name="main_content">
             <h:messages id="mainMessage" styleClass="message" rendered="true"/>
            


            Button to invoke Modal

            <a:commandLink reRender="modalFooContent"
             eventsqueue="foo"
             oncomplete="Richfaces.showModalPanel('addFoo',{width:650, top:200})">
             <h:outputText value="Add/Edit Foo"/>
             </a:commandLink>
            



            AddFoo Modal

            <a:form id="modalFooContent">
             <rich:messages id="modalMessages" styleClass="message" globalOnly="true" ajaxRendered="true"/>
            
            


            Button inside Modal

            <a:commandButton id="save"
             value="Save Foo"
             action="#{fooFoo.saveFoo}"
             oncomplete="javascript:closeModalPanel('addFoo');"
             reRender="mainMessage"
             eventsQueue="foo"
             view="#"
             />
            


            and in fooFoo.saveFoo I have

            
            FacesMessages.instance().addToControl("mainMessage",
             FacesMessage.SEVERITY_INFO,
             "Foo saved successfully");
            


            After clicking the button on the modal, I do not see the message anywhere. The modal closes immediately. I want this message to appear in the main page with the control that has id "mainMessage".