• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF command button action question...

 
Alan Smith
Ranch Hand
Posts: 185
Firefox Browser Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I just started dipping into JSF even though I have heard bad things left, right and center about it. From what I have seen so far (which is very little) I quite like it! A quick question regards the command buttons 'action' attribute...

Here are two extremely basic jsf pages, index.xhtml and response.xhtml. I have omitted the rest of the code but this is all that is in the body of each file.





Basically all I want this to do is to be able to click the submit button on both pages which switches back and forth between the two, which works fine. My question is that when I click the button on index.xhtml "http://localhost:8080/JSF_Test/faces/index.xhtml" comes up in the address bar on the browser and "http://localhost:8080/JSF_Test/faces/response.xhtml" comes up when I click the button on response.xhtml. In other words, the urls are in reverse for both pages. When I click the button on index.xhtml shouldn't "http://localhost:8080/JSF_Test/faces/response.xhtml" display in the address bar as it is the current page and vice versa? Can someone explain this to me.

Thanks,
Alan
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The navigation URL is one of those bad things you hear about.

In JSF, the URL is not really a resource reference in the sense that it is on most platforms, it's more of a session handle. JSF knows what's really going on, so it doesn't waste time updating the URL.

For certain cases, that's not desirable. Although vanity is a common one, webapps using J2EE container security need the "real" URL as well, since the container secures URLs, not resources. To get the "real", up-to-date URL, you can include a <redirect/> element on your navigation rule. That will place your displayed URL in sync with the page, but it does incur the extra cost of a redirect.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic