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   * Append any attributes to the Sorting, Filtering, Pagination, and Form Submission.
26   * On the URL's will resolve to &name=value.
27   * On the <form> attribute will be added as hidden fields
28   * <input type=hidden name= value=>
29   *
30   * @author Jeff Johnston
31   */
32  public class ParameterTag extends BodyTagSupport
33  {
34  	private String name;
35  	private String value;
36  
37  	public String getName()
38  	{
39  		return name;
40  	}
41  
42  	public void setName(String name)
43  	{
44  		this.name = name;
45  	}
46  
47  	public String getValue()
48  	{
49  		return value;
50  	}
51  
52  	public void setValue(String value)
53  	{
54  		this.value = value;
55  	}
56  
57  	public int doEndTag()
58  		throws JspException
59  	{
60  		TableTag tableTag = (TableTag) findAncestorWithClass(this, TableTag.class);
61  
62  		if (tableTag.getModelRowsSize() > 0) //only go through the first pass
63  		{
64  			return EVAL_PAGE;
65  		}
66  
67  		if (this.bodyContent != null) //have a body
68  		{
69  			value = getBodyContent().getString();
70  		}
71  
72  		if (value != null)
73  		{
74  			value = (String) ExpressionEvaluatorManager.evaluate("value", value.toString(), String.class, this, pageContext);
75  		}
76  
77  		tableTag.addParameter(name, value);
78  
79  		cleanup();
80  
81  		return EVAL_PAGE;
82  	}
83  	
84  	public void cleanup()
85  	{
86  		name = null;
87  		value = null;
88  		setBodyContent(null);
89  	}	
90  }