1 16 package org.apache.myfaces.wap.base; 17 18 import javax.faces.component.UIComponent; 19 import javax.faces.context.FacesContext; 20 import javax.faces.el.ValueBinding; 21 import javax.faces.webapp.UIComponentTag; 22 23 38 39 public abstract class ComponentTagBase extends UIComponentTag { 40 41 42 private String id = null; 43 private String rendered = null; 44 private String binding = null; 45 46 47 public ComponentTagBase() { 48 super(); 49 } 50 51 public abstract String getRendererType(); 52 53 public void release() { 54 super.release(); 55 this.id = null; 56 this.rendered = null; 57 this.binding = null; 58 } 59 60 protected void setProperties(UIComponent component) { 61 super.setProperties(component); 62 63 if (getRendererType() != null) { 64 component.setRendererType(getRendererType()); 65 } 66 67 if (id != null) { 68 if (isValueReference(id)) { 69 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(id); 70 component.setValueBinding("id", vb); 71 } else { 72 component.setId(id); 73 } 74 } 75 76 if (rendered != null) { 77 if (isValueReference(rendered)) { 78 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(rendered); 79 component.setValueBinding("rendered", vb); 80 } else { 81 boolean bool = Boolean.valueOf(rendered).booleanValue(); 82 component.setRendered(bool); 83 } 84 } 85 86 if (binding != null) { 87 if (isValueReference(binding)) { 88 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(binding); 89 component.setValueBinding("binding", vb); 90 } else { 91 throw new IllegalArgumentException ("Not a valid binding: " + binding); 92 } 93 } 94 } 95 97 101 public String getId() { 102 return id; 103 } 104 105 109 public void setId(String id) { 110 this.id = id; 111 } 112 116 public String getRendered() { 117 return rendered; 118 } 119 120 124 public void setRendered(String rendered) { 125 this.rendered = rendered; 126 } 127 128 132 public void setBinding(String binding) { 133 if (!isValueReference(binding)) { 134 throw new IllegalArgumentException ("Not a valid binding: " + binding); 135 } 136 this.binding = binding; 137 } 138 } 139 | Popular Tags |