【问题标题】:Link between XHTML pages?XHTML 页面之间的链接?
【发布时间】:2014-10-18 06:29:52
【问题描述】:

我使用<h:outputLink value="home.jsf"><h:outputText value="Home"/></h:outputLink> 在我的 XHTML 页面或所谓的 Facelets 之间移动。

虽然我个人更愿意使用<h:commandButton>...</h:commandButton> 做同样的事情。原因是在按钮中放置背景图像比使用 outputLinkoutputText 创建 CSS 解决方法更容易。

有什么办法吗?

【问题讨论】:

  • 我也非常喜欢如何做。你有描述这个问题的链接吗?

标签: jsf jsf-2 richfaces


【解决方案1】:

<h:commandButton> 的语法:

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

然后您可以在 bean 中创建一个操作以重定向到另一个视图:

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

您可以通过以下方式获取您的应用程序 URL:

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

【讨论】:

    猜你喜欢
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-03
    • 2014-06-21
    • 2022-01-18
    • 2017-07-05
    相关资源
    最近更新 更多