0

Right now I am giving my navigation rules in the faces-config.xml file. If I want to stop making entries in faces-config.xml.

How can i specify the navigation rules if I don't want to do it in 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>
Sunny Gupta
  • 6,929
  • 15
  • 52
  • 80

2 Answers2

3

Implicit navigation is only supported since JSF 2.0. As per the XML file root declaration and your question history, you're using JSF 1.2, so that's end of story.

However, based on your current navigation cases, you seem to be redirecting everytime. For that you could also use ExternalContext#redirect() instead.

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

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

Or, if you actually don't need to perform business actions at all, just use a normal link.

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

The additional advantage is that it becomes searchbot-indexable (and thus better SEO).

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Please suggest me a way how can I use it in JSF 2.0, There is no problem i can change the XML file root declaration and start using JSF 2.0. – Sunny Gupta May 12 '12 at 03:02
0

Instead of "success" the action method may return a view id, for example

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

This way you can shift your navigation rules to your managed beans. If you want to enforce a redirect use

public String login() { return "wsListing?faces-redirect=true"; }
Frank
  • 41
  • 1