1 package fr.improve.struts.taglib.layout.field; 2 3 import javax.servlet.jsp.JspException ; 4 5 import org.apache.struts.taglib.html.BaseHandlerTag; 6 7 import fr.improve.struts.taglib.layout.util.LayoutUtils; 8 import fr.improve.struts.taglib.layout.util.TagUtils; 9 10 16 public class RadioTag extends AbstractFieldTag { 17 private org.apache.struts.taglib.html.RadioTag radioTag = 18 new org.apache.struts.taglib.html.RadioTag(); 19 20 protected boolean doBeforeValue() throws javax.servlet.jsp.JspException { 21 fieldTag = radioTag; 22 return true; 23 } 24 25 28 public int doStartInspectField() throws JspException { 29 if (!doBeforeValue()) return SKIP_BODY; 31 32 StringBuffer sb = new StringBuffer (); 33 if (isChecked()) { 35 sb.append("<img SRC=\""); 36 sb.append(getSkin().getImageDirectory(pageContext.getRequest())); 37 sb.append("/"); 38 sb.append(getSkin().getProperty("layout.checkbox.checked")); 39 sb.append("\" border=\"0\" alt=\""); 40 sb.append(getSkin().getProperty("layout.checkbox.checked.label")); 41 sb.append("\">"); 42 } else { 43 String lc_imgsrc = getSkin().getProperty("layout.checkbox.unchecked"); 44 if (lc_imgsrc!=null && lc_imgsrc.length()>0) { 45 sb.append("<img SRC=\""); 46 sb.append(getSkin().getImageDirectory(pageContext.getRequest())); 47 sb.append("/"); 48 sb.append(lc_imgsrc); 49 sb.append("\" border=\"0\" alt=\""); 50 sb.append(getSkin().getProperty("layout.checkbox.unchecked.label")); 51 sb.append("\">"); 52 } 53 } 54 TagUtils.write(pageContext, sb.toString()); 55 56 doAfterValue(); 57 58 return EVAL_BODY_INCLUDE; 59 } 60 63 protected void printSimpleHiddenValue(Object in_value) throws JspException { 64 if (isChecked()) { 66 super.printSimpleHiddenValue(in_value); 67 } 68 } 69 70 private boolean isChecked() throws JspException { 71 Object lc_value = LayoutUtils.getBeanFromPageContext(pageContext, name, property); 72 return lc_value==null && value==null || lc_value!=null && lc_value.toString().equals(value); 73 } 74 75 78 public boolean isFill(Object lc_value) throws JspException { 79 return isChecked(); 80 } 81 82 protected void copyProperties(BaseHandlerTag in_dest) throws JspException { 83 super.copyProperties(in_dest); 84 radioTag.setProperty(getProperty()); 85 radioTag.setValue(getValue()); 86 radioTag.setName(getName()); 87 } 88 89 } | Popular Tags |