2 Replies Latest reply on May 14, 2011 6:20 PM by iabughosh

    Dynamically passing bean to rich:popupPanel

    nikh123123

      I have a base class, which is normal Java class. Three subclasses extend it which are @ViewScopedbeans. There's a facelet using a dynamic variable. I have three xhtml pages which use this facelets with the three beans viz. bean1, bean2 and bean3 which are dynamically included in arich:tab component on a main page. So far so good. But on every page there are a few popups which should refer to the current bean. And since those popups need form tag inside them, I have included them outside the main page's form tags in order to avoid nested form tags. Now I want the popup to refer to current bean (bean1, bean2 or bean3, depending upon from where the popup is called) in question. How do I achieve this?

        • 1. Dynamically passing bean to rich:popupPanel
          mp911de

          Hi Nikhil,

          define a own variable Name for the interchangeable Bean. Then, when you step on your page you set the current bean to your generic variable.

           

          e.g. public void showPopupFromBean1()

          {

               Bean1 bean1 = getBean1();

               FacesContext.getExternalContext().getSessionMap().put("currentBean", bean1);

          }

           

          Best regards,

          Mark

          • 2. Dynamically passing bean to rich:popupPanel
            iabughosh

            if you want to make your pop up common, attach it to a separate bean then send the current bean to the pop up bean :

            <a4j:commandButton value="show"

                                                                         render="popupID"

                                                                         oncomplete="#{rich:component('popupID')}.show();return false;">                                                                         

                                                       <f:setPropertyActionListener value="#{user.currentBean}" target="#{user.popupBean}" />                                                        

                              </a4j:commandButton>

                              <rich:popupPanel id="popupID"

                                                                       domElementAttachment="form">                  

                                        <h:outputText value="#{user.popupBean.value}" />

                                        <h:commandButton value="close"

                                                                                 onclick="#{rich:component('popupID')}.hide();return false;"/>

                              </rich:popupPanel>