001 package edu.nrao.sss.webapp.faces.tag; 002 003 import javax.faces.webapp.UIComponentTag; 004 import javax.faces.component.UIComponent; 005 import javax.faces.context.FacesContext; 006 import javax.faces.application.Application; 007 import javax.faces.el.ValueBinding; 008 import javax.faces.el.ReferenceSyntaxException; 009 010 import edu.nrao.sss.webapp.faces.component.GraphicalSelectorUIComponent; 011 012 public class GraphicalSelectorTag extends UIComponentTag 013 { 014 public String getComponentType() { return "edu.nrao.sss.GraphicalSelector"; } 015 public String getRendererType() { return null; } 016 017 private String value = null, 018 map = null, 019 styleClass = null, 020 selectedBorderStyle = null, 021 highlightedBorderStyle = null, 022 unhighlightedBorderStyle = null; 023 024 @SuppressWarnings("unchecked") 025 protected void setProperties(UIComponent component) 026 { 027 super.setProperties(component); 028 029 FacesContext context = FacesContext.getCurrentInstance(); 030 Application app = context.getApplication(); 031 032 if (value != null) 033 { 034 if (isValueReference(value)) 035 { 036 ValueBinding vb = app.createValueBinding(value); 037 038 component.setValueBinding("value", vb); 039 } 040 041 else 042 { 043 throw new ReferenceSyntaxException(value + " is not a valid EL expression"); 044 } 045 } 046 047 if (map != null) 048 { 049 if (isValueReference(map)) 050 { 051 ValueBinding vb = app.createValueBinding(map); 052 053 component.setValueBinding("map", vb); 054 } 055 056 else 057 { 058 ((GraphicalSelectorUIComponent)component).setMap(map); 059 } 060 } 061 062 if (styleClass != null) 063 { 064 if (isValueReference(styleClass)) 065 { 066 ValueBinding vb = app.createValueBinding(styleClass); 067 068 component.setValueBinding("styleClass", vb); 069 } 070 071 else 072 { 073 component.getAttributes().put("styleClass", styleClass); 074 } 075 } 076 077 if (selectedBorderStyle != null) 078 { 079 if (isValueReference(selectedBorderStyle)) 080 { 081 ValueBinding vb = app.createValueBinding(selectedBorderStyle); 082 083 component.setValueBinding("selectedBorderStyle", vb); 084 } 085 086 else 087 { 088 component.getAttributes().put("selectedBorderStyle", selectedBorderStyle); 089 } 090 } 091 092 if (highlightedBorderStyle != null) 093 { 094 if (isValueReference(highlightedBorderStyle)) 095 { 096 ValueBinding vb = app.createValueBinding(highlightedBorderStyle); 097 098 component.setValueBinding("highlightedBorderStyle", vb); 099 } 100 101 else 102 { 103 component.getAttributes().put("highlightedBorderStyle", highlightedBorderStyle); 104 } 105 } 106 107 if (unhighlightedBorderStyle != null) 108 { 109 if (isValueReference(unhighlightedBorderStyle)) 110 { 111 ValueBinding vb = app.createValueBinding(unhighlightedBorderStyle); 112 113 component.setValueBinding("unhighlightedBorderStyle", vb); 114 } 115 116 else 117 { 118 component.getAttributes().put("unhighlightedBorderStyle", unhighlightedBorderStyle); 119 } 120 } 121 } 122 123 public void release() 124 { 125 super.release(); 126 this.value = null; 127 this.map = null; 128 this.styleClass = null; 129 this.selectedBorderStyle = null; 130 this.highlightedBorderStyle = null; 131 this.unhighlightedBorderStyle = null; 132 } 133 134 public void setValue(String s) 135 { 136 this.value = s; 137 } 138 139 public void setMap(String s) 140 { 141 this.map = s; 142 } 143 144 public void setStyleClass(String s) 145 { 146 this.styleClass = s; 147 } 148 149 public void setSelectedBorderStyle(String s) 150 { 151 this.selectedBorderStyle = s; 152 } 153 154 public void setHighlightedBorderStyle(String s) 155 { 156 this.highlightedBorderStyle = s; 157 } 158 159 public void setUnhighlightedBorderStyle(String s) 160 { 161 this.unhighlightedBorderStyle = s; 162 } 163 }