It's not a secret anymore!
The moose likes JSF and the fly likes JSF command button action question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF command button action question..." Watch "JSF command button action question..." New topic

JSF command button action question...

Alan Smith
Ranch Hand

Joined: Oct 19, 2011
Posts: 185

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.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: JSF command button action question...
It's not a secret anymore!