6 Replies Latest reply on Jun 18, 2010 4:44 PM by Marci Miller

    redirect from a rich:modalPanel a4j:commandButton

    Marci Miller Newbie

      I have a simple scenario (at least I think it's simple).  From a page, the user clicks on a a4j:commandLink that opens a rich:modalPanel.  When the user clicks "Accept", the modal panel should close and the screen should be redirected to a new page in the application.  But no matter what I try, the modal panel closes and does not redirect to the new page.

      Here is the a4j:commandButton:

       

      <a4j:commandButton styleClass="stdButton" status="majorstatus" onclick="disableButtons();" id="reopenButton" value="Accept" limitToList="true"
                                  action="#{ProcessBean.reopenInterview}" oncomplete="windowclose();" reRender="reopeninterview, #{IntakeMenuBean.reRender}">

       

      I tried adding the following to the faces-config:

       

      <navigation-rule>
        <from-view-id>reopeninterview.xhtml</from-view-id>
        <navigation-case>
        <from-action>#{ProcessBean.reopenInterview}</from-action>
         <from-outcome>reopen</from-outcome>
         <to-view-id>/pages/basicsinterview.xhtml</to-view-id>
         <redirect/>
        </navigation-case>
      </navigation-rule>

       

      Any ideas on how to solve this problem?

      Thanks in advance!

        • 1. Re: redirect from a rich:modalPanel a4j:commandButton
          Ilya Shaikovsky Master

          show complete page sources. and information from server console when clicking at action button.

          • 2. Re: redirect from a rich:modalPanel a4j:commandButton
            Marci Miller Newbie

            The idea is to click on the commandLink which opens a modal panel.  Then the user can click on the "Reopen" button on the modal panel and be redirected to the interview.

             

            Here is the facelet - dccchecklist.xhtml (I have simplified it to better explain the problem):

            <ui:composition 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="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich"
                  xmlns:custom="http://doc/jsf/custom"
                  template="pagetemplate.xhtml">
                <ui:define name="content">
                    <h:form id="dccchecklistform">
                        <rich:panel id="dccchecklistprocpanel" style="width: 100%; height: 500px;">
                                <rich:dataTable headerClass="dr-table-header" width="96%" id="taskList" value="#{IntakeOffenderBean.DCCTasks}" var="dccChkTaskBean">
                                    <rich:column id="taskName" width="170px">
                                           <f:facet name="header"><h:outputText value="Task Description" styleClass="stdLabelLight"/></f:facet>
                                           <a4j:commandLink limitToList="true" oncomplete="javascript:Richfaces.showModalPanel('genericmp',{width:500, height: 260, top:200});" styleClass="linkText" value="#{dccChkTaskBean.task.task.description}"/>
                                       </rich:column>
                                </rich:dataTable>
                        </rich:panel>
                    </h:form>
                    <rich:modalPanel id="genericmp" minHeight="240" minWidth="450" zindex="2000">
                    <a4j:log popup="false"/>
                        <f:facet name="header">
                            <a4j:outputPanel id="mpheader">
                                <h:outputText value="Reopen Interview"/>
                            </a4j:outputPanel>
                        </f:facet>
                        <table width="100%" align="center">
                            <tr>
                                <td colspan="2" align="center">
                                    <h:outputText value="Inteview is already completed. Press Reopen if you to want to reopen the interview and make further changes or press Cancel to leave the interview closed." styleClass="stdLabel"/>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    <a4j:commandButton styleClass="stdButton" status="majorstatus" id="reopenButton" value="Reopen" limitToList="true"
                                        action="reopen"/>
                                </td>
                            </tr>
                        </table>
                    </rich:modalPanel>
                </ui:define>
            </ui:composition>

             

            Here is the output form a4j:log (after you click the "Reopen" button):

             

            debug[16:21:09,718]: Have Event  [object Object] with properties: target: undefined, srcElement: [object], type:  click
            debug[16:21:09,718]: Query preparation  for form 'null' requested
            Again, here is the faces-config info:
            <navigation-rule>
              <from-view-id>dccchecklist.xhtml</from-view-id>
              <navigation-case>
               <from-outcome>reopen</from-outcome>
               <to-view-id>/pages/dccbasicsinterview.xhtml</to-view-id>
               <redirect/>
              </navigation-case>
            </navigation-rule>
            richfaces 3.3.1
            Any ideas on what the problem might be?  Thanks for taking a look.
            • 3. Re: redirect from a rich:modalPanel a4j:commandButton
              Ilya Shaikovsky Master

              from log:

               

              debug[16:21:09,718]: Query preparation  for form 'null' requested

              and from your page code I see that you forgot to wrap command control with form.

              • 4. Re: redirect from a rich:modalPanel a4j:commandButton
                Marci Miller Newbie

                Thanks for your response.  After adding the form, I am getting more information in the log but the action is still not redirecting to the new page.  Here is the new log information:

                debug[8:41:22,203]: Have Event [object  Object] with properties: target: undefined, srcElement: [object], type:  click
                debug[8:41:22,218]: Query preparation  for form 'reopenform' requested
                debug[8:41:22,218]: Append hidden  control reopenform with value [reopenform] and value attribute  [reopenform]
                debug[8:41:22,234]: Append hidden  control reopenform:genericmpOpenedState with value [] and value attribute  []
                debug[8:41:22,234]: Append hidden  control javax.faces.ViewState with value [j_id2] and value attribute  [j_id2]
                debug[8:41:22,234]: parameter  reopenform:reopenButton with value reopenform:reopenButton
                debug[8:41:22,250]: Look up queue with  default name
                debug[8:41:22,250]: NEW AJAX REQUEST  !!! with form: reopenform
                debug[8:41:22,265]: Start  XmlHttpRequest
                debug[8:41:22,265]: Reqest state :  1
                debug[8:41:22,265]: QueryString:  AJAXREQUEST=_viewRoot&reopenform=reopenform&reopenform%3AgenericmpOpenedState=&javax.faces.ViewState=j_id2&reopenform%3AreopenButton=reopenform%3AreopenButton&
                debug[8:41:22,328]: Reqest state :  2
                debug[8:41:22,328]: Reqest state :  3
                debug[8:41:22,328]: Reqest state :  4
                debug[8:41:22,343]: Reqest end with  state 4
                debug[8:41:22,343]: Response  with  content-type: text/xml;charset=UTF-8
                debug[8:41:22,343]: Full response  content: <?xml version="1.0"?><html  xmlns="http://www.w3.org/1999/xhtml"><head><meta  name="Ajax-Update-Ids" content=""  /><title></title></head><body><span  id="ajax-view-state"><input type="hidden" name="javax.faces.ViewState"  id="javax.faces.ViewState" value="j_id2" /></span><meta  id="Ajax-Response" name="Ajax-Response" content="true"  /></body></html>
                debug[8:41:22,359]: Header  Ajax-Expired not found, search in <meta>
                debug[8:41:22,359]: search for  elements by name 'meta'  in element #document
                debug[8:41:22,359]: Find <meta  name='Ajax-Update-Ids' content=''>
                debug[8:41:22,375]: Find <meta  name='Ajax-Response' content='true'>
                debug[8:41:22,375]: Header  Ajax-Update-Ids not found, search in <meta>
                debug[8:41:22,375]: search for  elements by name 'meta'  in element #document
                debug[8:41:22,390]: Find <meta  name='Ajax-Update-Ids' content=''>
                warn[8:41:22,390]: No information in  response about elements to replace
                debug[8:41:22,390]: call  selectSingleNode for id= org.ajax4jsf.oncomplete
                debug[8:41:22,390]: Processing updates  finished, no oncomplete function to call
                debug[8:41:22,406]: call  selectSingleNode for id= ajax-view-state
                debug[8:41:22,406]: Hidden JSF state  fields:
                debug[8:41:22,406]: Namespace for  hidden view-state input fields is undefined
                debug[8:41:22,406]: search for  elements by name 'input'  in element span
                debug[8:41:22,421]: Replace value for  inputs: 10 by new values: 1
                debug[8:41:22,421]: Input in response:  javax.faces.ViewState
                debug[8:41:22,421]: Found same input  on page with type: hidden
                debug[8:41:22,437]: Found same input  on page with type: hidden
                debug[8:41:22,437]: Found same input  on page with type: hidden
                debug[8:41:22,437]: search for  elements by name 'INPUT'  in element span
                debug[8:41:22,453]: Replace value for  inputs: 10 by new values: 0
                debug[8:41:22,453]: call  selectSingleNode for id= _A4J.AJAX.focus
                debug[8:41:22,453]: No focus  information in response
                And here is the updated facelet:
                <ui:composition 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="http://richfaces.org/a4j"
                      xmlns:rich="http://richfaces.org/rich"
                      xmlns:custom="http://doc/jsf/custom"
                      template="pagetemplate.xhtml">
                    <ui:define name="content">
                        <h:form id="dccchecklistform">
                            <rich:panel id="dccchecklistprocpanel" style="width: 100%; height: 500px;">
                                    <rich:dataTable headerClass="dr-table-header" width="96%" id="taskList" value="#{IntakeOffenderBean.DCCTasks}" var="dccChkTaskBean">
                                        <rich:column id="taskName" width="170px">
                                               <f:facet name="header"><h:outputText value="Task Description" styleClass="stdLabelLight"/></f:facet>
                                               <a4j:commandLink limitToList="true" oncomplete="javascript:Richfaces.showModalPanel('genericmp',{width:500, height: 260, top:200});" styleClass="linkText" value="#{dccChkTaskBean.task.task.description}"/>
                                           </rich:column>
                                    </rich:dataTable>
                            </rich:panel>
                        </h:form>
                        <h:form id="reopenform">
                        <rich:modalPanel id="genericmp" minHeight="240" minWidth="450" zindex="2000">
                        <a4j:log/>
                            <f:facet name="header">
                                <a4j:outputPanel id="mpheader">
                                    <h:outputText value="Reopen Interview"/>
                                </a4j:outputPanel>
                            </f:facet>
                            <table width="100%" align="center">
                                <tr>
                                    <td colspan="2" align="center">
                                        <h:outputText value="Interview Task has been marked completed for #{IntakeOffenderBean.offender.offenderName} (#{IntakeOffenderBean.offender.offenderId}) by #{IntakeConfirmTaskBean.selectedTask.task.confirmStaff}" styleClass="stdLabel"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" align="center">
                                        <h:outputText value="Inteview is already completed. Press Reopen if you to want to reopen the interview and make further changes or press Cancel to leave the interview closed." styleClass="stdLabel"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="2">
                                        <a4j:commandButton styleClass="stdButton" status="majorstatus" id="reopenButton" value="Reopen" limitToList="true"
                                            action="reopen"/>
                                    </td>
                                </tr>
                            </table>
                        </rich:modalPanel>
                        </h:form>
                    </ui:define>
                </ui:composition>
                Thanks again!
                • 5. Re: redirect from a rich:modalPanel a4j:commandButton
                  Ilya Shaikovsky Master

                  seems we missing something obvious.. please attach sample war (or zipped project) to thread. I will review and correct it.

                  • 6. Re: redirect from a rich:modalPanel a4j:commandButton
                    Marci Miller Newbie

                    You are absolutely correct, it was something obvious.  A mistyped the name of the facelet in to-view-id.  But I am so happy to now have a working example of how to redirect to a new page from a modal panel.  Thanks for all your help!