简体   繁体   English

XHTML页面之间的链接?

[英]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. 我使用<h:outputLink value="home.jsf"><h:outputText value="Home"/></h:outputLink>在XHTML页面或所谓的Facelets之间移动。

Personally though I would prefer to do the same thing though using the <h:commandButton>...</h:commandButton> . 就我个人而言,尽管我更愿意使用<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 . 原因是,将背景图像放置到按钮中比使用outputLinkoutputText创建CSS解决方法要容易得多

Is there any way to do that? 有什么办法吗?

Syntax for <h:commandButton> : <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 : 然后,您可以在bean中创建一个操作以重定向到另一个视图:

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

You can get your application URL with : 您可以通过以下方式获取应用程序URL:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM