This content has been marked as final.
Show 7 replies
-
1. Re: EntityQuery Restrictions
pmuir Oct 24, 2007 3:55 PM (in response to griffitm)Try
public class StatusList extends EntityQuery { private static final String[] RESTRICTIONS = {"lower(status.description) like concat('%', concat(lower(#{statusList.status.description}),'%'))",}; ... private Status status = new Status(); @Override public String getEjbql() { return "select status from Status status"; } @Override public String getOrder() { return "status.sortOrder"; } ...
-
2. Re: EntityQuery Restrictions
griffitm Oct 24, 2007 4:03 PM (in response to griffitm)Doh! Thanks!
-
3. Re: EntityQuery Restrictions
griffitm Oct 25, 2007 5:22 PM (in response to griffitm)Overriding the getOrder method as below then disables the clickable sorting feature of the data tables:
<h:column> <f:facet name="header"> <s:link styleClass="columnHeader" value="Description #{statusList.order=='description asc' ? messages.down : ( statusList.order=='description desc' ? messages.up : '' )}"> <f:param name="order" value="#{statusList.order=='description asc' ? 'description desc' : 'description asc'}"/> </s:link> </f:facet> #{status.description} </h:column>
No longer seems to work, because I suspect the sort order is always returned by the Entity as what is returned by getOrder(). Is there any way for both to happily co-exist?
Do I need to override setOrder as well, and only return the hard coded value if null?
Thanks in advance for any help!
MG -
4. Re: EntityQuery Restrictions
griffitm Oct 25, 2007 5:31 PM (in response to griffitm)This seems to work:
@Override public String getOrder(){ if(super.getOrder() == null){ return "status.sortOrder"; } return super.getOrder(); }
-
5. Re: EntityQuery Restrictions
pmuir Oct 25, 2007 6:18 PM (in response to griffitm)Or hold an order field locally and implement both get and setOrder...
-
6. Re: EntityQuery Restrictions
griffitm Oct 26, 2007 10:38 AM (in response to griffitm)It seems that if you specify a query declaratively using the framework entity query, you loose the ability to sort data in a data table, because the data is always returned in the same order by the query. Can you pass the order by clause dynamically by declaring it as something that is a parameter to the query?
Thanks in advance,
MG -
7. Re: EntityQuery Restrictions
pmuir Oct 26, 2007 1:10 PM (in response to griffitm)What? you posted the solution above.