1 package com.jcorporate.expresso.services.taglib; 2 3 66 67 68 import com.jcorporate.expresso.core.controller.Transition; 69 import com.jcorporate.expresso.core.misc.URLUTF8Encoder; 70 import com.jcorporate.expresso.kernel.util.FastStringBuffer; 71 import org.apache.log4j.Logger; 72 73 import javax.servlet.jsp.JspException ; 74 import javax.servlet.jsp.tagext.TagSupport ; 75 import java.io.IOException ; 76 77 78 93 94 public class ButtonParams extends TagSupport { 95 96 private static final Logger log = Logger.getLogger(ButtonParams.class); 97 98 101 private String value; 102 103 104 107 public ButtonParams() { 108 } 109 110 115 public String getValue() { 116 return value; 117 } 118 119 124 public void setValue(String value) { 125 this.value = value; 126 } 127 128 133 public int doEndTag() throws javax.servlet.jsp.JspException { 134 ELTagSupport support = ELTagSupport.getInstance(); 135 Transition result = (Transition) support.evaluate("value", this.getValue(), 136 Transition.class, 137 this, this.pageContext); 138 139 if (result == null) { 140 throw new JspException ("Unable to locate transition for expression: " + this.getValue()); 141 } 142 143 FastStringBuffer fsb = FastStringBuffer.getInstance(); 144 String writeValue; 145 try { 146 fsb.append("<input type=hidden name=\""); 147 fsb.append(result.getName()); 148 fsb.append("_params\" value=\""); 149 fsb.append(URLUTF8Encoder.encode(result.getParamString(true))); 150 fsb.append("\">\n"); 151 fsb.append("<input type=hidden name=\""); 152 fsb.append(result.getName()); 153 fsb.append("_encoding\" value=\"u\">"); 154 } finally { 155 writeValue = fsb.toString(); 156 fsb.release(); 157 } 158 159 try { 160 this.pageContext.getOut().write(writeValue); 161 } catch (IOException ex1) { 162 log.error("Error writing output", ex1); 163 throw new JspException ("I/O error"); 164 } 165 166 return EVAL_PAGE; 167 } 168 169 } | Popular Tags |