8 Replies Latest reply on Jan 21, 2013 12:23 PM by davidbatteux

    [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)

    jadtn

      Hi,

      I've passe 1 week to do something with popupPanel, and I can't do it work as I expect.

       

      Context: I want to use a  rich:popupPanel in my pages. I want to open it from many h:form, so I put the popup outside any form.

       

      When I put form around the popup and set domElementAttachment="form" that's work fine:

      {code:xml}

      <h:form>    

          ........

           <a4j:commandLink action="#{ctrlSearchPopup.load}" execute="@this" value=" #{u.name} " render="popupFormAround" oncomplete="#{rich:component('popupFormAround')}.show()">

                <a4j:param name="uid1" value="#{u.name}" assignTo="#{ctrlSearchPopup.userId}" />

           </a4j:commandLink>

         ......

      </h:form>

       

       

       

      <h:form>

                <rich:popupPanel domElementAttachment="form" id="popupFormAround"               autosized="true">

                     <f:facet name="header">                    <h:outputText value="ElementAttachment=parent" />               </f:facet>

                     <f:facet name="controls">                    <h:outputLink value="#"                         onclick="#{rich:component('popupFormAround')}.hide(); return false;">X</h:outputLink>     </f:facet>       

                          <a4j:outputPanel rendered="#{not empty ctrlSearchPopup.current}"                          layout="block">

                               <h:inputText value="#{ctrlSearchPopup.current.name}" />

                               <h:inputText value="#{ctrlSearchPopup.current.txt}" />

                               <a4j:commandButton value="save" action="#{ctrlSearchPopup.save}" />

       

                          </a4j:outputPanel>             

              </rich:popupPanel>

      </h:form>

      {code:xml}

       

       

      Problem

      ------------

      My problem is that I want to put many forms in the popup to edit more object (with tabpane in client mode).

      Actually I don't understand if i do something wrong or other. I've tested with domElementAttachment=parent/form of without domElementAttachment and it s don't work.

      In the example below when the popup is edited I need to click twice to call the save method!

       

      {code:xml}

       

      <h:form>    

          ........

           <a4j:commandLink action="#{ctrlSearchPopup.load}" execute="@this" value=" #{u.name} " render="popupFormInside" oncomplete="#{rich:component('popupFormInside')}.show()">

                <a4j:param name="uid1" value="#{u.name}" assignTo="#{ctrlSearchPopup.userId}" />

           </a4j:commandLink>

         ......

      </h:form>

       

       

       

           <rich:popupPanel  id="popupFormInside"               autosized="true">

                     <f:facet name="header">                    <h:outputText value="ElementAttachment=parent" />               </f:facet>

                     <f:facet name="controls">                    <h:outputLink value="#"                         onclick="#{rich:component('popupFormInside')}.hide(); return false;">X</h:outputLink>     </f:facet>       

                          <a4j:outputPanel rendered="#{not empty ctrlSearchPopup.current}"                          layout="block">

                          <h:form>

                               <h:inputText value="#{ctrlSearchPopup.current.name}" />

                               <h:inputText value="#{ctrlSearchPopup.current.txt}" />

                               <a4j:commandButton value="save" action="#{ctrlSearchPopup.save}" />

                          </h:form>

                          </a4j:outputPanel>             

                </rich:popupPanel>

      {code:xml}

       

       

       

       

      If someone can tell me if I do something wrong or if it 's not possible to put the form inside a popup?

      In attachment I've put an example of the problem.

       

      Thanks for your help.

        • 1. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)
          richard.waehner

          I think instead of putting multiple forms in your popup you should consider using the execute attribut to only send parts of your form to the server. Also regions are a possibility to realise this.

          This blog post might help you to understand the difference: http://mkblog.exadel.com/2009/07/richfaces-region-partial-jsf-tree-processing/

          1 of 1 people found this helpful
          • 2. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)
            jadtn

            Region is good idea, I'm going to do this

            Thanks

            • 3. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)
              hantsy

              I have spent much time to make the popupPanel work in Richfaces 4.

               

              And I encountered another problem, there is a strange validation behavior in the popupPanel...

               

              http://community.jboss.org/thread/171874?tstart=0

              • 4. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)
                jadtn

                I've just upgraded jboss 5.1 to mojarra 2.1.3 (i was in 2.1.2)  and some problems i have with validation in popup seems disapear:

                in 2.1.2 , when i open popup i have always an error from a required input and the  input was fill in the popup! Now the message is disapear

                 

                May be it could help you

                • 5. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)

                  I have mojarra 2.1.3 (FCS b02) in Glassfish 3.1.1. No, this problem is not solved. Click-twice is required for a4j:commandButton or Link to fire action.

                   

                  I have a base xhtml, which uses <ui:include> to include a lot of popup xhtmls to edit different data objects. Each has its own form and submits its own data only. When I click "save", it fires action and closes popup in "oncomplete....." It worked well in RF3.3.3.

                   

                  This is blocking me from migrating my project to RF4.2.2.

                  • 6. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)
                    kwutzke

                    I have this problem, too. According to Ilya a popup that has a form has always been a requirement:

                     

                    See here: https://community.jboss.org/message/624845#624845

                     

                    {quote}Popup panel always had requirement either 1) to be  placed outside forms and have one inside or 2) to have domElementAttachment attribute to set properly.{quote}

                     

                    The link to the showcase however only details the "popup in form" variant (2), but not the one I'd expect to be the primary one "form in popup" (1): http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataTable&sample=dataTableEdit&skin=blueSky

                     

                    How do you solve case 1? Has anybody reported why popups constructed like this need two clicks to achieve something?

                     

                    Here's my code:

                     

                    {code:xml}<rich:popupPanel modal="true"

                                     onmaskclick="#{rich:component('authority-update-popup')}.hide(); return false;"

                                     id="authority-update-popup">

                      <f:facet name="header">

                        <h:outputText value="Edit Authority" />

                      </f:facet>

                      <f:facet name="controls">

                        <h:outputLink value="#" onclick="#{rich:component('authority-update-popup')}.hide(); return false;">

                          <h:outputText value="X" />

                        </h:outputLink>

                      </f:facet>

                      <h:form id="authority-update-form">

                        <h:panelGrid columns="1" styleClass="full-width" id="authority-update-grid">

                          <h:panelGroup>

                            <fieldset>

                              <legend>

                                <h:selectBooleanCheckbox value="#{ouManager.withSelectedAuthorityPostAddress}" id="authority-update-postaddress-checkbox">

                                  <f:ajax render="authority-update-postaddress-grid" />

                                </h:selectBooleanCheckbox>

                                <h:outputLabel value="Post Address" for="authority-update-postaddress-checkbox" style="vertical-align: 2px;"/>

                              </legend>

                              <ui:include src="/subviews/admin-postaddress-grid.xhtml">

                                <ui:param name="postAddressPanelId" value="authority-update-postaddress-grid" />

                                <ui:param name="postAddressDisabled" value="#{not ouManager.withSelectedAuthorityPostAddress}" />

                                <ui:param name="postAddress" value="#{ouManager.selectedAuthorityPostAddress}" />

                                <ui:param name="country" value="#{ouManager.selectedAuthorityPostAddress.country}" />

                                <ui:param name="postAddressStreetNameInputId" value="authority-update-postaddress-street-name-input" />

                                <ui:param name="postAddressStreetNumberInputId" value="authority-update-postaddress-street-number-input" />

                                <ui:param name="postAddressZipCodeInputId" value="authority-update-postaddress-zip-code-input" />

                                <ui:param name="postAddressCityNameInputId" value="authority-update-postaddress-city-name-input" />

                                <ui:param name="postAddressCountrySelectId" value="authority-update-postaddress-country-select" />

                              </ui:include>

                            </fieldset>

                          </h:panelGroup>

                        </h:panelGrid>

                        <h:panelGrid columns="2" style="margin: 0 auto;">

                          <a4j:commandButton value="Accept"

                                             action="#{ouManager.updateAuthority}"

                                             execute="@form"

                                             render=":authority-list@body @form"

                                             oncomplete="if ( #{facesContext.maximumSeverity == 'WARN 1'} ) {#{rich:component('authority-update-popup')}.hide(); return true;}"

                                             id="authority-update-button">

                          </a4j:commandButton>

                          <h:commandButton value="Cancel"

                                           onclick="#{rich:component('authority-update-popup')}.hide(); return false;"

                                           immediate="true" />

                        </h:panelGrid>

                        '#{facesContext.maximumSeverity}'

                        <h:messages />

                      </h:form>

                    </rich:popupPanel>{code}

                     

                    (Sorry, but RichFaces is so full of basic issues, how do we sell these things to our customers?)

                     

                    Karsten

                    • 7. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)
                      crimson

                      Hi,

                       

                      don't know whether this would be a working solution for you (which works for many h:form inside a rich:popupPanel), but maybe I found a working solution, which I noted in the corresponding richfaces JIRA item:

                      https://issues.jboss.org/browse/RF-11355?focusedCommentId=12745530&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12745530

                      • 8. Re: [RF 4.1.M1] rich:popupPanel with form inside problem (twice click)
                        davidbatteux

                        Hi,

                         

                        I think it's a bit too late, but for the case 1, it's a Mojarra issue. See this http://stackoverflow.com/questions/11408130/jsf-commandbutton-works-on-second-click and this http://stackoverflow.com/questions/7807334/rendering-other-form-by-ajax-causes-its-view-state-to-be-lost-how-do-i-add-this.

                         

                        You render your popupPanel before you make a .show() so you render a form. When the form is outside, there is no problem because you don't render a form, so no problem with viewState.

                         

                        Cheers,