tags:

views:

77

answers:

1

Hello Everybody ! I'm new in JSF and JSF 2.0 i want to redirect in JSF how can i do it? in html i can use tag for do this but in JSF i use h:outputLink or h:commandLink for render user if he is logged , login link not display to him, but if he not logged login link will display to him. and i want redirect link to other page or redirect to other website example google.com how can i do it with JSF? must i use action in h:commandLink? or rel in h:outputLink?

Thank you Best Regards

+1  A: 

Either use <h:link> to fire a JSF GET request:

<h:link outcome="page2">

Or add ?faces-redirect=true to the navigation outcome of a JSF POST request:

<h:commandLink action="page2?faces-redirect=true">

Or use <h:outputLink> if you want to pass a "normal" URL in:

<h:outputLink value="page2.jsf">
BalusC
Hi Balus thank you, but i have problem with include page, i include menu page into main page and when i click on Register link, it not redirect into register page, can you help me? Thank You ! Best Regards
Killen
The `h:link` outcome must point to the filename of the page without extension and it must be in the same folder as the main page.
BalusC
i use h:commandLink, but if menu page in one folder and register page in other folder and i include menu page into main page (it outside all of folder) it can be redirect? in my backing bean if return String outcome i must return such as `return "../register"` ? Thank for your response !
Killen
`UICommand` components should go in a `h:form`. The outcome must just match the page filename. If it's an URL, then you need to define a navigation case in faces-config.xml. You can on the other hand also use `h:outputLink`. This behaves exactly the same as `<a>`.
BalusC
Many thank you Balus !! :D
Killen