4 Replies Latest reply on Oct 8, 2007 5:22 AM by Emil Nilimaa

    create modal panel dinamically

    kelly goedert Apprentice


      how can I create a modal panel on the java code and display it on the screen? Is there an example on the documentation?



        • 1. Re: create modal panel dinamically
          Ilya Shaikovsky Master

          you may use standard binding to create it dynamically.

          As for calling - its just JS functions calls so you may cal them in any handler you need.

          • 2. Re: create modal panel dinamically
            kelly goedert Apprentice

            Could you please give me an example?

            • 3. Re: create modal panel dinamically
              Ilya Shaikovsky Master

              please (a very simple example):


               <a4j:commandButton value="showMp" oncomplete="javascript:Richfaces.showModalPanel('_panel',{left:'auto', top:'auto'})" action="#{mpBean.mpInit}" reRender="test"/>
               <a4j:outputPanel id="test">
               <rich:modalPanel binding="#{mpBean.mp}"/>

              Java code:
              import javax.faces.component.html.HtmlOutputText;
              import org.richfaces.component.html.HtmlModalPanel;
              public class MpBean {
               HtmlModalPanel mp = new HtmlModalPanel();
               public MpBean() {
               public String mpInit() {
               HtmlOutputText text= new HtmlOutputText();
               mp.getFacets().put("header", text);
               HtmlOutputText text2 = new HtmlOutputText();
               return null;
               public HtmlModalPanel getMp() {
               return mp;
               public void setMp(HtmlModalPanel mp) {
               this.mp = mp;

              So after button pressed - mp is created, refreshed on a page and called after request completed.

              • 4. Re: create modal panel dinamically
                Emil Nilimaa Newbie

                How do you actually show the modal panel from the backing bean?

                Suppose you have a method in the bean, and that method returns and error, and you wish to show that in a modal panel. So you want to open the modal panel from within the backing bean method.