|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SqlTableColumn.java | 0% | 0% | 0% | 0% |
|
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; | |
18 | import java.sql.SQLException; | |
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 | 0 | public SqlTableColumn(String strSqlField, String strDisplayName) |
39 | { | |
40 | 0 | 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 | 0 | public SqlTableColumn( |
50 | String strSqlField, | |
51 | String strDisplayName, | |
52 | boolean bSortable) | |
53 | { | |
54 | 0 | super(strSqlField, strDisplayName, bSortable); |
55 | } | |
56 | ||
57 | /** | |
58 | * @see org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn#getColumnValue(Object) | |
59 | */ | |
60 | 0 | public Object getColumnValue(Object objRow) |
61 | { | |
62 | 0 | try |
63 | { | |
64 | 0 | ResultSet objRS = (ResultSet) objRow; |
65 | 0 | String strColumnName = getColumnName(); |
66 | 0 | Object objValue = objRS.getObject(strColumnName); |
67 | 0 | if (objValue == null) |
68 | 0 | objValue = ""; |
69 | 0 | return objValue; |
70 | } | |
71 | catch (SQLException e) | |
72 | { | |
73 | 0 | LOG.error("Cannot get the value for column: " + getColumnName(), e); |
74 | 0 | return ""; |
75 | } | |
76 | } | |
77 | ||
78 | } |
|