1 16 package org.apache.myfaces.custom.popup; 17 18 import javax.faces.component.UIComponentBase; 19 import javax.faces.component.UIComponent; 20 import javax.faces.el.ValueBinding; 21 import javax.faces.context.FacesContext; 22 23 27 public class HtmlPopup 28 extends UIComponentBase 29 { 30 32 private static final String POPUP_FACET_NAME = "popup"; 33 34 public void setPopup(UIComponent popup) 35 { 36 getFacets().put(POPUP_FACET_NAME, popup); 37 } 38 39 public UIComponent getPopup() 40 { 41 return (UIComponent)getFacets().get(POPUP_FACET_NAME); 42 } 43 44 public boolean getRendersChildren() 45 { 46 return true; 47 } 48 49 50 52 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPopup"; 53 public static final String COMPONENT_FAMILY = "javax.faces.Panel"; 54 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Popup"; 55 56 private String _style = null; 57 private String _styleClass = null; 58 private Integer _displayAtDistanceX = null; 59 private Integer _displayAtDistanceY = null; 60 private Boolean _closePopupOnExitingElement = null; 61 private Boolean _closePopupOnExitingPopup = null; 62 63 public HtmlPopup() 64 { 65 setRendererType(DEFAULT_RENDERER_TYPE); 66 } 67 68 public String getFamily() 69 { 70 return COMPONENT_FAMILY; 71 } 72 73 public void setStyle(String style) 74 { 75 _style = style; 76 } 77 78 public String getStyle() 79 { 80 if (_style != null) return _style; 81 ValueBinding vb = getValueBinding("style"); 82 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 83 } 84 85 public void setStyleClass(String styleClass) 86 { 87 _styleClass = styleClass; 88 } 89 90 public String getStyleClass() 91 { 92 if (_styleClass != null) return _styleClass; 93 ValueBinding vb = getValueBinding("styleClass"); 94 return vb != null ? (String )vb.getValue(getFacesContext()) : null; 95 } 96 97 public void setDisplayAtDistanceX(Integer displayAtDistanceX) 98 { 99 _displayAtDistanceX = displayAtDistanceX; 100 } 101 102 public Integer getDisplayAtDistanceX() 103 { 104 if (_displayAtDistanceX != null) return _displayAtDistanceX; 105 ValueBinding vb = getValueBinding("displayAtDistanceX"); 106 return vb != null ? (Integer )vb.getValue(getFacesContext()) : null; 107 } 108 109 public void setDisplayAtDistanceY(Integer displayAtDistanceY) 110 { 111 _displayAtDistanceY = displayAtDistanceY; 112 } 113 114 public Integer getDisplayAtDistanceY() 115 { 116 if (_displayAtDistanceY != null) return _displayAtDistanceY; 117 ValueBinding vb = getValueBinding("displayAtDistanceY"); 118 return vb != null ? (Integer )vb.getValue(getFacesContext()) : null; 119 } 120 121 public void setClosePopupOnExitingElement(Boolean closePopupOnExitingElement) 122 { 123 _closePopupOnExitingElement = closePopupOnExitingElement; 124 } 125 126 public Boolean getClosePopupOnExitingElement() 127 { 128 if (_closePopupOnExitingElement != null) return _closePopupOnExitingElement; 129 ValueBinding vb = getValueBinding("closePopupOnExitingElement"); 130 return vb != null ? (Boolean )vb.getValue(getFacesContext()) : null; 131 } 132 133 public void setClosePopupOnExitingPopup(Boolean closePopupOnExitingPopup) 134 { 135 _closePopupOnExitingPopup = closePopupOnExitingPopup; 136 } 137 138 public Boolean getClosePopupOnExitingPopup() 139 { 140 if (_closePopupOnExitingPopup != null) return _closePopupOnExitingPopup; 141 ValueBinding vb = getValueBinding("closePopupOnExitingPopup"); 142 return vb != null ? (Boolean )vb.getValue(getFacesContext()) : null; 143 } 144 145 146 147 public Object saveState(FacesContext context) 148 { 149 Object values[] = new Object [7]; 150 values[0] = super.saveState(context); 151 values[1] = _style; 152 values[2] = _styleClass; 153 values[3] = _displayAtDistanceX; 154 values[4] = _displayAtDistanceY; 155 values[5] = _closePopupOnExitingElement; 156 values[6] = _closePopupOnExitingPopup; 157 return ((Object ) (values)); 158 } 159 160 public void restoreState(FacesContext context, Object state) 161 { 162 Object values[] = (Object [])state; 163 super.restoreState(context, values[0]); 164 _style = (String )values[1]; 165 _styleClass = (String )values[2]; 166 _displayAtDistanceX = (Integer )values[3]; 167 _displayAtDistanceY = (Integer )values[4]; 168 _closePopupOnExitingElement = (Boolean )values[5]; 169 _closePopupOnExitingPopup = (Boolean )values[6]; 170 } 171 } 173 | Popular Tags |