我在同一页面上有几个这样的表格:
<h:form>
<h:selectOneMenu value="#{collectionBean.selectedCollection}">
<f:selectItems value="#{collectionBean.collectionItems}" />
<a4j:support event="onchange" />
</h:selectOneMenu>
<a4j:commandButton value="Add" action="#{collectionBean.addToCollection(_resource)}" >
</a4j:commandButton>
</h:form>
这是我的豆:
@Name("collectionBean")
@Scope(ScopeType.SESSION)
public class CollectionBean {
private String selectedCollection;
public String getSelectedCollection() {
return selectedCollection;
}
public void setSelectedCollection(String collectionName) {
selectedCollection = collectionName;
}
public List<SelectItem> getCollectionItems() {
...
}
public void addToCollection(Resource res) {
...
}
}
表单与资源相关联_resource
,其目标是让用户将资源添加到他选择的集合中。
问题是只有页面上的最后一个表单有效:当更改其他表单中的选择时,该setSelectedCollection
方法永远不会被调用。
你知道什么可能是错的吗?