3

谁能为我提供一个如何使用丰富的示例:orderingList 控件?我已经到了可以根据需要显示数据的地步,但现在我实际上希望将修改后的订单传播到服务器。我找不到关于那个主题的任何东西。

<rich:orderingList value="#{countryHandler.data}" var="country">
    <rich:column>
        <f:facet name="header">
            <h:outputText value="id"/>
        </f:facet>
        <h:outputText value="#{country.id}"/>
    </rich:column>
    <rich:column>
        <f:facet name="header">
            <h:outputText value="code"/>
        </f:facet>
        <h:outputText value="#{country.code}"/>
</rich:column>

并且我的支持 bean 定义了一个属性数据,它只返回一个 List<Country>。

再说一遍:如何将更改后的对象顺序填充回服务器?

4

2 回答 2

2

当您提交表单时,Seam 将为您重新排序列表 (#{countryHandler.data}),以便您此时可以访问。我做了一个简单的例子来测试这个。所有文件如下:

CountryHandler.java

@Name("countryHandler")
@Scope(ScopeType.CONVERSATION)
public class CountryHandler {

    @In(create=true)
    private CountryService countryService;

    private List<Country> data;

    public void loadCountries() {
        this.data = this.countryService.getCountryList();
    }

    public List<Country> getData() {
        return data;
    }

    public void setData(List<String> data) {
        this.data = data;
    }

    public void submit() {
        //check the list order here.  You should find it's ordered...
    }
}

国家.xhtml

...snip...

<rich:orderingList value="#{countryHandler.data}" var="country">
    <rich:column>
        <f:facet name="header">
            <h:outputText value="id"/>
        </f:facet>
        <h:outputText value="#{country.id}"/>
    </rich:column>
    <rich:column>
        <f:facet name="header">
            <h:outputText value="code"/>
        </f:facet>
        <h:outputText value="#{country.code}"/>
</rich:column>
</rich:orderingList>

<h:commandButton action="#{countryHandler.submit()}" value="Submit" />

...snip...

国家/地区.page.xml

<page>
    ...snip...

    <begin-conversation join="true"/>

    <action execute="#{countryHandler.loadCountries()}"/>

    ...snip...
</page>

也可以看看:

于 2009-07-31T10:31:09.990 回答
0

我需要使用订购单。正如您所说,我可以将元素列表加载到排序列表中,但我无法管理从列表中删除项目。我尝试使用该activeItem属性,但它在支持 bean 时与我的对象不合作。

于 2009-08-21T07:18:38.987 回答