1 16 package org.apache.myfaces.custom.div; 17 18 import javax.faces.component.UIOutput; 19 import javax.faces.context.FacesContext; 20 import javax.faces.el.ValueBinding; 21 22 import org.apache.myfaces.component.html.util.HtmlComponentUtils; 23 24 35 public class Div extends UIOutput { 36 public static final String COMPONENT_TYPE = "org.apache.myfaces.Div"; 37 public static final String COMPONENT_FAMILY = "javax.faces.Output"; 38 private static final String DEFAULT_RENDERER_TYPE = DivRenderer.RENDERER_TYPE; 39 40 private String _style = null; 41 private String _styleClass = null; 42 43 public Div() { 45 setRendererType(DEFAULT_RENDERER_TYPE); 46 } 47 48 public String getFamily() { 49 return COMPONENT_FAMILY; 50 } 51 52 public String getClientId(FacesContext context) 53 { 54 String clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context); 55 if (clientId == null) 56 { 57 clientId = super.getClientId(context); 58 } 59 60 return clientId; 61 } 62 63 public String getStyle() { 64 if (_style != null) 65 return _style; 66 ValueBinding vb = getValueBinding("style"); 67 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 68 } 69 70 public void setStyle(String style) { 71 this._style = style; 72 } 73 74 public String getStyleClass() { 75 if (_styleClass != null) 76 return _styleClass; 77 ValueBinding vb = getValueBinding("styleClass"); 78 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 79 } 80 81 public void setStyleClass(String styleClass) { 82 this._styleClass = styleClass; 83 } 84 85 public void restoreState(FacesContext context, Object state) { 86 Object values[] = (Object []) state; 87 super.restoreState(context, values[0]); 88 _style = (String ) values[1]; 89 _styleClass = (String ) values[2]; 90 } 91 92 public Object saveState(FacesContext context) { 93 Object values[] = new Object [3]; 94 values[0] = super.saveState(context); 95 values[1] = _style; 96 values[2] = _styleClass; 97 return values; 98 } 99 } | Popular Tags |