Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

navigation not working after validation fail

 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Sushma
 
Ron De Leon
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks,
Ron


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


<!-- SearchRequestFaces.java -->

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

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


<!-- managed bean -->
<managed-bean>
<managed-bean-name>clientSearch</managed-bean-name>
<managed-bean-class> com.espeed.compliance.faces.client.SearchRequestFaces
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>


<!-- navigation -->
<navigation-case>
<from-outcome>Search</from-outcome>
<to-view-id>/jsf/client/SearchAccount.jsp</to-view-id>
<redirect/>
</navigation-case>

<navigation-case>
<from-outcome>ViewEdit</from-outcome>
<to-view-id>/jsf/client/EditViewAccount.jsp
</to-view-id>
<redirect/>
</navigation-case>
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic