1 package albel.tags.table; 2 3 import javax.servlet.jsp.*; 4 import javax.servlet.*; 5 import javax.servlet.jsp.tagext.*; 6 import javax.servlet.http.*; 7 import albel.tags.table.utils.*; 8 import albel.tags.table.model.*; 9 import albel.tags.table.render.*; 10 import albel.tags.table.controll.*; 11 15 public class TableTag extends BodyTagSupport 16 { 17 18 21 private String id; 22 23 26 private String sourceBeanClass; 27 28 31 private String language; 32 33 36 private String country; 37 38 public TableTag() 39 { 40 super(); 41 } 42 43 44 52 53 61 public void otherDoStartTagOperations() 62 { 63 64 82 83 } 84 85 91 public boolean theBodyShouldBeEvaluated() 92 { 93 94 return true; 100 101 } 102 103 104 112 public void otherDoEndTagOperations() 113 { 114 115 123 124 } 125 126 133 public boolean shouldEvaluateRestOfPageAfterEndTag() 134 { 135 136 return true; 143 144 } 145 146 147 156 157 160 public int doStartTag() throws JspException 161 { 162 HttpServletRequest request=(HttpServletRequest)pageContext.getRequest(); 163 HttpSessionAttributesMap attrs=new HttpSessionAttributesMap(request.getSession()); 164 if(!Manager.tableExists(attrs,getId())) 165 { 166 Table table=Manager.createTable(attrs, id); 167 table.setSourceBeanClass(getSourceBeanClass()); 168 if(language!=null && country!=null) 169 { 170 java.util.Locale loc=new java.util.Locale (getLanguage(),getCountry()); 171 table.setLocale(loc); 172 } 173 } 174 return this.EVAL_BODY_INCLUDE; 175 } 176 177 178 181 public int doEndTag() throws JspException 182 { 183 HttpServletRequest request=(HttpServletRequest)pageContext.getRequest(); 184 HttpSessionAttributesMap attrsCtx=new HttpSessionAttributesMap(request.getSession()); 185 Table t=Manager.getTable(attrsCtx, getId()); 186 try 187 { 188 HttpRequestParametersMap reqPars=new HttpRequestParametersMap(request.getParameterMap()); 189 StateController.setupTableState(t, reqPars); 190 } 191 catch (albel.tags.table.model.TableTagException tex) 192 { 193 throw new JspException(tex); 194 } 195 ITableRenderer tableRend=Manager.getTableRenderer(t); 196 String html=tableRend.render().getRenderable().toString(); 197 Writer.write(pageContext, html); 198 return EVAL_PAGE; 201 } 202 203 207 public String getId() 208 { 209 return this.id; 210 } 211 212 216 public void setId(String id) 217 { 218 this.id = id; 219 } 220 221 225 public String getSourceBeanClass() 226 { 227 return this.sourceBeanClass; 228 } 229 230 234 public void setSourceBeanClass(String sourceBeanClass) 235 { 236 this.sourceBeanClass = sourceBeanClass; 237 } 238 239 243 public String getLanguage() 244 { 245 return this.language; 246 } 247 248 252 public void setLanguage(String language) 253 { 254 this.language = language; 255 } 256 257 261 public String getCountry() 262 { 263 return this.country; 264 } 265 266 270 public void setCountry(String country) 271 { 272 this.country = country; 273 } 274 275 } 276 | Popular Tags |