9
我需要在我的ajax請求中將參數傳遞給服務器。請參閱下面的代碼。 範圍:查看範圍如何將參數傳遞給h:inputText中的f:ajax? f:param不起作用
沒有F:PARAM
<p:column width="40">
<h:inputText id="originalCostInputTxt" value="#{articlePromo.costoBruto}"
<f:ajax event="change"
execute="@this"
listener="#{promotionDetailManagedBean.onCostoBrutoChange}">
</f:ajax>
</h:inputText>
</p:column>
Managed Bean的
public final void onCostoBrutoChange(final AjaxBehaviorEvent event) {
createCostoBrutoOptions(promoArticlesList);
}
在這種情況下,方法onCostoBrutoChange()不會被調用。但是,當我包含f:param時,它不會被調用。請參閱下面的代碼。
使用f:PARAM
<p:column width="40">
<h:inputText id="originalCostInputTxt" value="#{articlePromo.costoBruto}"
<f:ajax event="change"
execute="@this"
listener="#{promotionDetailManagedBean.onCostoBrutoChange}">
<f:param value="#{articlePromo.promocionArticuloId}" name="myId"/>
</f:ajax>
</h:inputText>
</p:column>
Managed Bean的
public final void onCostoBrutoChange(final AjaxBehaviorEvent event) {
createCostoBrutoOptions(promoArticlesList);
String id = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("myId");
}
無法確定這個代碼什麼不正確。請指導。
感謝, Shikha
不知道這種方式...不錯! – Daniel
上帝自己的答案.. :)謝謝。有效。沒有意識到這一點。 –
@BalusC我在'c:foreach'裏面用編程的方式評估EL,使用迭代變量'var',但它的計算結果爲null。 – Theo