1 package fr.improve.struts.taglib.layout; 2 3 import javax.servlet.jsp.JspException ; 4 import javax.servlet.jsp.tagext.TagSupport ; 5 6 import fr.improve.struts.taglib.layout.util.FormUtilsInterface; 7 import fr.improve.struts.taglib.layout.util.LayoutUtils; 8 9 18 public class NotModeTag extends TagSupport { 19 23 String value; 24 25 29 public String getValue() { 30 return value; 31 } 32 33 37 public void setValue(String value) { 38 this.value = value; 39 } 40 41 48 public int doStartTag() throws JspException { 49 int mode = LayoutUtils.getSkin(pageContext.getSession()).getFormUtils().getFormDisplayMode(pageContext); 50 int notDesiredMode = -1; 51 52 if ("create".equalsIgnoreCase(value)) { 53 notDesiredMode = FormUtilsInterface.CREATE_MODE; 54 } else if ("edit".equalsIgnoreCase(value)) { 55 notDesiredMode = FormUtilsInterface.EDIT_MODE; 56 } else if ("inspect".equalsIgnoreCase(value)) { 57 notDesiredMode = FormUtilsInterface.INSPECT_MODE; 58 } 59 60 if (notDesiredMode == -1) { 61 throw new JspException ( 62 "Form mode " 63 + value 64 + " is not valid. Valid form modes are create, edit and inspect."); 65 } 66 67 if (notDesiredMode != mode) { 68 return EVAL_BODY_INCLUDE; 69 } else { 70 return SKIP_BODY; 71 } 72 } 73 74 } 75 | Popular Tags |