2
我正在使用Richfaces 4,并尝试获取rich:orderingList中的选定项目。我想要这些,以便我可以通过按下“删除”按钮将它们从列表中删除。所以对我有这样的:如何从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支持豆的功能,这是我改编自这里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方法。
嗨,谢谢你的回答/问题。 – yorick456
1.你说得对,渲染没有必要,但我认为它不会改变问题。 2.糟糕,这是一个错字,应该是“#” 3.“选择”属性在那里,至少在3.3,如下所示:http://docs.jboss.org/richfaces/latest_3_3_X/ EN/devguide/HTML/rich_orderingList.html#d0e38485。也许他们拿出了第4版,尽管我认为它应该在两个版本之间保持不变:https://community.jboss.org/wiki/RichFacesMigrationGuide33x-4xMigration-ComponentsMigration-RichInputComponents – yorick456
我认为“选择”属性已经真正从3.3到4.x中删除了。所以最好的方法是在RichFaces JIRA上创建一个问题,并要求对rich:orderingList组件进行增强,以便再次支持“选择”。不要犹豫,在创建后发布一个链接,以便人们投票。 –