【问题标题】:How to create h:commandButton in JSF to open a new page如何在 JSF 中创建 h:commandButton 以打开新页面
【发布时间】:2012-07-26 13:14:58
【问题描述】:

我想在 JSF 页面中创建命令按钮。当我按下它时,我想打开一个新页面并使用 http 发送一个值。我测试了这个h:commnadButton,但它不起作用。

<h:commandButton id="lnkHidden" value=" Edit User " action="EditAccountProfile.jsf">
 <f:param name="id" value="#{item.userid}" />
</h:commandButton>

【问题讨论】:

    标签: jsf jsf-2


    【解决方案1】:

    h:commandButton 用于提交表单,通常在服务器中执行操作。

    使用h:button 进行简单导航:

    <h:button id="lnkHidden" value=" Edit User " outcome="EditAccountProfile.jsf">
     <f:param name="id" value="#{item.userid}" />
    </h:button>
    

    这将生成一个普通的 HTML &lt;input type="button" onclick="window.location.href=/correct/path/to/EditAccountProfile.jsf" /&gt;,不需要 HTTP POST。

    另请参阅:

    When should I use h:outputLink instead of h:commandLink?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-25
      • 1970-01-01
      • 2019-05-24
      • 1970-01-01
      • 1970-01-01
      • 2016-07-25
      • 1970-01-01
      相关资源
      最近更新 更多