Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rich:orderingList usage example

can anyone provide me with an example of how to use th rich:orderingList control? I've gotten to the point where I'm able to display the data as I wanted but now I'd actually like to have the modified order propagated to server. I can't find anything on that 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 backing bean has a property data defined that returns just a List<Country>.

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

like image 582
Matthias Hryniszak Avatar asked Jul 21 '26 07:07

Matthias Hryniszak


1 Answers

When you submit the form, Seam will re-order the list (#{countryHandler.data}) for you so you should be able access at this point. I whipped up a quick example to test this. All files are as follows:

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>

See also:

  • http://livedemo.exadel.com/richfaces-demo/richfaces/orderingList.jsf
  • http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_orderingList.html
  • http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/richfaces/orderingList.html
like image 74
Aaron Chambers Avatar answered Jul 23 '26 20:07

Aaron Chambers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!