【发布时间】:2012-05-17 22:26:51
【问题描述】:
我正在使用 Richfaces 4,并尝试在 Rich:orderingList 中获取所选项目。我想要这些,以便我可以通过按下“删除”按钮将它们从列表中删除。所以我有这个:
<rich:orderingList id="categoriesList" listHeight="100px"
listWidth="300px" value="#{selectionBean.availableCategories}"
selection="${selectionBean.selectedCategories}"
valueChangeListener="#{selectionBean.takeSelection}" >
<a4j:ajax event="click" render="categoriesList" execute="@this" />
</rich:orderingList>
还有@ViewScoped backing bean中的函数,我从这里改编自https://community.jboss.org/message/561295:
private List<String> availableCategories;
private List<String> selectedCategories;
...............................
public void takeSelection(AjaxBehaviorEvent event) {
System.out.println("ABE In takeSelection...");
System.out.println(" Trying to find component with offering elements...");
UIComponent component = event.getComponent();
System.out.println(" Found: " + (component == null ? "<null>" : (component.getClass().getName() + " - " + component.getId())));
if(component != null) {
System.out.println( " Component that fired the event: " + component.getClass().getSimpleName() + " - " + component.getId());
UIOrderingList orderingList = (UIOrderingList) component;
System.out.println(" selectedCategories are "+ selectedCategories);
}
System.out.println(type + " Leaving takeSelection");
}
问题是当我点击列表选择一个项目时,虽然我看到发送了一个Ajax请求,但selectedCategories列表没有更新,也没有调用takeSelection方法。
【问题讨论】: