0

現在、faces-config.xmlファイルでナビゲーションルールを指定しています。faces-config.xmlへのエントリの作成を停止したい場合。

ナビゲーションルールをfaces-config.xmlで指定したくない場合、どうすれば指定できますか?

「faces-config.xml」

<?xml version="1.0"?>
<faces-config version="1.2" 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_1_2.xsd">
    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/login.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/wsListing.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/wsListing.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>ebzService</from-outcome>
            <to-view-id>/ebzinput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
        <navigation-case>
            <from-outcome>filterEbz</from-outcome>
            <to-view-id>/filterebzinput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>


    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/ebzinput.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/ebzoutput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
        </navigation-rule>

</faces-config>
4

2 に答える 2

3

暗黙のナビゲーションは、JSF2.0以降でのみサポートされます。XMLファイルのルート宣言と質問履歴によると、JSF 1.2を使用しているので、これで話は終わりです。

ただし、現在のナビゲーションケースに基づくと、毎回リダイレクトしているようです。そのためには、代わりに使用することもできますExternalContext#redirect()

public void login() throws IOException {
    // ...

    FacesContext.getCurrentInstance().getExternalContext().redirect("wsListing.xhtml");
}

または、実際にビジネスアクションを実行する必要がまったくない場合は、通常のリンクを使用します。

<h:outputLink value="ebzinput.xhtml">go to ebzinput</h:outputLink>

追加の利点は、検索ボットのインデックス作成が可能になることです(したがって、SEOが向上します)。

于 2012-05-11T11:22:40.693 に答える
0

「成功」の代わりに、アクションメソッドはビューIDを返す場合があります。

public String login() { return "wsListing"; }

このようにして、ナビゲーションルールをマネージドBeanにシフトできます。リダイレクトの使用を強制したい場合

public String login() { return "wsListing?faces-redirect=true"; }
于 2012-05-11T08:07:42.003 に答える