8 Replies Latest reply on Jun 6, 2007 4:33 AM by Ilya Shaikovsky

    a bug in modalPanel that <h:commandButton action won't take

    vivian hu Novice

      I have such a mocalPanel:

      <h:form id="vdWizardForm">
      <rich:modalPanel id="addDesktopMp" minHeight="280" minWidth="300"
      height="400" width="1000" zindex="2000">
      <f:facet id="modalHeader" name="header">
      <h:outputText id="modalTitle" value="#{bundle.AddDesktop}" />
      </f:facet>
      <h:panelGroup id="wizard">
      <a4j:include id="includeId" viewId="/pages/desktop/addDesktopType.xhtml"/>
      </h:panelGroup>
      </rich:modalPanel>
      </h:form>

      in the included addDesktopType.xhtml, I have such a button
      <h:commandButton value="more" action="#{desktopBean.test}"/>

      the test() method did get called, and it just return a string "cancel", the navigation doesn't happen.
      But if I hard code the string in the xhtml file, the navigation happens:

      <h:commandButton value="more" action="cancel"/>

      If I move the commandButton out of the include file, it also works.
      Any idea?

        • 1. Re: a bug in modalPanel that <h:commandButton action won't t
          Ilya Shaikovsky Master

          do you need to navigate inside the included window or close it and make navigation?

          • 2. Re: a bug in modalPanel that <h:commandButton action won't t
            vivian hu Novice

            In the last step of the wizard (in the included page), if the action succeed, I want the action method to return a string to make the page navigate to the first step, if fail, I want to return a different string to make the page stay in the current page.

            • 3. Re: a bug in modalPanel that <h:commandButton action won't t
              Ilya Shaikovsky Master

              Oh.. sorry missed from your code - your panel with
              any action components inside should have a form inside to be submitted. And it should be placed outside from external form in this case.

              • 4. Re: a bug in modalPanel that <h:commandButton action won't t
                vivian hu Novice

                It still doesn't work.

                ===================
                <rich:modalPanel id="addDesktopMp" minHeight="280" minWidth="300"
                height="400" width="1000" zindex="2000">
                <f:facet id="modalHeader" name="header">
                <h:outputText id="modalTitle" value="#{bundle.AddDesktop}" />
                </f:facet>
                <h:panelGroup id="wizard">
                <a4j:include id="includeId"
                viewId="/pages/desktop/addDesktopType.xhtml" />
                </h:panelGroup>
                </rich:modalPanel>

                =======================
                The included page

                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <h:form id="reviewForm"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
                xmlns:rich="http://richfaces.ajax4jsf.org/rich">
                <f:loadBundle basename="com.vmware.vdi.admin.ui.messages.MessageBundle" var="bundle"/>
                <a4j:keepAlive beanName="desktopBean" />



                <h:outputText value="#{bundle.ReadyToComplete}"/>




                <h:outputText value="#{bundle.ReviewInstruction}"/>




                <rich:panel>



                <h:outputText value="#{bundle.DesktopTypeColon}" />  
                <h:outputText value="#{desktopBean.type}" />




                <h:outputText value="#{bundle.DesktopIdColon}" />  
                <h:outputText value="#{desktopBean.id}" />




                <h:outputText value="#{bundle.DesktopDisplayNameColon}" />  
                <h:outputText value="#{desktopBean.displayName}" />




                <h:outputText value="#{bundle.VirtualCenterServerColon}" />  
                <h:outputText value="#{desktopBean.vcName}" />




                <h:outputText value="#{bundle.VirtualMachineSelectionColon}" />  




                <rich:dataList value="#{desktopBean.selectedVMNames}" var="vm">
                <h:outputText value="#{vm}"/>
                </rich:dataList>



                </rich:panel>





                <rich:spacer height="20px">
                </rich:spacer>





                <a4j:commandButton action="back" value="#{bundle.Back}" reRender="wizard"/>
                <rich:spacer width="5px"></rich:spacer>
                <a4j:commandButton value="#{bundle.Finish}"
                action="#{desktopBean.addDesktop}"
                oncomplete="Richfaces.hideModalPanel('addDesktopMp');"
                reRender="wizard,myTable,myTree"/>
                <rich:spacer width="5px"></rich:spacer>
                <a4j:commandButton
                action="cancel"
                actionListener="#{desktopBean.cancel}"
                value="#{bundle.Cancel}"
                oncomplete="Richfaces.hideModalPanel('addDesktopMp');"
                reRender="wizard"/>




                </h:form>

                =====================
                bean method

                public String addDesktop() {
                return "finish";
                }

                • 5. Re: a bug in modalPanel that <h:commandButton action won't t
                  vivian hu Novice

                  Can somebody help? Did anybody has done this before?

                  • 6. Re: a bug in modalPanel that <h:commandButton action won't t
                    Ilya Shaikovsky Master

                    Please repeat your snipet using code blocks to avoid loosed parts of your code. Thanks!

                    And again - anyway you need to have form element inside your modal and the modal shouldn't be inside external one form

                    • 7. Re: a bug in modalPanel that <h:commandButton action won't t
                      vivian hu Novice

                      Here is goes again:
                      The files that with the modalPenal:

                       <rich:modalPanel id="addDesktopMp" minHeight="280" minWidth="300"
                       height="400" width="1000" zindex="2000">
                       <f:facet id="modalHeader" name="header">
                       <h:outputText id="modalTitle" value="#{bundle.AddDesktop}" />
                       </f:facet>
                       <h:panelGroup id="wizard">
                       <a4j:include id="includeId"
                       viewId="/pages/desktop/addDesktopType.xhtml" />
                       </h:panelGroup>
                       </rich:modalPanel>
                      


                      the wizard step: (pay attention to the finish button)
                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                      <h:form id="reviewForm"
                       xmlns="http://www.w3.org/1999/xhtml"
                       xmlns:ui="http://java.sun.com/jsf/facelets"
                       xmlns:h="http://java.sun.com/jsf/html"
                       xmlns:f="http://java.sun.com/jsf/core"
                       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
                       xmlns:rich="http://richfaces.ajax4jsf.org/rich">
                      <f:loadBundle basename="com.vmware.vdi.admin.ui.messages.MessageBundle" var="bundle"/>
                       <a4j:keepAlive beanName="desktopBean" />
                       <table>
                       <tr>
                       <td align="left">
                       <h:outputText value="#{bundle.ReadyToComplete}"/>
                       </td>
                       </tr>
                       <tr>
                       <td align="left">
                       <h:outputText value="#{bundle.ReviewInstruction}"/>
                       </td>
                       </tr>
                       <tr>
                       <td>
                       <rich:panel>
                       <table>
                       <tr>
                       <td>
                       <h:outputText value="#{bundle.DesktopTypeColon}" />  
                       <h:outputText value="#{desktopBean.type}" />
                       </td>
                       </tr>
                       <tr>
                       <td>
                       <h:outputText value="#{bundle.DesktopIdColon}" />  
                       <h:outputText value="#{desktopBean.id}" />
                       </td>
                       </tr>
                       <tr>
                       <td>
                       <h:outputText value="#{bundle.DesktopDisplayNameColon}" />  
                       <h:outputText value="#{desktopBean.displayName}" />
                       </td>
                       </tr>
                       <tr>
                       <td>
                       <h:outputText value="#{bundle.VirtualCenterServerColon}" />  
                       <h:outputText value="#{desktopBean.vcName}" />
                       </td>
                       </tr>
                       <tr>
                       <td>
                       <h:outputText value="#{bundle.VirtualMachineSelectionColon}" />  
                       </td>
                       </tr>
                       <tr>
                       <td>
                       <rich:dataList value="#{desktopBean.selectedVMNames}" var="vm">
                       <h:outputText value="#{vm}"/>
                       </rich:dataList>
                       </td>
                       </tr>
                       </table>
                       </rich:panel>
                       </td>
                       </tr>
                      
                       <tr>
                       <td>
                       <rich:spacer height="20px">
                       </rich:spacer>
                       </td>
                       </tr>
                       <tr>
                       <td align="center">
                       <a4j:commandButton action="back" value="#{bundle.Back}" reRender="wizard"/>
                       <rich:spacer width="5px"></rich:spacer>
                       <a4j:commandButton value="#{bundle.Finish}"
                       action="#{desktopBean.addDesktop}"
                       oncomplete="Richfaces.hideModalPanel('addDesktopMp');"
                       reRender="wizard,myTable,treeTable"/>
                       <rich:spacer width="5px"></rich:spacer>
                       <a4j:commandButton
                       action="cancel"
                       actionListener="#{desktopBean.cancel}"
                       value="#{bundle.Cancel}"
                       oncomplete="Richfaces.hideModalPanel('addDesktopMp');"
                       reRender="wizard"/>
                       </td>
                       </tr>
                       </table>
                      </h:form>
                      
                      
                      


                      the bean method:
                      public String addDesktop() {
                      return "finish";
                      }

                      • 8. Re: a bug in modalPanel that <h:commandButton action won't t
                        Ilya Shaikovsky Master

                        Ok and I think the last question I missed to ask about your environment. I'll start to write the example for you now.