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?
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With