1
我有一個JSF頁面並且有一個與之關聯的Managedbean。在@RequestScoped中沒有獲取請求參數ManagedBean
我的XHTML頁面看起來是這樣的:
<h:head>
</h:head>
<h:body id="configuratorWrapper">
<h:form method="post" id="form" name ="name" prependId="false">
<f:view>
<div class="container">
<input type="hidden" name="exception" id="exception" value="aaa" />
</div>
<h:input type="hidden" name="email" id="email" value="#{emailManagedBean.sendEmailForErrorPage()}" />
</f:view>
</h:form>
<h:outputScript library="resources/bower_components/boostrap-sass/assets/javascripts" name="bootstrap.js"></h:outputScript>
</h:body>
emailManagedBean是相關Managedbean這是一個@RequestScoped ManagedBean。
在EmailManagebean的方法sendEmailForErrorPage()看起來像:
public Boolean sendEmailForErrorPage() {
this.exception = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("exception");
}
我需要得到的異常值,爲 「AAA」,這是我在XHTML頁面了。但現在我的價值爲零。
我嘗試使用
<p:commandButton name ='email' action="#{emailManagedBean.sendEmailForErrorPage()}">
<f:param name="exception" value="aaa" />
</p:commandButton>
不過結果卻是零。
有人可以幫我解決這個問題。
難道你不應該在f:view中放置h:form來正確構建組件樹嗎? – OTM