6 Replies Latest reply on Jan 10, 2008 6:58 AM by shooali

    ReRender of a4j:include

    shooali

      Hello,

      I have a modal panel in my page that contains an a4j:include and its viewid att pointing to a bean property returning the first page to show in the wizard.

      All works fine except that when closing the modal panel and opening it again, the reRender in the a4j:command button opening the modal panel does not work (the above bean property method is not called) thus the modal panel opens to the last page it was before it closed last time.
      searched the forum and saw that there is a need to wrap the a4j:include with outputPanel. did that and pointed the reRender to the outputpanel id. did not change a thing. also so another way to facelatly include an xhtml containing the modal panel and reRender the outputpanel there. nothing again.

      I am using rich 3.1.2 myfaces 1.2 on tomcat.



      please help.

      thanks,

      
      
      <script language="javascript">
      
       function openRuleWizardMP()
       {
       Richfaces.showModalPanel('RuleWizardMP');
       }
      </script>
      
      
      
      <rich:modalPanel id="RuleWizardMP" width="1000" height="600">
       <f:facet name="header">
       <h:outputText value="#{messages['RULE.WIZARD.LABEL.ADD_RULE']}"/>
       </f:facet>
       <a4j:outputPanel id="addRuleWizardPanel">
       <a4j:include id="addRuleWizardInclude" viewId="#{manageRulesStageBean.startStage}" />
       </a4j:outputPanel>
      </rich:modalPanel>
      
      
      <a4j:commandButton value="Create"
       styleClass="submit_btn"
       reRender="addRuleWizardPanel"
       action="#{manageRulesStageBean.setStartStage}"
       oncomplete="openRuleWizardMP()"/>
      


        • 1. Re: ReRender of a4j:include
          shooali

          help any one?

          • 2. Re: ReRender of a4j:include
            shooali

            I have noticed that if I open the modalpanel and does not navigate to the next stage, close the modal panel and open it again, the getter for startStage viewid used in the a4j:include is called. However, if I open the modal panel, click next to navigate to the next stage, close the modal panel and click to open it again, the getter in the viewId property of the a4j:include is called at all and the modal panel opens to the last stage it was on when closed.

            • 3. Re: ReRender of a4j:include
              shooali

              I have prepared a full example, outside of our main app.
              If I click the "openFirst" button, the MP open to the first stage, then click the "second" button - it navigates to the second stage, close the MP. click "openFirst" again and it opens to the second stage.

              please tell me what am I doing wrong.

              thanks,

              main page:
              
              <!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: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:c="http://java.sun.com/jstl/core"
               xmlns:rich="http://richfaces.ajax4jsf.org/rich">
              
              <ui:composition>
              <a4j:log hotkey="G"></a4j:log>
              <rich:modalPanel id="trmp" width="600" height="600">
               <f:facet name="header"><h:outputText value="Modal Panel"/></f:facet>
               <f:facet name="controls">
               <a href="#" onclick="Richfaces.hideModalPanel('trmp')">X</a>
               </f:facet>
               <h:panelGroup id="wizardPanel">
               <a4j:include id="wizard" viewId="#{richTestBean.startStage}"/>
               </h:panelGroup>
              </rich:modalPanel>
               <h:form>
               <a4j:commandButton
               actionListener="#{richTestBean.defineFirstStartStage}"
               reRender="wizardPanel"
               oncomplete="Richfaces.showModalPanel('trmp')"
               value="openFirst"/>
               <a4j:commandButton
               actionListener="#{richTestBean.defineSecondStartStage}"
               reRender="wizardPanel"
               oncomplete="Richfaces.showModalPanel('trmp')"
               value="openSecond"/>
               </h:form>
              </ui:composition>
              </html>
              
              First wizard stage:
              <!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:h="http://java.sun.com/jsf/html"
               xmlns:ui="http://java.sun.com/jsf/facelets">
              
               <ui:composition template="/stage_template.xhtml">
               <ui:define name="body">
               <h:outputText value="first"/>
               </ui:define>
               </ui:composition>
              </html>
              
              second wizard stage:
              <!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:h="http://java.sun.com/jsf/html"
               xmlns:ui="http://java.sun.com/jsf/facelets">
              
               <ui:composition template="/stage_template.xhtml">
               <ui:define name="body">
               <h:outputText value="second"></h:outputText>
               </ui:define>
               </ui:composition>
              </html>
              
              wizard stage template:
              <html xmlns="http://www.w3.org/1999/xhtml"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
              
               <ui:composition>
              
               <h:form>
              
               <table>
               <tr>
               <td>
               <ui:insert name="body"/>
               </td>
               </tr>
               <tr>
               <td>
               <a4j:commandButton
               action="first"
               value="first"
               reRender="wizardPanel"/>
               <a4j:commandButton
               action="second"
               value="second"
               reRender="wizardPanel"/>
               </td>
               </tr>
               </table>
               </h:form>
               </ui:composition>
              </html>
              
              page bean:
              import javax.faces.event.ActionEvent;
              
              
              public class RichTestBean {
               private String startStage = "/first.xhtml";
              
               public RichTestBean() {
               }
              
               public String getStartStage() {
               return startStage;
               }
              
               public void defineFirstStartStage(ActionEvent event) {
               this.startStage = "/first.xhtml";
               }
              
               public void defineSecondStartStage(ActionEvent event) {
               this.startStage = "/second.xhtml";
               }
              }
              
              faces-config:
              <?xml version="1.0" encoding="UTF-8"?>
              <faces-config version="1.2" .......>
               <managed-bean>
               <managed-bean-name>richTestBean</managed-bean-name>
               <managed-bean-class>RichTestBean</managed-bean-class>
               <managed-bean-scope>request</managed-bean-scope>
               </managed-bean>
               <navigation-rule>
               <from-view-id>*</from-view-id>
               <navigation-case>
               <from-outcome>second</from-outcome>
               <to-view-id>/second.xhtml</to-view-id>
               </navigation-case>
               <navigation-case>
               <from-outcome>first</from-outcome>
               <to-view-id>/first.xhtml</to-view-id>
               </navigation-case>
               </navigation-rule>
               <application>
               <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
               </application>
              </faces-config>
              
              
              


              • 4. Re: ReRender of a4j:include
                ilya_shaikovsky

                will this works as excpected if you just write viewId="/first.xhtml" just on the page?

                • 5. Re: ReRender of a4j:include
                  shooali

                  of course not. I want the wizard to open to a stage according to the button you click. If click the "openFirst" to start in the first stage and if clicked the "openSecond" to start in the second stage. If I put viewId="/first.xhtml" it will always open in the first stage.

                  • 6. Re: ReRender of a4j:include
                    shooali

                    Hi,

                    If this cannot be done, please let me know if there's a workaround.

                    thanks,