KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > ModeTag


1 package fr.improve.struts.taglib.layout;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import fr.improve.struts.taglib.layout.util.FormUtilsInterface;
6 import fr.improve.struts.taglib.layout.util.LayoutUtils;
7 /**
8  * Evaluate the content of the tag in function of the form mode.
9  * @author: Jean-Noël Ribette
10  */

11 public class ModeTag extends javax.servlet.jsp.tagext.TagSupport JavaDoc {
12     private String JavaDoc value ="";
13 public int doStartTag() throws JspException JavaDoc {
14     int lc_mode = LayoutUtils.getSkin(pageContext.getSession()).getFormUtils().getFormDisplayMode(pageContext);
15     boolean lc_include = false;
16     switch (lc_mode) {
17         case FormUtilsInterface.CREATE_MODE:
18             if (value.indexOf("create")!=-1) {
19                 lc_include = true;
20             }
21             break;
22         case FormUtilsInterface.EDIT_MODE:
23             if (value.indexOf("edit")!=-1) {
24                 lc_include = true;
25             }
26             break;
27         case FormUtilsInterface.INSPECT_MODE:
28             if (value.indexOf("inspect")!=-1) {
29                 lc_include = true;
30             }
31             break;
32     }
33     
34     if (lc_include) {
35         return EVAL_BODY_INCLUDE;
36     } else {
37         return SKIP_BODY;
38     }
39 }
40 /**
41  * Insert the method's description here.
42  * Creation date: (02/12/2001 22:53:50)
43  * @return java.lang.String
44  */

45 public java.lang.String JavaDoc getValue() {
46     return value;
47 }
48     public void release() {
49         super.release();
50         value = "";
51     }
52 /**
53  * Evaluate the body tag if the form mode is in the specified form mode.
54  * @param newValue java.lang.String create / edit / inspect.
55  */

56 public void setValue(java.lang.String JavaDoc newValue) {
57     if (value!=null) {
58         value = newValue.toLowerCase();
59     } else {
60         value = "";
61     }
62 }
63 }
64
Popular Tags