0

我正在尝试使用 ui:include 在 RichFaces 4 popupPanel 和 faces-config.xml 中的导航规则构建一个向导,但是在完成后备 bean 中的操作时,页面不会导航到目标页面。我已经检查以确保 bean 按预期执行并且它提供了预期的结果。

下面列出了 JSF 页面和包含的页面:

<rich:popupPanel modal="true" id="addSvcAcctPanel" autosized="true">

        <rich:messages id="addSvcAcctPanelMessages" globalOnly="false"
            styleClass="message" />

        <a:outputPanel id="includeAddSvcAcct">          
            <ui:include src="/layout/addSvcAccPg2.xhtml" />
        </a:outputPanel>                    

        <h:form id="closeSvcAcctForm">
            <div class="buttons">
                <a:commandButton styleClass="save" id="closeAddSvcBtn"
                    value="close"
                    onclick="#{rich:component('addSvcAcctPanel')}.hide()"
                    render="hasAgentsAccItm,svcAccAccordItm,svcAcctsTab,svcAccInfo,agentPanel,ServiceAccts,noticesAccordion">
                    <rich:tooltip direction="topRight" mode="client" showDelay="300"
                        styleClass="tooltip" layout="block">

                        <span style="white-space: wrap">Click on the 'Close'
                            button to close this panel and return to the main screen. If you
                            have any unsaved information on this page, it will be lost when
                            you click close.</span>

                    </rich:tooltip>
                </a:commandButton>
            </div>              
        </h:form>
    </rich:popupPanel>

插入的两个面板的 JSF 代码如下:

第 1 页……

<?xml version="1.0" encoding="UTF-8" ?>
<h:form xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:richext="http://java.sun.com/jsf/composite/richext"
    xmlns:a="http://richfaces.org/a4j">

    <rich:panel id="addSvcAcctPanelContent" headerClass="head2" style="height:100%;">
        <f:facet name="header">
            <h:outputText styleClass="med_black_type_bold_facet"
                value="Add a Service Account" />
        </f:facet>



        <h:panelGrid columns="3">
            <h:outputText styleClass="med_black_type_bold"
                value="Department" id="companyLabel" />

            <rich:select styleClass="med_black_type" id="companySelect"
                required="true" value="#{main.selected_company}" render="acctWarning, accountLabel1" valueChangeListener="#{main.determineProperAccountName}">
                <f:selectItem
                    itemLabel="Please select an Organisation"
                    itemValue="" />
                <f:selectItems value="#{country_companies}" />
                <a:ajax event="selectitem" render="acctWarning, accountLabel1, acctNumberExplain, acctIdHeader, acctIDHelp" execute="@this"/>               
            </rich:select>

            <rich:message for="companySelect" style=" width : 330px;" />

            <h:outputText styleClass="med_black_type_bold"
                value="Account 'Nickname'" id="nicknameLabel" />


            <h:inputText styleClass="med_black_type" id="nickname"
                value="#{main.alias}" onfocus="#{rich:component('nickNameHelpPanel')}.show()"
                onblur="#{rich:component('nickNameHelpPanel')}.hide()">
                <rich:validator />  

                <!-- <f:ajax event="focus" execute="@this" onevent="#{rich:component('nickNameHelpPanel')}.show()"/>        
                <f:ajax event="blur" execute="@this" onevent="#{rich:component('nickNameHelpPanel')}.hide()"/> --> 
            </h:inputText>
            <rich:message for="nickname" style=" width : 330px;" />

            <richext:spacer width="30" />
            <h:outputText id="acctWarning" styleClass="med_blue_type_bold"
                value="Enter the #{main.accountProperName} below - numbers and letters only! No dots or dashes." />
            <richext:spacer width="30" />

            <h:outputText styleClass="med_black_type_bold"
                value="#{main.accountProperName}" id="accountLabel1" />

            <h:inputText styleClass="med_black_type" id="account"
                value="#{main.account_id}" onfocus="#{rich:component('acctIDHelpPanel')}.show()"
                onblur="#{rich:component('acctIDHelpPanel')}.hide()">
                <rich:validator />

                <!-- <f:ajax event="focus" execute="@this" onevent="#{rich:component('acctIDHelpPanel')}.show()"/>      
                <f:ajax event="blur" execute="@this" onevent="#{rich:component('acctIDHelpPanel')}.hide()"/> --> 
            </h:inputText>
            <rich:message for="account" style=" width : 330px;" />
        </h:panelGrid>

        <div class="buttons">

            <a:commandButton styleClass="save" id="addServiceCompany"
                value="save" action="#{main.addAccount}" render="includeAddSvcAcct, includeAddSvcAcct1"/>
        </div>
    </rich:panel>



</h:form>

第 2 页……

<?xml version="1.0" encoding="UTF-8" ?>
<h:form xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:richext="http://java.sun.com/jsf/composite/richext"
    xmlns:a="http://richfaces.org/a4j">

<rich:panel>
    <h:outputText value="The service account has been successfully added." styleClass="med_black_type"/>
</rich:panel>   

faces-config 的相关摘录如下:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.1" 
 xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xi="http://www.w3.org/2001/XInclude"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd">

 <navigation-rule>
  <from-view-id>/layout/addSvcAccPg2.seam</from-view-id>
  <navigation-case>
   <from-action>#{main.outcome}</from-action>
   <from-outcome>success</from-outcome>
   <to-view-id>/layout/addSvcAccPg3.seam</to-view-id>
  </navigation-case>
 </navigation-rule>

 <application>
  <locale-config>
   <default-locale>en</default-locale>
   <supported-locale>bg</supported-locale>
   <supported-locale>de</supported-locale>
   <supported-locale>en</supported-locale>
   <supported-locale>fr</supported-locale>
   <supported-locale>tr</supported-locale>
  </locale-config>
 </application>
</faces-config>

来自 backing bean 的方法如下:

public String addAccount() {
        String retVal = "failed";
        try {

            getSAFctx.addService(getIntUserId(), 1, selected_company,
                    account_id, alias);         
            retVal = "success";
        } catch (Exception e) {

           System.out.println(e.getMessage());                  

        } finally {                     

            return retVal;
        }
}

我曾尝试使用 pages.xml、*.pages.xml 和 rich:togglePanel(由于某种原因,它不允许 commandButtons 参与支持 bean)。有没有人有任何可以提供帮助的建议?有谁知道如何使这个向导工作?

提前致谢。

戴夫。

4

1 回答 1

0

从上面的代码可以清楚地看出,一旦页面 /layout/addSvcAccPg2.seam 包含在 rich:popupPanel 中,那么它将导致单个页面中两个不同组件的 ID 相同的情况。

您已将 ID="addSvcAcctPanel" 用于rich:popupPanel 和rich:panel。这是 Richfaces 的常见问题,并会产生页面导航问题。

只是让它们不同,然后再试一次。

于 2013-04-03T03:39:46.493 回答