my dog learned polymorphism*
The moose likes JSF and the fly likes navigation issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "navigation issue" Watch "navigation issue" New topic
Author

navigation issue

Tom Cog
Greenhorn

Joined: Jan 21, 2011
Posts: 4
I'm a newbie to JSF so please take it easy on me. I'm an experienced programmer with Struts, but this is a new small project I have to do (by myself of course) with JSF.

I'm using ICEFaces 1.8, with JSF 1.2 and Java6 SDK. Tomcat 6 web container.

I have Page1 that contains a data table, that lists master record data. One of the columns contains a commandLink which allows a specific child record to be edited, in Page2. The navigation works perfectly from Page1 to Page2. The problem comes in when after the user is done on Page2, they may need to go back to Page1 to look at the rest of the master records and perhaps view another one. I cannot get that to work. I created a commandLink in Page2, to navigate back to Page1, using a static outcome string. Regardless if I use redirect true or false, JSF will immediately go to Page2 and not display Page1. If I re-enter the URL for Page1 into a new browser tab, it still goes to Page2. The only way I can get back to Page1 is to completely close the browser, the open it back up and put in the URL.

I know there must be something simple I am missing here. I tried to search for the answer with all of the search terms I can think of but I keep getting back results that do not apply to my situation. Can someone tell me what I'm doing wrong here, or point me to an existing thread that explains this?

Thanks in advance!

Tom
Tom Cog
Greenhorn

Joined: Jan 21, 2011
Posts: 4
Bump. Anyone? Please...
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Tom

You have an strange problem , because there is not problem using a commandLink to navigate from one page to another and go back to the first, remember that jsf use a post method for navigation and for that the url is one step behind, you use redirect to make a new get and refresh the url but you lost the data from the page.
If I re-enter the URL for Page1 into a new browser tab, it still goes to Page2.

I think for some weird reason when you try to enter the url for Page1 the ViewHandler load the outcome (a session bean) and for that reason match a navigation case and cause the navigation for page2. Try to create 2 empty page with the same behavior of the navigation and check if the same problem occurs.
Sorry for not having a concrete answer, I hope this helps somewhat.
Regards
Cesar


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Tom Cog
Greenhorn

Joined: Jan 21, 2011
Posts: 4
Well, a completely static navigation test works. I created two simple pages that use a commandLink to go to the other page. This works. I am still completely mystified why my original case does not work. The link back from the detail record page to the master record page is also static. I also want to make it completely clear that I am NOT pressing the browser 'back' button, or in any way trying to implement 'back button' behavior. I want to have a command link that will go to a specific JSF page.
Eric Ford
Greenhorn

Joined: Jun 04, 2010
Posts: 17
For one like this, Tom, you really need to post your code. My first suspicion is that you're using a backing class that is "session" scoped and whatever flag value you use to detect/perform the navigation is still set the next time you enter Page 1 so the trip to Page 2 is appearing to occur automatically.

But, I'm just guessing.

Eric


Tom Cog wrote:I'm a newbie to JSF so please take it easy on me. I'm an experienced programmer with Struts, but this is a new small project I have to do (by myself of course) with JSF.

I'm using ICEFaces 1.8, with JSF 1.2 and Java6 SDK. Tomcat 6 web container.

I have Page1 that contains a data table, that lists master record data. One of the columns contains a commandLink which allows a specific child record to be edited, in Page2. The navigation works perfectly from Page1 to Page2. The problem comes in when after the user is done on Page2, they may need to go back to Page1 to look at the rest of the master records and perhaps view another one. I cannot get that to work. I created a commandLink in Page2, to navigate back to Page1, using a static outcome string. Regardless if I use redirect true or false, JSF will immediately go to Page2 and not display Page1. If I re-enter the URL for Page1 into a new browser tab, it still goes to Page2. The only way I can get back to Page1 is to completely close the browser, the open it back up and put in the URL.

I know there must be something simple I am missing here. I tried to search for the answer with all of the search terms I can think of but I keep getting back results that do not apply to my situation. Can someone tell me what I'm doing wrong here, or point me to an existing thread that explains this?

Thanks in advance!

Tom
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

Welcome to the JavaRanch, Tom, but please don't "bump". You shouldn't have to, since we have a lot of traffic here and if someone knows the answer, you'll usually get a response fairly quickly. "Fairly quickly" isn't instantaneous, however, since we're all volunteers here, not 24x7 paid support, and the planet needs to spin around once or twice before all potential contributors are likely yo have seen your question. Patience is a virtue.

I'm afraid I can't really tell what's wrong from your description. Usually when you get stuck on a page that means that one or more of the form's data objects is failing validation. An <h:messages globalOnly="false"/> tag can generally tell you what the problem is.

One thing to be aware of however, is that in JSF, unlike most webapp frameworks, a URL isn't an absolute resource locator, it's more of a session handle. So the displayed URL value and the displayed page are often at variance.


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

Joined: Jan 21, 2011
Posts: 4
Eric Ford wrote:For one like this, Tom, you really need to post your code. My first suspicion is that you're using a backing class that is "session" scoped and whatever flag value you use to detect/perform the navigation is still set the next time you enter Page 1 so the trip to Page 2 is appearing to occur automatically.

But, I'm just guessing.

Eric


Hi Eric, thanks for the response. The bean which is used is request scope. There are no UI components within the bean, its purely used to hold properties that are referenced in the jsp pages with value bindings. I'm not permitted to post the exact code here, but I should be able to create a cloned version of it that would be safe for me to post. Until I can do that, I will just give a quick description here. The first page is very simple. It has a data table, with three columns. The data table has a value binding for the property which contains an ArrayList of objects for the data table to iterate. The second and third columns contain simple text from object properties. The first column contains a commandLink, whose action binds to a method of a different bean (the backing bean for the second page) that will load the data based on the value being set with setPropertyActionListener.

The second page has a commandLink with a string outcome hard coded for the action, which directs back to the first page. The expected behavior would be that following this command link would display the first page, but it does not. The second page is displayed instead.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: navigation issue
 
Similar Threads
How to make a JSP/HTML page to stay on itself when user clicks on back button on the browser?
upon click of back button, go to logout page
<h:inputText> rendering problem in JSF1.2
Navigating to another page...
Liferay Portlet with JSF Portlet bride-Problem