我正在使用 Richfaces 4,并尝试获取丰富的选定项目: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 支持 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 方法。