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.TagSupport;
20  
21  import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
22  import org.extremecomponents.table.InputAttributes;
23  import org.extremecomponents.table.bean.Input;
24  
25  
26  
27  /***
28   * @author jeff johnston
29   */
30  public class InputTag extends TagSupport implements InputAttributes
31  {
32  	private String type;
33  	private String name;
34  	private String value;
35  	private String onclick;
36  
37  	public String getType()
38  	{
39  		return type;
40  	}
41  
42  	public void setType(String type)
43  	{
44  		this.type = type;
45  	}
46  
47  	public String getName()
48  	{
49  		return name;
50  	}
51  
52  	public void setName(String name)
53  	{
54  		this.name = name;
55  	}
56  
57  	public String getValue()
58  	{
59  		return value;
60  	}
61  
62  	public void setValue(String value)
63  	{
64  		this.value = value;
65  	}
66  
67  	public String getOnclick()
68  	{
69  		return onclick;
70  	}
71  
72  	public void setOnclick(String onclick)
73  	{
74  		this.onclick = onclick;
75  	}
76  
77  	public int doEndTag()
78  		throws JspException
79  	{
80  		TableTag tableTag = (TableTag) findAncestorWithClass(this, TableTag.class);
81  		
82  		if (value != null)
83  		{
84  			value = (String) ExpressionEvaluatorManager.evaluate("value", value, String.class, this, pageContext);
85  		}
86  
87  		Input input = new Input(tableTag.getModel()); //first create the input
88  		input.setType(type); 
89  		input.setName(name);
90  		input.setValue(value);
91  		input.setOnclick(onclick);
92  		tableTag.addInput(input);
93  		
94  		cleanup();
95  
96  		return EVAL_PAGE;
97  	}
98  	
99  	public void cleanup()
100 	{
101 		type = null; 
102 		name = null;
103 		value = null;
104 		onclick = null;
105 	}	
106 }