簡體   English   中英

rich:orderingList用法示例

[英]rich:orderingList usage example

任何人都可以提供一個如何使用豐富的例子: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>。

所以再次:如何將更改的對象順序填充回服務器?

當您提交表單時,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...
    }
}

Countries.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...

Countries.page.xml

<page>
    ...snip...

    <begin-conversation join="true"/>

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

    ...snip...
</page>

也可以看看:

我需要使用訂購清單。 正如您所說,我可以將元素列表加載到排序列表中,但我無法管理從列表中刪除項目。 我嘗試使用activeItem屬性,但它不支持我的對象支持bean。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM