Can I use wildcard character * in JSF navigation rule?

时间:2016-02-12 21:38:50

标签: jsf navigation wildcard

Is there any way in JSF page navigation to create a joker rule? I have a logout link in my template header (almost for all pages). And I want to give just one rule which navigate all the pages inside the secure folder to the index page in the root.

<ListView
    android:id="@+id/listv"
    android:layout_marginTop="100dp"
    android:layout_width="wrap_content"
    android:layout_height="200dp">

</ListView>

I tried this, but the parser said it had not found a rule from <navigation-rule> <from-view-id>/secure/*.xhtml</from-view-id> <navigation-case> <from-outcome>index</from-outcome> <to-view-id>/index.xhtml</to-view-id> </navigation-case> </navigation-rule> to /secure/pagex.xhtml. Is this true? I have to give a rule for all of my pages one by one?

1 个答案:

答案 0 :(得分:2)

通配符仅允许作为后缀(作为最后一个字符)。

<navigation-rule>
    <from-view-id>/secure/*</from-view-id>
    <navigation-case>
        <from-outcome>index</from-outcome>
        <to-view-id>/index.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

<from-view-id>是可选的。你也可以删除它。

<navigation-rule>
    <navigation-case>
        <from-outcome>index</from-outcome>
        <to-view-id>/index.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

或者,更好的是,使用隐式导航,然后您可以完全删除<navigation-rule>

E.g。 GET

<h:button ... outcome="/index" />
<h:link ... outcome="/index" />

或POST

public String logout() {
    // ...

    return "/index?faces-redirect=true";
}

JSF会自动担心扩展和映射。

另见: