View Javadoc

1   /*
2    * Copyright 2004 Jeff Johnston
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.extremecomponents.table.tag;
17  
18  import javax.servlet.jsp.JspException;
19  import javax.servlet.jsp.tagext.BodyTagSupport;
20  
21  import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
22  
23  
24  /***
25   * Override/Add properties to the table.
26   *
27   * @author Jeff Johnston
28   */
29  public class PropertyTag extends BodyTagSupport
30  {
31  	private String name;
32  	private String value;
33  
34  	public String getName()
35  	{
36  		return name;
37  	}
38  
39  	public void setName(String name)
40  	{
41  		this.name = name;
42  	}
43  
44  	public String getValue()
45  	{
46  		return value;
47  	}
48  
49  	public void setValue(String value)
50  	{
51  		this.value = value;
52  	}
53  
54  	public int doEndTag()
55  		throws JspException
56  	{
57  		TableTag tableTag = (TableTag) findAncestorWithClass(this, TableTag.class);
58  
59  		if (tableTag.getModelRowsSize() > 0) //only go through the first pass
60  		{
61  			return EVAL_PAGE;
62  		}
63  
64  		if (this.bodyContent != null) //have a body
65  		{
66  			value = getBodyContent().getString();
67  		}
68  
69  		if (value != null)
70  		{
71  			value = (String) ExpressionEvaluatorManager.evaluate("value", value.toString(), String.class, this, pageContext);
72  		}
73  
74  		tableTag.addProperty(name, value);
75  
76  		cleanup();
77  
78  		return EVAL_PAGE;
79  	}
80  	
81  	public void cleanup()
82  	{
83  		name = null;
84  		value = null;
85  		setBodyContent(null);
86  	}	
87  }