Rich: orderingList example

can someone provide me an example of how to use th rich: orderingList control? I got to the point where I can display the data the way I wanted, but now I really wanted the modified order to propagate to the server. I can not find anything on this subject.

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

and my bean support contains property data that only returns a List <Country>.

So again: how can I populate the changed order of objects back to the server?

+3
source share
2 answers

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

. :

+2

. , , . activeItem, bean.

0

Source: https://habr.com/ru/post/1712840/


All Articles