How can I define a navigation rule from all view-ids from #{current.doLogout} to the same view-id?
Asked
Active
Viewed 3,975 times
0
-
Your heading and description to my knowledge varies. While your heading states you need to be in the same page after you click the command button(Which is what @Balusc described), your description states what I described. Please correct me if I am wrong – mvg Mar 01 '11 at 10:57
2 Answers
3
You need to use wildcards to achieve this
Just call the logout method in action tag. and just add this to your faces-config.xml
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>welcome</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

mvg
- 1,574
- 4
- 37
- 63
2
If you don't define any or return null
or void
in action method, it will by default display the same page as where the form is been submitted.
public void doLogout() {
// Logout.
}
This way you don't need to fiddle with navigation cases in faces-config.xml
. Are you by the way already aware of the new JSF 2.0 "implicit navigation" feature?

BalusC
- 1,082,665
- 372
- 3,610
- 3,555
-
Your answer varies with this http://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener. Can a return type of action method be void? – mvg Mar 01 '11 at 06:12
-
If I don't define the rule in the faces-config.xml, the commandLink will be disabled due to lack of any navigation-rule!!! – ehsun7b Mar 01 '11 at 09:02
-
@mvg: Yes, it can. I didn't said anywhere that it **must** return a `String`. @ehsun: then the cause of your problem lies somewhere else. Once again, are you aware about the new implicit navigation rules in JSF 2.0 which makes the entire navigation rules obsolete? – BalusC Mar 01 '11 at 11:32
-
Do you mean by implicit navigation, the returning the name of pages (facelets)? – ehsun7b Mar 01 '11 at 14:41
-
In fact I have a command link which can be clicked from any page (facelet) and will call a method of a session scoped bean. and after that I want the user visit the same page but he has loged out and the content of the page may be different. – ehsun7b Mar 01 '11 at 14:42
-
Just returning `null` or `void` ought to work. Don't forget to remove any navigation cases related to this which becomes unnecessary. – BalusC Mar 01 '11 at 15:19