1 9 package org.jboss.portal.portlet.taglib; 10 11 import javax.servlet.jsp.JspException ; 12 import javax.servlet.jsp.tagext.TagSupport ; 13 14 24 public class URLParameterTag extends TagSupport 25 { 26 private String name; 27 private String value; 28 29 40 public String getName() 41 { 42 return name; 43 } 44 45 48 public void setName(String name) 49 { 50 this.name = name; 51 } 52 53 64 public String getValue() 65 { 66 return value; 67 } 68 69 72 public void setValue(String value) 73 { 74 this.value = value; 75 } 76 77 82 public int doStartTag() throws JspException 83 { 84 return SKIP_BODY; 85 } 86 87 92 public int doEndTag() throws JspException 93 { 94 try 95 { 96 GenerateURLTag ancestorTag = 97 (GenerateURLTag)findAncestorWithClass(this, GenerateURLTag.class); 98 99 Parameter p = new Parameter(getName(), getValue()); 100 101 if (p.isValid()) 102 { 103 ancestorTag.addParameter(p.getName(), p.getValue()); 104 } 105 else 106 { 107 } 110 111 } 112 catch (Exception e) 113 { 114 e.printStackTrace(); 115 throw new JspException (e); 116 } 117 return EVAL_PAGE; 118 } 119 120 public class Parameter 121 { 122 private String name; 123 private String value; 124 125 128 public String getName() 129 { 130 return name; 131 } 132 133 138 public String getValue() 139 { 140 return value; 141 } 142 143 public Parameter(String name, String value) 144 { 145 this.name = name; 146 this.value = value; 147 } 148 149 public boolean isValid() 150 { 151 return name != null && name.length() > 0; 152 } 153 } 154 } 155 | Popular Tags |