KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > edit > ValidTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.bridge.jsp.taglib.edit;
11
12 import org.mmbase.bridge.jsp.taglib.util.Attribute;
13 import org.mmbase.bridge.jsp.taglib.*;
14
15 import javax.servlet.jsp.JspTagException JavaDoc;
16
17
18 /**
19  * Shows the valid state of an mm:form
20  *
21  * @author Michiel Meeuwissen
22  * @version $Id: ValidTag.java,v 1.1 2005/12/20 23:00:47 michiel Exp $
23  * @since MMBase-1.8
24  */

25
26 public class ValidTag extends ContextReferrerTag implements Condition {
27
28
29     protected Attribute form = Attribute.NULL;
30     protected Attribute inverse = Attribute.NULL;
31
32     public void setForm(String JavaDoc f) throws JspTagException JavaDoc {
33         form = getAttribute(f);
34     }
35
36     public void setInverse(String JavaDoc b) throws JspTagException JavaDoc {
37         inverse = getAttribute(b);
38     }
39     protected boolean getInverse() throws JspTagException JavaDoc {
40         return inverse.getBoolean(this, false);
41     }
42
43
44     public int doStartTag() throws JspTagException JavaDoc {
45         FormTag formTag = (FormTag) findParentTag(FormTag.class, (String JavaDoc) form.getValue(this), true);
46         if (formTag.isValid() != getInverse()) {
47             return EVAL_BODY;
48         } else {
49             return SKIP_BODY;
50         }
51     }
52     
53     public int doAfterBody() throws JspTagException JavaDoc {
54         if (EVAL_BODY == EVAL_BODY_BUFFERED) { // not needed if EVAL_BODY_INCLUDE
55
if (bodyContent != null) {
56                 try{
57                     if(bodyContent != null) {
58                         bodyContent.writeOut(bodyContent.getEnclosingWriter());
59                     }
60                 } catch(java.io.IOException JavaDoc e){
61                     throw new TaglibException(e);
62                 }
63             }
64         }
65         return SKIP_BODY;
66     }
67 }
68
Popular Tags