3 Replies Latest reply on Jun 19, 2012 9:45 AM by grubi

    is it supposed to be like this? (rich:popupPanel + aj4:outputPanel)

    zeppelinux

      Hi All,

       

      I have a problem using rich:popupPanel with a4j:outputPanel, the @ViewScoped (or @ConversationScoped) bean  is instantiated several times.

      Here is the bean:

       

      @Named

      @ViewScoped

      public class TestBean implements Serializable {

       

       

          private String labelToUpdate;

       

       

          public void sampleOperation(){

              labelToUpdate = "TestBean instance: " + this;

          }

       

       

          public void updateLabel(){

              labelToUpdate = "TestBean instance: " + this;

          }

       

       

          public String getLabelToUpdate() {

              return labelToUpdate;

          }

       

       

          public void setLabelToUpdate(String labelToUpdate) {

              this.labelToUpdate = labelToUpdate;

          }

      }

       

       

      page.xhtml

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE html

              PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:a4j="http://richfaces.org/a4j"

            xmlns:rich="http://richfaces.org/rich"

            xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"

            xml:lang="en" lang="en">

      <h:head>

       

       

      </h:head>

      <h:body>

       

       

      <h:form>

          <a4j:commandLink action="#{testBean.sampleOperation}" value="Show PopUp"

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

                           render="popupPanel"/>

      </h:form>

       

       

      <ui:include src="popup.xhtml"/>

       

       

      </h:body>

      </html>

       

      popup.xhtml

       

      <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich"

                      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"

                      xmlns:a4j="http://richfaces.org/a4j">

       

       

          <a4j:outputPanel id="popupPanel">

              <rich:popupPanel id="popup" modal="true" resizeable="false" width="500"

                               height="300"

                               onmaskclick="#{rich:component('popup')}.hide()">

       

       

                  <f:facet name="controls">

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

                  </f:facet>

       

       

                  <h:form>

                      <a4j:commandButton action="#{testBean.updateLabel}" render="panelToUpdate"/>

                  </h:form>

       

       

                  <a4j:outputPanel id="panelToUpdate">

                      <h:outputText  value="#{testBean.labelToUpdate}" rendered="#{testBean.labelToUpdate != null}"/>

                  </a4j:outputPanel>

       

       

              </rich:popupPanel>

          </a4j:outputPanel>

      </ui:composition>

       

      When page.xhtml is loaded, click on 'Show PopUp' link, popup will appear with panelToUpdate having some text, for example

       

           TestBean instance: TestBean@9ff296

       

      now click 'Submit' button, text will disappear... click 'Submit' again, label with different instance id will appear:

       

           TestBean instance: TestBean@13d13e3

       

       

      The current behaviour is strange, and doesn't make any sence to me.

       

       

      There is small maven project in attachment that has all the sources.

       

      Similar problem was reported 9 months ago:

       

           https://community.jboss.org/thread/167161

       

      bug was created and closed:

       

      https://issues.jboss.org/browse/RF-11389

       

      but I'm still struggling with this in RF 4.2.2.Final, rich:popupPanel is unusable pretty much.

       

      Is there anything wrong with the way it is used?

        • 1. Re: is it supposed to be like this? (rich:popupPanel + aj4:outputPanel)
          zeppelinux

          very similar symptoms also here : https://issues.jboss.org/browse/RF-11355

          • 2. Re: is it supposed to be like this? (rich:popupPanel + aj4:outputPanel)
            zeppelinux

            changing poppup.xhtml like this (put h:form outside of the popupPanel) makes it work as expected:

             

            <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich"

                            xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"

                            xmlns:a4j="http://richfaces.org/a4j">

             

             

                <h:form>

                <a4j:outputPanel id="popupPanel">

             

             

                    <rich:popupPanel id="popup" modal="true" resizeable="false" width="500"

                                     height="300"

                                     onmaskclick="#{rich:component('popup')}.hide()">

             

             

                        <f:facet name="controls">

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

                        </f:facet>

             

                            <a4j:commandButton action="#{testBean.updateLabel}" render="panelToUpdate"/>

             

                        <a4j:outputPanel id="panelToUpdate">

                            <h:outputText  value="#{testBean.labelToUpdate}" rendered="#{testBean.labelToUpdate != null}"/>

                        </a4j:outputPanel>

             

             

                    </rich:popupPanel>

             

             

                </a4j:outputPanel>

                </h:form>

            </ui:composition>

             

            but still it would be nice to have the option to use more that one form with/in popup

            • 3. Re: is it supposed to be like this? (rich:popupPanel + aj4:outputPanel)
              grubi

              Similar problem here, but without any outputPanel. I simply use a h:form combined with a4j:commandLink and a ViewScoped bean.

               

              First Problem

              Multiple forms with their own a4j:commandLink do not work. The first command is working and re-rendering as expected. It could be clicked several time without any problem. The following commands do nothing (really nothing, not even the actionListener will be called).

               

              First Fix

              After putting all elements in a single form, everything works as expected. But thats a limitation I'm not really happy with.

               

              Second Problem

              After that I only put the commands and the input-fields, that affect the beans state, in a single form. All other forms were removed.

              The commands without a form work still as expected (commandLinks without an form?...). But the submit button is messing up the ViewScoped bean. It simply creates a new one and so nothing is working anymore because the state of the frontend does not match the state of the bean (variable values, etc)...

              The same happens if i change the submit command from ajax to normal h:comandLink. The ViewScoped bean will be recreated...

               

              For testing purposes I changed from ViewScoped to SessionScoped (both ajax and non-ajax). The first click still does not work, but all following clicks do what they should do as long as I don't change the selection which will reload another form.

               

              I don't know, if this is a pure RF failure or it's JSF2 (JBoss 7.1.1) too...