KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > contrib > table > model > sql > SqlTableColumn


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.contrib.table.model.sql;
16
17 import java.sql.ResultSet JavaDoc;
18 import java.sql.SQLException JavaDoc;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn;
23
24 /**
25  *
26  * @author mindbridge
27  */

28 public class SqlTableColumn extends SimpleTableColumn
29 {
30     private static final long serialVersionUID = 1L;
31     private static final Log LOG = LogFactory.getLog(SqlTableColumn.class);
32
33     /**
34      * Creates an SqlTableColumn
35      * @param strSqlField the identifying name of the column and the SQL field it refers to
36      * @param strDisplayName the display name of the column
37      */

38     public SqlTableColumn(String JavaDoc strSqlField, String JavaDoc strDisplayName)
39     {
40         super(strSqlField, strDisplayName);
41     }
42
43     /**
44      * Creates an SqlTableColumn
45      * @param strSqlField the identifying name of the column and the SQL field it refers to
46      * @param strDisplayName the display name of the column
47      * @param bSortable whether the column is sortable
48      */

49     public SqlTableColumn(
50         String JavaDoc strSqlField,
51         String JavaDoc strDisplayName,
52         boolean bSortable)
53     {
54         super(strSqlField, strDisplayName, bSortable);
55     }
56
57     /**
58      * @see org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn#getColumnValue(Object)
59      */

60     public Object JavaDoc getColumnValue(Object JavaDoc objRow)
61     {
62         try
63         {
64             ResultSet JavaDoc objRS = (ResultSet JavaDoc) objRow;
65             String JavaDoc strColumnName = getColumnName();
66             Object JavaDoc objValue = objRS.getObject(strColumnName);
67             if (objValue == null)
68                 objValue = "";
69             return objValue;
70         }
71         catch (SQLException JavaDoc e)
72         {
73             LOG.error("Cannot get the value for column: " + getColumnName(), e);
74             return "";
75         }
76     }
77
78 }
79
Popular Tags