File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Navigation Problem

 
Kinildson Persegueiro
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to say, I'm using Facelets too...


My h:commandLink is in the list page:
 
Christian Nicoll
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kinildson Persegueiro
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic