This content has been marked as final.
Show 8 replies
-
1. Re: rich:column - Attribute sortingOrder and EL
nbelaevski Jul 14, 2009 4:54 PM (in response to mcnig)Hi,
How does "headerCells" look like? -
2. Re: rich:column - Attribute sortingOrder and EL
mcnig Jul 15, 2009 3:53 AM (in response to mcnig)I'm sorry, my example was too complex for the simple problem. So I made a easier one based on this example: http://mkblog.exadel.com/maxablog/richfaces-built-in-sorting/
<rich:dataTable value="#{wondersBean.sevenNewWonders}" var="wonder"> <rich:column sortBy="#{wonder.name}" sortOrder="#{wondersBean.sortingOrder}"> <f:facet name="header">Name</f:facet> <h:outputText value="#{wonder.name}" /> </rich:column> <rich:column sortBy="#{wonder.location}" sortOrder="ASCENDING"> <f:facet name="header">Location</f:facet> <h:outputText value="#{wonder.location}" /> </rich:column> </rich:dataTable>
The first column is always sorted and the "sort by click" doesn't work. I guess that the EL evaluats by each click. (#{wondersBean.sortingOrder} returns the String "ASCENDING").
The second column works fine. It's possible sort ASC/DESC by click.public String getSortingOrder(){ return "ASCENDING"; }
-
3. Re: rich:column - Attribute sortingOrder and EL
ilya_shaikovsky Jul 15, 2009 5:07 AM (in response to mcnig)
(#{wondersBean.sortingOrder} returns the String "ASCENDING").
So the order ASC hardcoded in getter return? It should just return current sortingOrder instead. -
4. Re: rich:column - Attribute sortingOrder and EL
mcnig Jul 15, 2009 7:18 AM (in response to mcnig)"ilya_shaikovsky" wrote:
So the order ASC hardcoded in getter return? It should just return current sortingOrder instead.
I hardcoded the getter just for the example. In the real code, I get the default value from a property file. (From the same property we get the header names, special styles for a column and other special behaviors.) Why? I use a lot of tables. As a result of that I wrote a facelet table tag and a table bean, this enables me to use one tag instead of copy many code lines.
How can I get, set and return the current sortingOrder? -
5. Re: rich:column - Attribute sortingOrder and EL
ilya_shaikovsky Jul 15, 2009 7:34 AM (in response to mcnig)How can I get, set and return the current sortingOrder?
I mean the property should change between sorting states. And if it always return the same value - sorting will not occurs. -
6. Re: rich:column - Attribute sortingOrder and EL
mcnig Jul 15, 2009 7:53 AM (in response to mcnig)But how can I get the sorting state?
Or do you mean that I should write a toggle-method? (But even for this a should know the sorting state.) -
7. Re: rich:column - Attribute sortingOrder and EL
ilya_shaikovsky Jul 15, 2009 8:04 AM (in response to mcnig)No I mean you should have actual property in Bean and getter and setter for it in order component could update the state in bean after sort and not just get the same value.
-
8. Re: rich:column - Attribute sortingOrder and EL
mcnig Jul 15, 2009 9:11 AM (in response to mcnig)That works! It much easier than I expeced!!! Thank you for your assistance :-)
For everybody who have the same "problem" just add this to your bean:import org.richfaces.model.Ordering; private Ordering sortingOrder = Ordering.ASCENDING; public Ordering getSortingOrder() { return sortingOrder; } public void setSortingOrder(final Ordering vSortingOrder) { this.sortingOrder = vSortingOrder; }