1 88 89 package org.opencms.jsp; 90 91 import org.opencms.i18n.CmsEncoder; 92 import org.opencms.main.OpenCms; 93 import org.opencms.util.CmsStringUtil; 94 95 import javax.servlet.jsp.JspException ; 96 import javax.servlet.jsp.JspTagException ; 97 import javax.servlet.jsp.tagext.BodyTagSupport ; 98 import javax.servlet.jsp.tagext.Tag ; 99 100 110 public class CmsJspTagParam extends BodyTagSupport { 111 112 113 private static final long serialVersionUID = -1057768160264355211L; 114 115 120 protected boolean m_encode; 121 122 123 protected String m_name; 124 125 126 protected String m_value; 127 128 131 public CmsJspTagParam() { 132 133 super(); 134 init(); 135 } 136 137 143 public int doEndTag() throws JspException { 144 145 Tag t = findAncestorWithClass(this, I_CmsJspTagParamParent.class); 146 if (t == null) { 147 throw new JspTagException (Messages.get().getBundle(pageContext.getRequest().getLocale()).key( 148 Messages.ERR_PARENTLESS_TAG_1, 149 new Object [] {"param"})); 150 } 151 if (CmsStringUtil.isEmpty(m_name)) { 153 return EVAL_PAGE; 154 } 155 156 I_CmsJspTagParamParent parent = (I_CmsJspTagParamParent)t; 158 String value = m_value; 159 if (value == null) { 160 if (bodyContent == null || bodyContent.getString() == null) { 161 value = ""; 162 } else { 163 value = bodyContent.getString().trim(); 164 } 165 } 166 if (m_encode) { 167 parent.addParameter( 168 CmsEncoder.encode(m_name, OpenCms.getSystemInfo().getDefaultEncoding()), 169 CmsEncoder.encode(value, OpenCms.getSystemInfo().getDefaultEncoding())); 170 } else { 171 parent.addParameter(m_name, value); 172 } 173 174 return EVAL_PAGE; 175 } 176 177 180 public void release() { 181 182 init(); 183 } 184 185 190 public void setName(String name) { 191 192 m_name = name; 193 } 194 195 200 public void setValue(String value) { 201 202 m_value = value; 203 } 204 205 208 private void init() { 209 210 m_name = null; 211 m_value = null; 212 } 213 } | Popular Tags |