2012-07-26 37 views
1

我想在JSF頁面中創建命令按鈕。當我按下它時,我想打開一個新頁面並使用http發送一個值。我測試了這個h:commnadButton,但它不工作。如何在JSF中創建h:commandButton以打開新頁面

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

回答

4

h:commandButton用於提交表單,通常在服務器上執行動作。

使用h:button進行簡單的導航:

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

,這將產生一個普通的HTML <input type="button" onclick="window.location.href=/correct/path/to/EditAccountProfile.jsf" />,不需要HTTP POST。

參見:

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