1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.contrib.table.model.ognl; |
16 | |
|
17 | |
import org.apache.commons.logging.Log; |
18 | |
import org.apache.commons.logging.LogFactory; |
19 | |
import org.apache.tapestry.contrib.table.model.ITableColumn; |
20 | |
import org.apache.tapestry.contrib.table.model.simple.ITableColumnEvaluator; |
21 | |
import org.apache.tapestry.services.ExpressionEvaluator; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class OgnlTableColumnEvaluator implements ITableColumnEvaluator |
27 | |
{ |
28 | |
|
29 | |
private static final long serialVersionUID = 1L; |
30 | |
|
31 | 0 | private static final Log LOG = LogFactory.getLog(OgnlTableColumnEvaluator.class); |
32 | |
|
33 | |
|
34 | |
|
35 | |
private ExpressionEvaluator _expressionEvaluator; |
36 | |
|
37 | |
private String m_strExpression; |
38 | |
|
39 | |
public OgnlTableColumnEvaluator(String strExpression, |
40 | |
ExpressionEvaluator expressionEvaluator) |
41 | 0 | { |
42 | 0 | m_strExpression = strExpression; |
43 | 0 | _expressionEvaluator = expressionEvaluator; |
44 | 0 | } |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
public synchronized Object getColumnValue(ITableColumn objColumn, |
51 | |
Object objRow) |
52 | |
{ |
53 | |
|
54 | |
|
55 | 0 | if (m_strExpression == null || m_strExpression.equals("")) return ""; |
56 | |
|
57 | |
try |
58 | |
{ |
59 | 0 | return _expressionEvaluator.read(objRow, m_strExpression); |
60 | |
} |
61 | 0 | catch (Exception e) |
62 | |
{ |
63 | 0 | LOG.error("Cannot use column expression '" + m_strExpression |
64 | |
+ "' in row", e); |
65 | 0 | return ""; |
66 | |
} |
67 | |
} |
68 | |
} |