1 package net.sourceforge.formview.taglib; 2 3 import java.io.IOException ; 4 5 import javax.servlet.ServletRequest ; 6 import javax.servlet.jsp.JspException ; 7 import javax.servlet.jsp.JspWriter ; 8 import javax.servlet.jsp.tagext.TagSupport ; 9 10 import net.sourceforge.formview.FormView; 11 import net.sourceforge.formview.util.WEBFormViewUtil; 12 13 21 public class DebugFormViewTag extends TagSupport { 22 23 private static final long serialVersionUID = 1L; 24 25 private String debugEnabled; 27 public String getDebugEnabled() { 28 return debugEnabled; 29 } 30 31 public void setDebugEnabled(String debugEnabled) { 32 this.debugEnabled = debugEnabled; 33 } 34 35 38 public DebugFormViewTag() { 39 40 } 41 42 47 public int doEndTag() throws JspException { 48 if ("true".equalsIgnoreCase(debugEnabled)) { 49 JspWriter out = pageContext.getOut(); 51 ServletRequest request = pageContext.getRequest(); 52 StringBuffer htmlDebug = new StringBuffer (""); 54 htmlDebug.append("<div>"); 55 String displayState = "no STATE"; 57 String state = (String )request.getAttribute(WEBFormViewUtil.getREQUEST_FORMSTATE_KEY(null)); 58 if (state != null && state.length() > 0) 59 displayState = state; 60 htmlDebug.append("<li>STATE : " + displayState + "</li>"); 61 StringBuffer displayForm = new StringBuffer (""); 63 FormView form = (FormView)WEBFormViewUtil.getFormViewSaved(request); if (form == null) { 65 displayForm.append("no FORM "); 66 } 67 else { 68 displayForm.append(form.toHtml()); 70 } 71 htmlDebug.append(displayForm.toString()); 72 htmlDebug.append("</div>"); 73 try { 74 out.println(htmlDebug.toString()); 75 } catch (IOException ex) { 76 throw new JspException (ex.getMessage()); 77 } 78 } 79 return EVAL_PAGE; 80 } 81 82 public void release() { 83 super.release(); 84 debugEnabled = null; 85 } 86 } 87 | Popular Tags |