Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JSF question

  Asked By: Jose    Date: Jun 02    Category: Java    Views: 716
  

I have an update page which I can call from many places. after user clicks update button I need to go back to the caller page which can be different each time.
how do I get the navigation rule name?
I can get the caller servlet from url request but I need to return a string in my action method which is the name of navigation rule.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Neil Turner     Answered On: Jun 02

It could be a rapid solution for the problem.


<managed-bean>
<managed-bean-name>yourController</managed-bean-name>
<managed-bean-class>YourController</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>


<navigation-rule>
<navigation-case>
<from-outcome>list</from-outcome>
<to-view-id>/List.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>view</from-outcome>
<to-view-id>/View.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>edit</from-outcome>
<to-view-id>/Edit.jsp</to-view-id>
</navigation-case>
</navigation-rule>




public class YourController {

String lastOutcomeName = "list";

public String edit() {
String param =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().\
get("outcomeName");

if(param != null && !param.trim().eaquals("")) {
lastOutcomeName = param;
} else {
lastOutcomeName = "list";
}

return "edit";
}

public String save() {
.....
return lastOutcomeName;
}

public String cancel() {
.....
return lastOutcomeName;
}
}


List.jsp
============

<h:commandLink value="Edit" action="#{yourController.edit}">
<f:param name="outcomeName" value="list"/>
</h:commandLink>


View.jsp
==========
<h:commandLink value="Edit" action="#{yourController.edit}">
<f:param name="outcomeName" value="view"/>
</h:commandLink>

 
Didn't find what you were looking for? Find more on JSF question Or get search suggestion and latest updates.




Tagged: