1 8 13 14 package org.webjmx.tags; 15 16 import java.util.*; 17 import javax.management.*; 18 import javax.servlet.jsp.*; 19 import javax.servlet.jsp.tagext.*; 20 21 25 public class FormParameterTag extends TagSupport 26 implements JMXTaglibConstants 27 { 28 29 private String name; 30 31 32 private String type; 33 34 35 private String value; 36 37 38 private String mbeanName; 39 40 41 private String parameterInfo; 42 43 44 private String count; 45 46 47 public FormParameterTag() 48 { } 49 50 53 public int doStartTag() 54 throws JspException 55 { 56 Object o = getParent(); 57 while(o != null && !(o instanceof FormMBeanTag)) 58 o = ((Tag)o).getParent(); 59 60 if(!(o instanceof FormMBeanTag)) 61 throw new JspException("enclosing tag must be of type formMBean."); 62 FormMBeanTag parent = (FormMBeanTag)o; 63 64 if(parameterInfo != null) 65 { 66 o = pageContext.getAttribute(parameterInfo); 67 if( o == null || !(o instanceof MBeanParameterInfo)) 68 throw new JspException("tag attribute paramterInfo must point a page attribute of type MBeanParameterInfo, found: " +o); 69 70 MBeanParameterInfo pInfo = (MBeanParameterInfo)o; 71 name = pInfo.getName(); 72 type = pInfo.getType(); 73 if(Boolean.getBoolean(DEBUG_PROP)) pageContext.getServletContext().log("got name [" +name +"] and type[" +type +"] from parameterInfo."); 74 } 75 76 if(count != null &&(name == null || name.length() == 0)) 77 name = pageContext.getAttribute(count).toString(); 78 79 MBeanServer server = GetServerTag.getMBeanServer(parent.getLocator()); 80 81 try 82 { 83 String pType = type; 85 86 88 StringBuffer results = new StringBuffer ("<INPUT"); 89 if(pType != null && pType.equalsIgnoreCase("java.lang.Boolean")) 90 results.append(" TYPE=CHECKBOX"); 91 else 92 results.append(" TYPE=TEXT"); 93 95 results.append(" NAME=\""); 96 if(name != null) 97 results.append(name); 98 else if(mbeanName != null) 99 results.append(TAGLIB_NAME); 100 101 if(value != null) 102 { 103 results.append("\" VALUE=\""); 104 results.append(value); 105 } 106 results.append("\"/>"); 107 108 if(type != null) 109 { 110 results.append("\n<INPUT TYPE=HIDDEN NAME=\""); 111 results.append(TAGLIB_TYPE_PREFIX); 112 results.append(name); 113 results.append("\" VALUE=\""); 114 results.append(type); 115 results.append("\"/>"); 116 } 117 118 pageContext.getOut().write(results.toString()); 119 }catch(Exception ex) 120 { 121 ex.printStackTrace(); 122 throw new JspException(ex.getMessage()); 123 } 124 return (SKIP_BODY); 125 } 126 127 130 public String getName() 131 { 132 return name; 133 } 134 135 138 public void setName(String name) 139 { 140 this.name = name; 141 } 142 143 146 public String getType() 147 { 148 return type; 149 } 150 151 154 public void setType(String type) 155 { 156 this.type = type; 157 } 158 159 162 public String getValue() 163 { 164 return value; 165 } 166 167 170 public void setValue(String value) 171 { 172 this.value = value; 173 } 174 175 178 public void release() 179 { 180 name = type = value = null; 181 } 182 183 186 public String getMbeanName() { 187 return mbeanName; 188 } 189 190 193 public void setMbeanName(String mbeanName) { 194 this.mbeanName = mbeanName; 195 } 196 197 200 public String getParameterInfo() 201 { 202 return parameterInfo; 203 } 204 205 208 public void setParameterInfo(String parameterInfo) 209 { 210 this.parameterInfo = parameterInfo; 211 } 212 213 216 public String getCount() 217 { 218 return count; 219 } 220 221 224 public void setCount(String count) 225 { 226 this.count = count; 227 } 228 229 } 230 | Popular Tags |