KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > sqltable > SqlTableOrderByTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.sqltable;
14
15 import java.io.IOException JavaDoc;
16
17 import javax.servlet.jsp.JspException JavaDoc;
18
19 import com.tonbeller.tbutils.res.Resources;
20
21 /**
22  * @author av
23  * @since Oct 6, 2004
24  */

25 public class SqlTableOrderByTag extends SqlTableNestedTag {
26   public int doStartTag() throws JspException JavaDoc {
27     SqlTable table = getTable();
28     String JavaDoc column = table.getOrderBy();
29     String JavaDoc nested = table.getNestedOrderBy();
30     Resources res = getResources();
31     String JavaDoc sql;
32     if (table.isDescending())
33       sql = res.getString("sqltable.orderby.desc", column);
34     else
35       sql = res.getString("sqltable.orderby.asc", column);
36     
37     // nested == "COLUMN" or "COLUMN DESC"
38
if (nested != null && !nested.startsWith(column))
39       sql = sql + "," + nested;
40     
41     try {
42       pageContext.getOut().print(sql);
43     } catch (IOException JavaDoc e) {
44       throw new JspException JavaDoc(e);
45     }
46     return super.doStartTag();
47   }
48
49 }
50
Popular Tags