6 Replies Latest reply on Jun 3, 2008 10:07 AM by Mirek Okonoiewski

    RichFaces MessageBox

    Mirek Okonoiewski Newbie

      I wonder how to implement a MessageBox in RF ?
      MessageBox should be triggered from a backing bean, and user choices must trigger a proper action in bean, like :

       answer = showMB(); //show messagebox, wait for Yes,No answer
       } else {

      The best choice for MessageBox in RF seems to be modalPanel. But there is some challenge to meet :

      1. modalPanel should be fired from the server code, not from the page using Richfaces.showModalPanel() or
      <rich:componentControl for="panel" attachTo="link" operation="show" event="onclick" >

      2. ModalPanel should not have a own form. Normally, in bigger application, there is only one main page with main form and pages are included using subview or similar technics. So, how to get commandButtons to fire without own form ?

        • 1. Re: RichFaces MessageBox
          Ilya Shaikovsky Master

          1) could be freelly implemented usign EL binding on showWhenRendered attribute and manipulating with this binding on server.

          2) You could not perform submit without for in modal. And there is no workaround for this. But why this such a problem for you?

          • 2. Re: RichFaces MessageBox
            Mirek Okonoiewski Newbie

            2. Maybe there is no problem to fire a method on the server side using <a4j:commandButton without any form in modalPanel. I don't know. I have to test it.

            • 3. Re: RichFaces MessageBox
              Ilya Shaikovsky Master

              daswidanja, you can't perfomrm any submit without form. So this is a limitation and there is nothing to try. I mean why the form inside the panel is such a limitation for you?

              • 4. Re: RichFaces MessageBox
                Mirek Okonoiewski Newbie

                Because all pages in hole application has only one main page with <a4j:form> and are included like

                <f:subview id="body">
                 <jsp:include page="/jsf/prodcat/productMain.jsf" flush="false"></jsp:include>

                So, when I render a page, the main <a4j:form> is always there.

                • 5. Re: RichFaces MessageBox
                  Ilya Shaikovsky Master

                  then you need to include the modal also here conditionally ;)

                  • 6. Re: RichFaces MessageBox
                    Mirek Okonoiewski Newbie

                    what about this :

                    <script language="javascript">
                     function getAnswer(answer){
                     var dest = document.getElementById("mainForm:mboxAnswer");
                     var destForm = document.getElementById("mainForm");
                    <a4j:form id="mainForm">
                    <h:panelGrid id="_productMainGrid" columnClasses="outer-frame" border="0">
                     <a4j:commandButton onclick="Richfaces.showModalPanel('mp',{width:450, top:200});" value="showModalPanel" />
                     <h:inputHidden id="mboxAnswer" value="#{testMBean.mboxAnswer}" />
                     <rich:modalPanel id="mp" minHeight="200" minWidth="450" height="200" width="500" zindex="2000">
                     <f:facet name="header">
                     <h:outputText value="Modal Panel Title" />
                     <f:facet name="controls">
                     <h:graphicImage value="/pictures/close.png" style="cursor:pointer" onclick="getAnswer('no');" />
                     <h:graphicImage value="/pictures/yes.png" style="cursor:pointer" onclick="getAnswer('yes');" />
                     <h:graphicImage value="/pictures/no.png" style="cursor:pointer" onclick="getAnswer('no');" />