2

我正在使用 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 方法。

4

1 回答 1

0

几个问题,以便更好地理解您的问题。

这样做的目的是什么:

<a4j:ajax event="click" render="categoriesList" execute="@this" />

为什么要在每次单击时呈现 orderingList,因为它假设仅在单击“删除”按钮时才被修改?

为什么:

selection="${selectionBean.selectedCategories}"

以“$”符号而不是“#”开头?(不应该阻塞)。

最后,我在组件上找不到“选择”属性。参见VDL。你确定语法吗?

问候

于 2012-05-09T21:11:01.893 回答