001 package edu.nrao.sss.webapp.faces.tag; 002 003 import javax.faces.application.Application; 004 import javax.faces.webapp.UIComponentTag; 005 import javax.faces.component.UIComponent; 006 import javax.faces.el.ValueBinding; 007 import javax.faces.context.FacesContext; 008 009 import org.apache.log4j.Logger; 010 011 public class ColumnTag extends UIComponentTag 012 { 013 private static final Logger log = Logger.getLogger(ColumnTag.class); 014 private String colspan = null, 015 styleClass = null; 016 017 // Associate the renderer and component type. Same type as recorded in 018 // faces-config.xml. 019 public String getComponentType() { return "edu.nrao.sss.Column"; } 020 public String getRendererType() { return null; } 021 022 023 @SuppressWarnings("unchecked") 024 protected void setProperties(UIComponent component) 025 { 026 //This takes care of the rendered attribute for us. 027 super.setProperties(component); 028 029 FacesContext context = FacesContext.getCurrentInstance(); 030 Application app = context.getApplication(); 031 032 // set colspan 033 if (colspan != null) 034 { 035 if (isValueReference(colspan)) 036 { 037 ValueBinding vb = app.createValueBinding(colspan); 038 component.setValueBinding("colspan", vb); 039 } 040 041 else 042 { 043 component.getAttributes().put("colspan", colspan); 044 } 045 } 046 047 // set styleClass 048 if (styleClass != null) 049 { 050 if (isValueReference(styleClass)) 051 { 052 ValueBinding vb = app.createValueBinding(styleClass); 053 component.setValueBinding("styleClass", vb); 054 } 055 056 else 057 { 058 component.getAttributes().put("styleClass", styleClass); 059 } 060 } 061 } 062 063 /** 064 * clear up any resources we've used. 065 */ 066 public void release() 067 { 068 super.release(); 069 colspan = null; 070 styleClass = null; 071 } 072 073 /** 074 * Bean method for our colspan attribute. 075 */ 076 public void setColspan(String span) 077 { 078 this.colspan = span; 079 } 080 081 public void setStyleClass(String c) 082 { 083 this.styleClass = c; 084 } 085 }