1 38 39 package org.apache.cocoon.faces.samples.components.taglib; 40 41 42 import org.apache.cocoon.faces.FacesUtils; 43 import org.apache.cocoon.faces.taglib.UIComponentTag; 44 import org.apache.cocoon.faces.samples.components.components.MapComponent; 45 import org.apache.cocoon.faces.samples.components.renderkit.Util; 46 import org.apache.commons.lang.BooleanUtils; 47 48 import javax.faces.component.UIComponent; 49 import javax.faces.context.FacesContext; 50 import javax.faces.el.MethodBinding; 51 import javax.faces.el.ValueBinding; 52 import javax.faces.event.ActionEvent; 53 54 55 58 59 public class MapTag extends UIComponentTag { 60 61 62 private String current = null; 63 64 65 public void setCurrent(String current) { 66 this.current = current; 67 } 68 69 70 private String actionListener = null; 71 72 73 public void setActionListener(String actionListener) { 74 this.actionListener = actionListener; 75 } 76 77 78 private String action = null; 79 80 81 public void setAction(String action) { 82 this.action = action; 83 } 84 85 86 private String immediate = null; 87 88 89 public void setImmediate(String immediate) { 90 this.immediate = immediate; 91 } 92 93 94 private String styleClass = null; 95 96 97 public void setStyleClass(String styleClass) { 98 this.styleClass = styleClass; 99 } 100 101 102 public String getComponentType() { 103 return ("DemoMap"); 104 } 105 106 107 public String getRendererType() { 108 return ("DemoMap"); 109 } 110 111 112 public void recycle() { 113 super.recycle(); 114 current = null; 115 styleClass = null; 116 actionListener = null; 117 action = null; 118 immediate = null; 119 styleClass = null; 120 } 121 122 123 protected void setProperties(UIComponent component) { 124 super.setProperties(component); 125 MapComponent map = (MapComponent) component; 126 if (styleClass != null) { 130 if (FacesUtils.isExpression(styleClass)) { 131 ValueBinding vb = FacesContext.getCurrentInstance() 132 .getApplication(). 133 createValueBinding(styleClass); 134 map.setValueBinding("styleClass", vb); 135 } else { 136 map.getAttributes().put("styleClass", styleClass); 137 } 138 } 139 if (actionListener != null) { 140 if (FacesUtils.isExpression(actionListener)) { 141 Class args[] = {ActionEvent.class}; 142 MethodBinding mb = FacesContext.getCurrentInstance() 143 .getApplication() 144 .createMethodBinding(actionListener, args); 145 map.setActionListener(mb); 146 } else { 147 Object params [] = {actionListener}; 148 throw new javax.faces.FacesException(); 149 } 150 } 151 152 if (action != null) { 153 if (FacesUtils.isExpression(action)) { 154 MethodBinding vb = FacesContext.getCurrentInstance() 155 .getApplication() 156 .createMethodBinding(action, null); 157 map.setAction(vb); 158 } else { 159 map.setAction(Util.createConstantMethodBinding(action)); 160 } 161 } 162 if (immediate != null) { 163 if (FacesUtils.isExpression(immediate)) { 164 ValueBinding vb = FacesContext.getCurrentInstance() 165 .getApplication(). 166 createValueBinding(immediate); 167 map.setValueBinding("immediate", vb); 168 } else { 169 map.setImmediate(BooleanUtils.toBoolean(immediate)); 170 } 171 } 172 173 } 174 175 176 } 177 | Popular Tags |