1 package fr.improve.struts.taglib.layout; 2 3 import javax.servlet.jsp.JspException ; 4 5 import fr.improve.struts.taglib.layout.event.EndLayoutEvent; 6 import fr.improve.struts.taglib.layout.event.StartLayoutEvent; 7 import fr.improve.struts.taglib.layout.util.LayoutUtils; 8 import fr.improve.struts.taglib.layout.util.TagUtils; 9 10 23 24 public class MessageTag extends LabelledTag { 25 protected boolean layout = true; 26 31 public int doStartLayoutTag() throws JspException { 32 doStartLayout(); 33 String key = this.key; 34 if (key == null) { 35 Object value = 37 TagUtils.lookup(pageContext, name, property, null); 38 if (value != null && !(value instanceof String )) { 39 JspException e = new JspException 40 (messages.getMessage("message.property", key)); 41 TagUtils.saveException(pageContext, e); 42 throw e; 43 } 44 key = (String )value; 45 } 46 String lc_message = getLabel(); 47 TagUtils.write(pageContext, lc_message); 48 49 doEndLayout(); 50 return (SKIP_BODY); 52 } 53 56 public void release() { 57 super.release(); 58 layout = true; 59 } 60 64 private void doStartLayout() throws JspException { 65 if (layout) { 66 StringBuffer lc_buffer = new StringBuffer ("<th"); 67 if (styleClass!=null) { 68 lc_buffer.append(" class=\""); 69 lc_buffer.append(styleClass); 70 lc_buffer.append("\""); 71 } 72 lc_buffer.append(" colspan=\""); 73 lc_buffer.append(LayoutUtils.getSkin(pageContext.getSession()).getFieldInterface().getColumnNumber()); 74 lc_buffer.append("\">"); 75 new StartLayoutEvent(this, lc_buffer.toString()).send(); 76 } 77 } 78 79 83 private void doEndLayout() throws JspException { 84 if (layout) { 85 new EndLayoutEvent(this,"</th>").send(); 86 } 87 } 88 89 93 public void setLayout(boolean layout) { 94 this.layout = layout; 95 } 96 97 } 98 | Popular Tags |