KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > containers > QuerySortOrderTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.bridge.jsp.taglib.containers;
11
12 import javax.servlet.jsp.JspTagException JavaDoc;
13
14 import org.mmbase.bridge.Query;
15 import org.mmbase.bridge.util.Queries;
16 import org.mmbase.bridge.jsp.taglib.CloudReferrerTag;
17 import org.mmbase.bridge.jsp.taglib.util.Attribute;
18 import org.mmbase.storage.search.*;
19 //import org.mmbase.util.logging.*;
20

21 /**
22  * Applies a sortorder to the surrounding query.
23  *
24  * @author Michiel Meeuwissen
25  * @since MMBase-1.7
26  * @version $Id: QuerySortOrderTag.java,v 1.5 2005/05/27 10:37:51 michiel Exp $
27  */

28 public class QuerySortOrderTag extends CloudReferrerTag implements QueryContainerReferrer {
29
30     //private static final Logger log = Logging.getLoggerInstance(QuerySortOrderTag.class);
31

32     protected Attribute container = Attribute.NULL;
33     protected Attribute direction = Attribute.NULL;
34     protected Attribute field = Attribute.NULL;
35     protected Attribute casesensitive = Attribute.NULL;
36
37     public void setContainer(String JavaDoc c) throws JspTagException JavaDoc {
38         container = getAttribute(c);
39     }
40
41     public void setDirection(String JavaDoc d) throws JspTagException JavaDoc {
42         direction = getAttribute(d);
43     }
44     public void setCasesensitive(String JavaDoc s) throws JspTagException JavaDoc {
45         casesensitive = getAttribute(s);
46     }
47     public void setField(String JavaDoc f) throws JspTagException JavaDoc {
48         field = getAttribute(f);
49     }
50
51
52     public int doStartTag() throws JspTagException JavaDoc {
53         QueryContainer c = (QueryContainer) findParentTag(QueryContainer.class, (String JavaDoc) container.getValue(this));
54         
55         Query query = c.getQuery();
56         int order = Queries.getSortOrder(direction.getString(this));
57         StepField stepField = query.createStepField(field.getString(this));
58                    
59         query.addSortOrder(stepField, order, casesensitive.getBoolean(this, false));
60         return SKIP_BODY;
61     }
62
63 }
64
Popular Tags