我有一個JSF應用程序,其中有一個組合框。JSF訪問bean類中的html元素值
<h:selectOneMenu id="collectorType"
value="#{activityDataSource.object.type}"
rendered="#{empty activityDataSource.object.id}"
disabled="#{!sp:hasRight(facesContext, 'ManageApplication')}"
readonly="#{!sp:hasRight(facesContext, 'ManageApplication')}"
onchange="$('editForm:selectTypeButton').click();">
<f:ajax event="change"
execute="@this"
render="dsTransformationRule dsCorrelationRule"
listener="#{activityDataSource.handleCollectorTypeChange}" />
<f:selectItem itemValue="" itemLabel="#{msgs.select_collector_type}"/>
<f:selectItems value="#{activityDataSource.collectorTypes}"/>
</h:selectOneMenu>
而且我得到的bean類這樣的組合框的設定值:
public void setSelectedTransformationRule(String transformationRule)
throws GeneralException {
String collectorType = (String) getRequestParam().get("editForm:collectorType");
}
而且我成功地這樣做。我通過組合框的ajax onchage事件調用此方法。
但是,如果我嘗試在不同的方法中獲得相同的組合框值,我會得到空值。
public void handleCollectorTypeChange() throws GeneralException {
String collectorType = (String) getRequestParam().get("editForm:collectorType");
}
任何幫助!
我也這麼做過。仍爲空 –
「 」上沒有'process'和'partialSubmit'屬性。 –