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.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
24  import org.extremecomponents.table.ExportAttributes;
25  import org.extremecomponents.table.bean.Export;
26  
27  
28  
29  /***
30   * Append any attributes to the Sorting, Filtering, Pagination, and Form Submission.
31   * On the URL's will resolve to &name=value.
32   * On the <form> attribute will be added as hidden fields
33   * <input type=hidden name= value=>
34   *
35   * @author Jeff Johnston
36   */
37  public class ExportTag extends BodyTagSupport implements ExportAttributes
38  {
39  	private static Log logger = LogFactory.getLog(ExportTag.class);
40  	
41  	private String name;
42  	private String view;
43  	private String title;
44  	private String description;
45  	private String headerColor;
46  	private String headerBackgroundColor;
47  
48  	public String getName()
49  	{
50  		return name;
51  	}
52  
53  	public void setName(String name)
54  	{
55  		this.name = name;
56  	}
57  
58  	public String getView()
59  	{
60  		return view;
61  	}
62  
63  	public void setView(String view)
64  	{
65  		this.view = view;
66  	}
67  
68  	public String getTitle()
69  	{
70  		return title;
71  	}
72  
73  	public void setTitle(String title)
74  	{
75  		this.title = title;
76  	}
77  
78  	public String getDescription()
79  	{
80  		return description;
81  	}
82  
83  	public void setDescription(String description)
84  	{
85  		this.description = description;
86  	}
87  
88  	public String getHeaderColor()
89  	{
90  		return headerColor;
91  	}
92  
93  	public void setHeaderColor(String headerColor)
94  	{
95  		this.headerColor = headerColor;
96  	}
97  
98  	public String getHeaderBackgroundColor()
99  	{
100 		return headerBackgroundColor;
101 	}
102 
103 	public void setHeaderBackgroundColor(String headerBackgroundColor)
104 	{
105 		this.headerBackgroundColor = headerBackgroundColor;
106 	}
107 
108 	public int doEndTag()
109 		throws JspException
110 	{
111 		TableTag tableTag = (TableTag) findAncestorWithClass(this, TableTag.class);
112 
113 		if (tableTag.getModelRowsSize() > 0) //only go through the first pass
114 		{
115 			return EVAL_PAGE;
116 		}
117 		
118 		if (name != null)
119 		{
120 			name = (String) ExpressionEvaluatorManager.evaluate("name", name, java.lang.String.class, pageContext);
121 		}
122 		
123 		if (title != null)
124 		{
125 			title = (String) ExpressionEvaluatorManager.evaluate("title", title, java.lang.String.class, pageContext);
126 		}
127 
128 		Export export = new Export(tableTag.getModel());
129 		export.setName(name);
130 		export.setView(view);
131 		export.setTitle(title);
132 		export.setDescription(description);
133 		export.setHeaderColor(headerColor);
134 		export.setHeaderBackgroundColor(headerBackgroundColor);
135 		tableTag.addExport(export);
136 		
137 		cleanup();
138 
139 		return EVAL_PAGE;
140 	}
141 	
142 	public void cleanup()
143 	{
144 		name = null;
145 		view = null;
146 		title = null;
147 		description = null;
148 		headerColor = null;
149 		headerBackgroundColor = null;
150 	}	
151 }