1 33 34 package com.icesoft.faces.component.panelpopup; 35 36 import com.icesoft.faces.component.CSS_DEFAULT; 37 import com.icesoft.faces.component.ext.HtmlPanelGroup; 38 import com.icesoft.faces.component.ext.taglib.Util; 39 import com.icesoft.faces.context.effects.JavascriptContext; 40 41 import javax.faces.component.UIComponent; 42 import javax.faces.context.FacesContext; 43 import javax.faces.el.ValueBinding; 44 45 58 public class PanelPopup 59 extends HtmlPanelGroup { 60 63 public static final String COMPONENT_TYPE = "com.icesoft.faces.PanelPopup"; 64 67 public static final String DEFAULT_RENDERER_TYPE = 68 "com.icesoft.faces.PanelPopup"; 69 73 private static final boolean DEFAULT_RESIZABLE = false; 74 77 private static final boolean DEFAULT_MODAL = false; 78 81 private static final String HEADER_FACET = "header"; 82 85 private static final String BODY_FACET = "body"; 86 87 90 private String styleClass = null; 91 94 private String style = null; 95 98 private Boolean resizable = null; 99 102 private Boolean modal = null; 103 104 107 public PanelPopup() { 108 setRendererType(DEFAULT_RENDERER_TYPE); 109 JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS, 110 FacesContext.getCurrentInstance()); 111 } 112 113 115 118 public UIComponent getHeader() { 119 return (UIComponent) getFacet(HEADER_FACET); 120 } 121 122 125 public UIComponent getBody() { 126 return (UIComponent) getFacet(BODY_FACET); 127 } 128 129 132 public boolean isRendered() { 133 if (!Util.isRenderedOnUserRole(this)) { 134 return false; 135 } 136 return super.isRendered(); 137 } 138 139 140 143 public String getHeaderClass() { 144 return Util.getQualifiedStyleClass(this, 145 CSS_DEFAULT.POPUP_DEFAULT_HEADER_CLASS); 146 } 147 148 149 152 public String getBodyClass() { 153 return Util.getQualifiedStyleClass(this, 154 CSS_DEFAULT.POPUP_DEFAULT_BODY_CLASS); 155 } 156 157 158 161 public void setStyleClass(String styleClass) { 162 this.styleClass = styleClass; 163 } 164 165 168 public String getStyleClass() { 169 return Util.getQualifiedStyleClass(this, 170 styleClass, 171 CSS_DEFAULT.POPUP_BASE, 172 "styleClass"); 173 } 174 175 178 public String getStyle() { 179 if (style != null) { 180 return style; 181 } 182 ValueBinding vb = getValueBinding("style"); 183 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 184 } 185 186 189 public void setStyle(String style) { 190 this.style = style; 191 } 192 193 200 public boolean isResizable() { 201 return false; } 203 204 210 public void setResizable(boolean resizable) { 211 this.resizable = Boolean.valueOf(resizable); 212 } 213 214 217 public boolean isModal() { 218 if (modal != null) { 219 return modal.booleanValue(); 220 } 221 ValueBinding vb = getValueBinding("modal"); 222 Boolean boolVal = 223 vb != null ? (Boolean ) vb.getValue(getFacesContext()) : null; 224 return boolVal != null ? boolVal.booleanValue() : DEFAULT_MODAL; 225 } 226 227 230 public void setModal(boolean modal) { 231 this.modal = Boolean.valueOf(modal); 232 } 233 234 237 public Object saveState(FacesContext context) { 238 Object values[] = new Object [10]; 239 values[0] = super.saveState(context); 240 values[5] = styleClass; 241 values[6] = style; 242 values[7] = resizable; 243 values[8] = modal; 244 values[9] = title; 245 return ((Object ) (values)); 246 } 247 248 251 public void restoreState(FacesContext context, Object state) { 252 Object values[] = (Object []) state; 253 super.restoreState(context, values[0]); 254 styleClass = (String ) values[5]; 255 style = (String ) values[6]; 256 resizable = (Boolean ) values[7]; 257 modal = (Boolean ) values[8]; 258 title = (String ) values[9]; 259 } 260 261 private String title = null; 262 263 266 public void setTitle(String title) { 267 this.title = title; 268 } 269 270 273 public String getTitle() { 274 if (title != null) { 275 return title; 276 } 277 ValueBinding vb = getValueBinding("title"); 278 return vb != null ? (String ) vb.getValue(getFacesContext()) : null; 279 } 280 } | Popular Tags |