7 Replies Latest reply on Oct 6, 2013 7:33 AM by Frank Ruenagel

    popuppanel and validation problem

    ugo rossi Newbie

      Hi.

      I have strange problem with popuppanel and validation. I'm using richfaces 4, jsf 2.

      I have a data Table that contains some rows. Clicking on a table's cell, the user open a popup punel.

      In the popuppanel there are 3 inputext where the user must put some value "require=true". When the input fase is teminate, the user persist the data in a DB table and close the popuppanel.

      Now if the user, click on a new row the popuppanel shows the clicked data and everything it's ok.

      But if during the submit phase, there are some validation problem i have a strange problem. When i close the popoup, select a new row, click on it for open the popuppanel whit these dagta

      i find in the popup the old date, and not the new one.

      I read something about a component bug, someone can help me?

      Thank you!!

        • 1. Re: popuppanel and validation problem
          Brendan Healey Master

          Hi, without seeing the code there's a lot of guess work and this is a stab in the dark...

           

          How does the row click work that opens the popupPanel? are you using extendedDataTable with the selectionchange event

          or is there a commandLink/commandButton in the row? Either way you need to render the contents of the popupPanel. So

          you would need something like this:

           

          <rich:popupPanel ...>

            <h:panelGroup id="panelContents">

            ...

            </h:panelGroup>

          </rich:popupPanel>

           

          & render="panelContents" on row click.

           

          Regards,

          Brendan.

          • 2. Re: popuppanel and validation problem
            ugo rossi Newbie

            Hi, thaks a lot.

            There is commandLink in the row of the table.

             

            <a4j:commandLink oncomplete="#{rich:component(contrQualBB.pop)}.show();"

            render="popup" onclick="show(#{cq.id},'dup')"

            style="text-align:center;font-size:medium">

             

            <h:graphicImage value="../../resources/images/duplica.gif" alt="Duplica" style="border:0"

            />

             

            <rich:tooltip id="tt2" styleClass="tooltip" layout="block"

            >

            OPEN

             

            </rich:tooltip>

             

            </a4j:commandLink>

             

            In the command link i render the popuppanel

             

             

             

            <

            h:form id="formPanel">

             

             

            <rich:popupPanel id="popup" modal="true" autosized="true" resizeable="false" height="560" width=

            "500" domElementAttachment="form">

             

             

            Suppose that this is my table:

            (row 1)--Name1--Order1---data1

            (row 2)--Name2--Order2---data2

            (row 3)--Name3--Order3---data3

            If i visualizze (for exaple row 1), modify Order1 in Order11, save the data and close the popup (no validation error).

            Now, if i open (row 2) in the popup i see the correct information Name2--Order2---data2.

            If visualizze (for exaple row 1, again), modify Order1 in "", save the data (validation error, Order is a required value), close the popup.

            Now, if i open the (row 2) in the popup i find the old value, relative to the (row 1) Name1--Order1---data1.

            • 3. Re: popuppanel and validation problem
              Brendan Healey Master

              Ok, as you are using domElementAttachment="form" I don't think you need the h:form that encloses the popupPanel.

              If you weren't using domElementAttachment="form" you would put the form inside the popupPanel, not outside it. I

              think that's right, I've got to admit I use jQuery dialogs rather than popupPanel.

               

              You are rendering the popupPanel itself, you need to render the contents of the popupPanel as per my reply, so add

              a panelGroup and render that from the commandLink and render that instead of render="popup".

               

              - remove the enclosing h:form from the popupPanel

                - add a panelGroup inside the popupPanel

                - render the panelGroup from the commandLink render=, not the popupPanel itself

               

              I think that's right!

               

              Regards,

              Brendan.

              • 4. Re: popuppanel and validation problem
                Ivan Ravin Newbie

                You have to clear local values in panel:

                https://community.jboss.org/thread/200279?tstart=0

                https://community.jboss.org/thread/200207?tstart=0

                 

                this way you can clear all childs in panel:

                 

                 

                {code}

                public void refresh(String componentId) {

                     FacesContext context = FacesContext.getCurrentInstance();

                     UIComponent component = context.getViewRoot().findComponent(componentId);

                     if (component != null)

                          clearChilds(component);

                }

                 

                private void clearChilds(UIComponent c) {

                     if (UIInput.class.isAssignableFrom(c.getClass())) {

                          UIInput input = (UIInput)c;

                          input.setSubmittedValue(null);

                          input.setValue(null);

                          input.setLocalValueSet(false);

                     } else {

                          Iterator<UIComponent> kids = c.getFacetsAndChildren();

                          while (kids.hasNext()) {

                               clearChilds(kids.next());

                          }

                     }

                }

                 

                {code}

                • 5. Re: popuppanel and validation problem
                  ugo rossi Newbie

                  Hi Brendan, thanks a lot.

                  I try to follow your indication but i have the same problem in the same condition.

                  I try to clear all childs in panel, as suggested by Ivan, and probably is the correct solution for me.

                   

                  Regards.

                   

                  • 7. Re: popuppanel and validation problem
                    Frank Ruenagel Newbie

                    Dirty solution: the Problem is somewhat hidden, if you implement client side validation. But it is still there, and dangerous....

                     

                    What I do:

                    A workaround on client side is to prevent closing the panel,  if server sided validation errors occour:

                     

                    <rich:popupPanel id="produktPopup"  modal="true" onmaskclick="windowcloseproduktPopup();"

                                              autosized="true">

                      <h:form id="xxxx">

                    [...]

                      <a4j:outputPanel ajaxRendered="true">

                         <script type="text/javascript">

                         function windowcloseproduktPopup() {

                              if(#{not facesContext.validationFailed}) {

                                   #{rich:component('produktPopup')}.hide();

                               

                      }

                      return false;

                      }

                      </script>

                      </a4j:outputPanel>

                    </h:form>           

                              </rich:popupPanel>

                     

                    As Khosro writes in his helpful reply, this is a bug. And it is still open....