File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes navigation not working after validation fail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "navigation not working after validation fail" Watch "navigation not working after validation fail" New topic

navigation not working after validation fail

Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139

I have a form and there are several fields in it and some of these are required.
I have two buttons on this page1.
1) button1 is to proceed to page2.
2) button2 navigates to page3.

If I enter values in all the required fields and click button1, it works fine and takes me to the page2.
but, if I don't enter anything in the required field, and click on the button 1, then the required validation fails, so it comes back to the same page. After that even if I enter values in all the fields and click on the button 1, it takes me to the page3(which is the destination of button2).

Also, I have a link on page3 to go to the page2, but even that link stops working and takes me to some other page, which I have not specified for this link's action .

please help, I am not able to understand what is happening here.

Ron De Leon

Joined: Feb 14, 2006
Posts: 11
Hi Sushma,

I am getting the same problem as you have been experincing that navigation keeps returning to the same page.

Below are some code samples for reference. Also, I put some logs to capture the behavior.

The navigation works and sometimes doesn't work depending on the certain situation as you have describe above.

This is my observation of navigation not working from looking in the logs. Everytime I hit the link and it returns to the same page. I don't see the method "viewEditAction" being called by JSF. Instead it reconstruct the same page again, so I will see the constructor of "SearchRequestFaces" being called again.

I assume one thing that there could be exception or error in JSF that it keeps the previous request in the Faces Context for that particular session. It might not work on my session but it might work on other session.

FOR QUICK FIX, I usually close all my IE to force to get a new session and to restart the app server.

I hope this help. I am still looking for the answer for this navigation not working. I need look in the FacesContext to see what is happening there. I will let you know if I find something informative.


<!-- jsp page -->
<h:commandLink id="editSearchs" action="#{clientSearch.viewEditAction}" >
<hutputText value="View/Edit" />
<f:param name="idAcct" value="#{data.idAcct}"/>

<!-- -->

public SearchRequestFaces() {
log.debug("SearchRequestFaces => initiliazed for request");

public String viewEditAction() {
String idAccount = DataTypeConverter.getFacesParamValue(this.fc, "idAcct");
log.debug("VIEW EDIT ACTION => setting the current account with " + idAccount + " or " + client.getAccountFaces().getIdAcct());
return "ViewEdit";

<!-- managed bean -->
<managed-bean-class> com.espeed.compliance.faces.client.SearchRequestFaces

<!-- navigation -->

Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
well, for me I know for sure that the navigation doesn't work only after validation fails and only for a button and a link...
and this behaviour doesn't change even after restarting the server or closing all the explorer.
I am sure there is some JSF life cycle matter here which I don't know.

experts, please suggest something.

Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
I tried a phaseListener and just printed the facesContext.getViewRoot().getViewId() before and after all the phases and it turns out that after the validation fails and when I click any other links or button the viewId changes in the APPLY_REQUEST_VALUES phase... why is that and how does it gets the view id that is not specified for that button or link is not clear to me...
A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
I am still learning JSF, but I would give it a try changing the bean to session scope and removing the "redirect" from the navigation rules in the config file. Just my idea.....
I agree. Here's the link:
subject: navigation not working after validation fail
It's not a secret anymore!