Socrates
Socrates

Reputation: 9574

Link between XHTML pages?

I use <h:outputLink value="home.jsf"><h:outputText value="Home"/></h:outputLink> to move between my XHTML pages or so called Facelets.

Personally though I would prefer to do the same thing though using the <h:commandButton>...</h:commandButton>. The reason is that it is easier to place a background image into a button than to create a CSS workaround with the outputLink and the outputText.

Is there any way to do that?

Upvotes: 0

Views: 92

Answers (1)

Thrax
Thrax

Reputation: 1964

Syntax for <h:commandButton> :

<h:commandButton action="#{yourBean.action}" image="yourPic.png" value="your text on the button" styleClass="yourCSS" />

You can then create an action in your bean to redirect on another view :

FacesContext.getCurrentInstance().getExternalContext().redirect("your destination");

You can get your application URL with :

FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();

Upvotes: 1

Related Questions