1 21 22 package org.opensubsystems.patterns.scrollabletable.www; 23 24 import java.util.Properties ; 25 26 import javax.servlet.jsp.JspException ; 27 import javax.servlet.jsp.tagext.BodyContent ; 28 29 import org.opensubsystems.core.util.Config; 30 import org.opensubsystems.core.www.BlockElementTag; 31 import org.opensubsystems.core.www.TagUtils; 32 33 43 public class ScrollableTableTag extends BlockElementTag 44 { 45 47 51 public static final String WEBUI_LIST_CHECK = "oss.webui.list.check"; 52 53 57 public static final String WEBUI_LIST_SORTABLE = "oss.webui.list.sortable"; 58 59 61 65 public static final boolean WEBUI_LIST_CHECK_DEFAULT = true; 66 67 70 public static final boolean WEBUI_LIST_SORTABLE_DEFAULT = true; 71 72 76 public static final String ACTIVE_SCROLLABLE_TABLE_ID = "activescrollabletableid"; 77 78 82 public static final String SCROLLABLE_TABLE_CHECK = "scrollabletablecheck"; 83 84 87 public static final String SCROLLABLE_TABLE_SORTABLE = "scrollabletablesortable"; 88 89 92 public static final String SCROLLABLE_TABLE_ROW_LIMIT = "scrollabletablerowlimit"; 93 94 97 public static final String SCROLLABLE_TABLE_PREFIX = "unknowntableid"; 98 99 101 104 private static final long serialVersionUID = 3264660649363019353L; 105 106 113 protected String m_strCheck; 114 115 119 protected String m_strSortable; 120 121 126 protected String m_strLimit; 127 128 130 133 public ScrollableTableTag() 134 { 135 super("clsEmbeddedListDynamic", BlockElementTag.DIV_BLOCK_ELEMENT); 138 139 Properties prpSettings; 143 144 prpSettings = Config.getInstance().getPropertiesSafely(); 145 m_strCheck = Config.getBooleanPropertyAsString( 146 prpSettings, 147 WEBUI_LIST_CHECK, 148 WEBUI_LIST_CHECK_DEFAULT, 149 "Flag allowing for scrollable tables to have checkbox" 150 + " in each line"); 151 152 m_strSortable = Config.getBooleanPropertyAsString( 153 prpSettings, 154 WEBUI_LIST_SORTABLE, 155 WEBUI_LIST_SORTABLE_DEFAULT, 156 "Flag allowing for scrollable tables to be sortable" 157 + " using column headings"); 158 159 m_strLimit = ""; 160 } 161 162 164 167 public int doStartTag( 168 ) throws JspException 169 { 170 super.doStartTag(); 171 172 cache(ACTIVE_SCROLLABLE_TABLE_ID, m_strId); 175 cache(SCROLLABLE_TABLE_CHECK, m_strCheck); 177 cache(SCROLLABLE_TABLE_SORTABLE, m_strSortable); 179 cache(SCROLLABLE_TABLE_ROW_LIMIT, m_strLimit); 181 182 return (EVAL_BODY_BUFFERED); 183 } 184 185 188 public int doEndTag( 189 ) throws JspException 190 { 191 BodyContent content = getBodyContent(); 196 StringBuffer sbContent = new StringBuffer (); 197 sbContent.append(content.getString()); 198 String strContent; 199 200 if ((m_strLimit != null) && (m_strLimit.length() > 0)) 201 { 202 sbContent.append("<input type=\"hidden\" id=\""); 205 sbContent.append(m_strId); 206 sbContent.append("limit\" value=\""); 207 sbContent.append(m_strLimit); 208 sbContent.append("\">"); 209 } 210 strContent = sbContent.toString(); 211 212 if (content != null) 213 { 214 strContent = strContent.replaceAll(SCROLLABLE_TABLE_PREFIX , m_strId); 215 } 216 218 getCachedContent(ACTIVE_SCROLLABLE_TABLE_ID, true); 220 getCachedContent(ScrollableTableTag.SCROLLABLE_TABLE_CHECK, true); 222 getCachedContent(ScrollableTableTag.SCROLLABLE_TABLE_SORTABLE, true); 224 225 TagUtils.write(pageContext, strContent); 226 227 super.doEndTag(); 228 229 return (EVAL_PAGE); 230 } 231 232 238 public String getCheck( 239 ) 240 { 241 return m_strCheck; 242 } 243 244 250 public void setCheck( 251 String strCheck 252 ) 253 { 254 m_strCheck = strCheck; 255 } 256 257 263 public void setCheck( 264 boolean bCheck 265 ) 266 { 267 m_strCheck = Boolean.toString(bCheck); 268 } 269 270 276 public boolean isCheckActive( 277 ) 278 { 279 return ((Boolean.TRUE.toString().equalsIgnoreCase(m_strCheck)) 280 || ("1".equals(m_strCheck))); 281 } 282 283 286 public String getSortable( 287 ) 288 { 289 return m_strSortable; 290 } 291 292 295 public void setSortable( 296 String strSortable 297 ) 298 { 299 m_strSortable = strSortable; 300 } 301 302 305 public void setSortable( 306 boolean bSortable 307 ) 308 { 309 m_strSortable = Boolean.toString(bSortable); 310 } 311 312 315 public boolean isSortableActive( 316 ) 317 { 318 return ((Boolean.TRUE.toString().equalsIgnoreCase(m_strSortable)) 319 || ("1".equals(m_strSortable))); 320 } 321 322 325 public String getLimit( 326 ) 327 { 328 return m_strLimit; 329 } 330 331 334 public void setLimit( 335 String strLimit 336 ) 337 { 338 m_strLimit = strLimit; 339 } 340 } 341 | Popular Tags |