View Javadoc

1   /** ------------------------------------
2    * SweetDEV RIA library
3    * Copyright [2006 - 2010] [Ideo Technologies]
4    * ------------------------------------
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * 		http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   *
18   *
19   * For more information, please contact us at:
20   *         Ideo Technologies S.A
21   *        124 rue de Verdun
22   *        92800 Puteaux - France
23   *
24   *      France & Europe Phone : +33 1.46.25.09.60
25   *
26   *
27   *        web : http://www.ideotechnologies.com
28   *        email : SweetDEV-RIA@ideotechnologies.com
29   *
30   *
31   * @version ${pom.version}
32   * @author Ideo Technologies
33   */
34  package com.ideo.sweetdevria.taglib.spliterLayout;
35  
36  import javax.servlet.jsp.JspException;
37  import javax.servlet.jsp.JspTagException;
38  import javax.servlet.jsp.PageContext;
39  
40  import com.ideo.sweetdevria.taglib.BaseTagSupport;
41  import com.ideo.sweetdevria.taglib.Hideable;
42  import com.ideo.sweetdevria.taglib.IRiaTag;
43  
44  /**
45   * @jsp.tag name = "slcolumn" display-name = "Spliter Layout's Column"
46   *          description = "Description : Split a spliterLayout part in 2 columns  
47   *      Nested in tag : <b>ria:spliterlayout</b>
48   * "
49   */
50  public class SpliterColumnTag extends BaseTagSupport implements IRiaTag, Hideable {
51  	private static final long serialVersionUID = -6774387161515291298L;
52  
53  	protected static final String BUILDER_ID = "spliterlayout.column.builder";
54  
55  	protected boolean rendered = true;
56  
57  	protected String width = "100%";
58  
59  	protected boolean spliter = false;
60  
61  	protected SpliterLayoutTag parent = null;
62  	protected String spliterStyle = null;
63  	protected String spliterStyleClass = null;
64  	protected int cellIndex = 0;
65  	
66  	
67  	public SpliterColumnTag() {
68  		release();
69  	}
70  
71  	public int doStartTag() throws JspException {
72  		try{
73  			parent = (SpliterLayoutTag) getParent();
74  		}
75  		catch (ClassCastException e) {
76  		}
77  		if (parent == null) {
78  			throw new JspTagException("Spliter Layout Column Tag without Spliter Layout Tag");
79  		}
80  		spliter = parent.showSpliter();
81  		id = parent.addColumn();
82  		spliterStyle = parent.getSpliterStyle();
83  		spliterStyleClass = parent.getSpliterStyleClass();
84  		super.doStartTag();
85  		return EVAL_BODY_INCLUDE;
86  	}
87  
88  	public PageContext getPageContext() {
89  		return pageContext;
90  	}
91  
92  	public void release() {
93  		rendered = true;
94  		width = "100%";
95  		spliter = false;
96  		parent = null;
97  		spliterStyle = null;
98  		spliterStyleClass = null;
99  		cellIndex = 0;
100 		super.release();
101 	}
102 
103 	public boolean isRendered() {
104 		return this.rendered;
105 	}
106 
107 	/**
108 	 * @jsp.attribute required="false" rtexprvalue="true" type="boolean"
109 	 *                description="Visible or not (default true) ?"
110 	 */
111 	public void setRendered(boolean rendered) {
112 		this.rendered = rendered;
113 	}
114 
115 	public String getWidth() {
116 		return width;
117 	}
118 
119 	/**
120 	 * @jsp.attribute required="false" rtexprvalue="true" type="java.lang.String"
121 	 *                description="Spliter Layout Column's width (100% by
122 	 *                default)"
123 	 */
124 	public void setWidth(String width) {
125 		this.width = width;
126 	}
127 
128 	public String getBuilderId() {
129 		return SpliterColumnTag.BUILDER_ID;
130 	}
131 
132 	public boolean isSpliter() {
133 		return spliter;
134 	}
135 
136 	public void setSpliter(boolean spliter) {
137 		this.spliter = spliter;
138 	}
139 
140 	public String getSpliterStyle() {
141 		return spliterStyle;
142 	}
143 
144 	public String getSpliterStyleClass() {
145 		return spliterStyleClass;
146 	}
147 
148 	public void setSpliterStyle(String spliterStyle) {
149 		this.spliterStyle = spliterStyle;
150 	}
151 
152 	public void setSpliterStyleClass(String spliterStyleClass) {
153 		this.spliterStyleClass = spliterStyleClass;
154 	}
155 
156 	public SpliterLayoutTag getLayout() {
157 		return parent;
158 	}
159 
160 	public int getCellIndex() {
161 		return cellIndex;
162 	}
163 
164 	public void setCellIndex(int cellIndex) {
165 		this.cellIndex = cellIndex;
166 	}
167 	
168 	public boolean showSpliter() {
169 		return (cellIndex>0?true:false);
170 	}	
171 }