Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Michael Illgner
liferay-ui:search-container orderable ?
March 17, 2010 3:33 AM
Answer

Michael Illgner

Rank: Junior Member

Posts: 33

Join Date: June 30, 2009

Recent Posts

Hi folks
Another question from me ;-)

I just build a custom service using ServiceBuilder and managed to display the contents of my new database table using <the liferay-ui:search-container> taglib. No problem.

Now I want to sort the content of the seach-conatiner by an arbitrary column. Just setting the orderable attribut as describe in http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/SearchContainer does not to work .. Any ideas ?
 1
 2    <liferay-ui:search-container emptyResultsMessage="newsletterEmptyResultsMessage">
 3        <liferay-ui:search-container-results>
 4            <%
 5                try {
 6                    results = NewsLetterLocalServiceUtil.getNewsLetters(searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());
 7                    total = results.size();
 8
 9                    pageContext.setAttribute("results", results);
10                    pageContext.setAttribute("total", total);
11                } catch (SystemException se) {
12                    Log log = LogFactoryUtil.getLog(this.getClass());
13                    log.error("cannot get newsletter recipients", se);
14                }
15            %>
16        </liferay-ui:search-container-results>
17        <liferay-ui:search-container-row className="com.mycompany.NewsLetter"    keyProperty="id" modelVar="newsletter">
18            <liferay-ui:search-container-column-text name="Firstname" property="firstName" orderable="<%= true %>"/>
19            <liferay-ui:search-container-column-text name="Lastname" property="lastName" orderable="<%= true %>"/>
20            <liferay-ui:search-container-column-text name="Company"    property="company" orderable="<%= true %>"/>
21            <liferay-ui:search-container-column-text name="eMail" property="emailAddress" orderable="<%= true %>"/>
22            <liferay-ui:search-container-column-jsp align="right" path="/html/newsletter/edit_actions.jsp" />
23        </liferay-ui:search-container-row>
24        <liferay-ui:search-iterator />
25
26    </liferay-ui:search-container>


searchContainer.getOrderByComparator() always returns NULL !!!

What is going wrong here ?
Deawn Md Alimozzaman
RE: liferay-ui:search-container orderable ?
August 2, 2010 12:57 PM
Answer

Deawn Md Alimozzaman

Rank: New Member

Posts: 14

Join Date: February 10, 2010

Recent Posts

Hi,
did u get any solution because i am looking for the same solution. pls reply.
Corentin R
RE: liferay-ui:search-container orderable ?
January 6, 2011 9:19 AM
Answer

Corentin R

Rank: Junior Member

Posts: 92

Join Date: June 18, 2010

Recent Posts

Same question... Again and again ...
Any idea on how to get a list of custom bean with column orderable in a search-container ?

Thanks !
Corentin R
RE: liferay-ui:search-container orderable ?
January 6, 2011 10:04 AM
Answer

Corentin R

Rank: Junior Member

Posts: 92

Join Date: June 18, 2010

Recent Posts

Probably the good start of a solution here ... emoticon
venka reddy
RE: liferay-ui:search-container orderable ?
April 5, 2011 4:18 AM
Answer

venka reddy

Rank: Regular Member

Posts: 231

Join Date: March 23, 2011

Recent Posts

you have written code in util, is there any way,other than that??? clicking on any header displaying in ascending or descending
Tanweer .
RE: liferay-ui:search-container orderable ?
April 5, 2011 11:33 AM
Answer

Tanweer .

Rank: Expert

Posts: 319

Join Date: March 11, 2010

Recent Posts

venka reddy:
you have written code in util, is there any way,other than that??? clicking on any header displaying in ascending or descending


Venka,
You can achieve the same using the BeanComparator provided by Apache.Find the snippet below.
1import org.apache.commons.beanutils.BeanComparator
2      
3      BeanComparator comp = new BeanComparator("passSortingParameterHere");
4      Collections.sort(ListToBeSorted,comp);


You can call this API when the header is clicked and send the parameter with which you want to sort.

Hope this proves useful to you.
venka reddy
RE: liferay-ui:search-container orderable ?
April 6, 2011 3:49 AM
Answer

venka reddy

Rank: Regular Member

Posts: 231

Join Date: March 23, 2011

Recent Posts

hi Tanweer,

can we do sorting without using Bean Comparator provided by apache???
Oliver Bayer
RE: liferay-ui:search-container orderable ?
April 6, 2011 4:45 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi Venka,

you can also write your own comparator. Take a look at the existing *Comparator classes provided by Liferay e.g. ArticleIDComparator to see which methods you should implement.

HTH Oli