aspose file tools*
The moose likes JSF and the fly likes Navigation Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Navigation Problem" Watch "Navigation Problem" New topic
Author

Navigation Problem

Kinildson Persegueiro
Greenhorn

Joined: Aug 04, 2008
Posts: 12
Hi there,

What would cause a commandLink tag to do not dispatch to the right page?

When I clik the commandLink the flow goes through my backing bean, I'm printing with system.out.println to assure it, but the page navigation isn't working.
Instead of going to a different page, which is mapped in my faces-config.xml, the same command's link page is showed.

Thanks!
Kinildson Persegueiro
Greenhorn

Joined: Aug 04, 2008
Posts: 12
I forgot to say, I'm using Facelets too...


My h:commandLink is in the list page:
Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106
Hi,

I've not used facelets, but in your code you are using the actionListener-attribute for your commandLink and I assume that this is the problem. In the old JSP's there exists an action-attribute for the commandLink, which affects the navigation, perhaps this exists also still in facelets and you should use it .

Another option why the same page will be displayed is that the outcome-mapping in your faces-config.xml doesn't match to another page. If this is the case then the same page will be refreshed.


SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - My Hello World Webservice
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Facelets won't make any difference. But you didn't show what navigation rule you defined in faces-config, and, as Christian pointed out, when not explicitly told otherwise, JSF will simply redisplay the current view.


Customer surveys are for companies who didn't pay proper attention to begin with.
Kinildson Persegueiro
Greenhorn

Joined: Aug 04, 2008
Posts: 12
there exists an action-attribute for the commandLink, which affects the navigation, perhaps this exists also still in facelets and you should use it .


I'm using the tag h:commandListener because I'm getting the atribute value int the backing bean...



It's working, I'm printing the value, it's ok. But the navigation fails.
Kinildson Persegueiro
Greenhorn

Joined: Aug 04, 2008
Posts: 12
my navigation rule...

<navigation-rule>
<from-view-id>/view/mainPage.xhtml</from-view-id>
<navigation-case>
<from-outcome>search</from-outcome>
<to-view-id>/view/mainPage.jsf</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>detail</from-outcome>
<to-view-id>/view/detail.jsf</to-view-id>
</navigation-case>
</navigation-rule>

${myBean.myMethod} will return the String "detail". According to my faces-config.xml I was expecting to be redirected to myContext/view/detail.xhtml.
I also tried to change the from-view-id's value tag to view/detail.xhtml but it didn't worked either...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

You're using an Action Listener instead of an Action Handler. Action Listeners should properly have a void return, not a String. Action Handlers return a navigation controlling String. Without a handler, the navigation rules are not applied by the JSF framework. Instead, the default navigation (return the same View as before) is applied.

People tend to over-use listeners in JSF, and I'm not sure why. Whether it's due to history, since JSF went through some pretty radical changes before it went "pro" and everyone's working off outdated examples or it's simply that they look technically flashier, or whatever, I just don't know.

A JSF URL doesn't "redirect", incidentally. It's decoded and used to locate the actual JSF view template (xhtml, in your case), which is then fed into the JSF lifecycle processor. It's not a URL redirection. The difference may seem inconsequential, but a lot of people also make the mistake of thinking that a webapp server is just some sort of glorified file server, and it isn't. Merely an URL decoding and resource retrieval system that's sometimes mapped to retrieve elements from a resource tree that's organized like directories and files (and may actually be so, but only in exploded WARs).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Navigation Problem