Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/aendvari/tethys/tag/notices/NoticesExistTag.java


1   /*
2    * NoticesExistTag.java
3    *
4    * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5    *
6    * See the file LICENSE for terms of use.
7    *
8    */
9   
10  package com.aendvari.tethys.tag.notices;
11  
12  import java.io.IOException;
13  
14  import java.util.Collection;
15  import java.util.Iterator;
16  
17  import javax.servlet.http.*;
18  import javax.servlet.jsp.*;
19  import javax.servlet.jsp.tagext.*;
20  
21  import com.aendvari.common.model.*;
22  
23  import com.aendvari.tethys.*;
24  import com.aendvari.tethys.tag.*;
25  import com.aendvari.tethys.tag.data.*;
26  import com.aendvari.tethys.context.*;
27  
28  import com.aendvari.common.notices.*;
29  
30  
31  /**
32   * <p>Implementation class to verify that notices are available.</p>
33   *
34   * @author  Scott Milne
35   *
36   */
37  
38  public class NoticesExistTag extends DataTag
39  {
40    /* Variables */
41  
42    /** The OSM path containing notices. */
43    protected String path;
44  
45    /** Should recursion be used to extract the messages. */
46    protected boolean recursive;
47  
48  
49    /* Constructor */
50  
51    public NoticesExistTag()
52    {
53      super();
54  
55      path = null;
56      recursive = true;
57    }
58  
59    /* Attributes */
60  
61    public void setPath(String path) { this.path = path; }
62    public String getPath() { return path; }
63  
64    public void setRecursive(boolean recursive)
65    {
66      this.recursive = recursive;
67    }
68  
69    public boolean getRecursive()
70    {
71      return recursive;
72    }
73  
74    public int doStartTag() throws JspTagException
75    {
76      try
77      {
78        // get the notices map
79        NoticesMap noticesMap = NoticesTagData.getData(
80          pageContext, getDataScope()).getNoticesMap();
81  
82        // get the messages
83        Notices messages = noticesMap.getNotices();
84  
85        // check for valid messages
86        if (messages != null)
87        {
88          Collection errorNotices = messages.getNotices(getPath(), recursive);
89  
90          if (errorNotices.size() > 0)
91          {
92            // allow the body of this tag to be shown
93            return EVAL_BODY_INCLUDE;
94          }
95        }
96      }
97      catch (Exception exception)
98      {
99        throw new JspTagException("NoticesExistTag:" + exception.toString());
100     }
101 
102     // nothing matched, so don't display the body
103     return SKIP_BODY;
104   }
105 
106     /**
107      * Release all allocated resources.
108    *
109      */
110 
111     public void release()
112     {
113         super.release();
114 
115     path = null;
116     recursive = true;
117     }
118 }
119