KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > networkplaces > tags > PathsTag


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.networkplaces.tags;
21
22 import java.util.StringTokenizer JavaDoc;
23
24 import javax.servlet.jsp.JspException JavaDoc;
25 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
26
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.struts.taglib.TagUtils;
30
31 import com.sslexplorer.networkplaces.forms.FileSystemForm;
32 import com.sslexplorer.policyframework.LaunchSession;
33
34 /**
35  * <p>
36  * A custom tag which checks to see if the contents of the tag can be deleted.
37  *
38  * @author James D Robinson <james@3sp.com>
39  *
40  */

41 public class PathsTag extends BodyTagSupport JavaDoc {
42     final static Log log = LogFactory.getLog(PathsTag.class);
43     
44     private String JavaDoc paths;
45     protected String JavaDoc scope;
46     protected String JavaDoc property;
47     protected String JavaDoc name;
48
49     public int doStartTag() throws JspException JavaDoc {
50
51         // Look up the requested property value
52
LaunchSession launchSession = (LaunchSession)TagUtils.getInstance().lookup(pageContext, name, property, scope);
53         
54         
55         FileSystemForm fsf = (FileSystemForm) pageContext.getRequest().getAttribute("fileSystemForm");
56         StringBuffer JavaDoc results = new StringBuffer JavaDoc();
57         results.append("<div class=\"path\"><span>");
58         StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc(fsf.getPath(), "/");
59         
60         String JavaDoc currentPath = tok.nextToken(); // Important: skip the file store
61
// we only remove the second entry if the first one is the store, else we are straight into the proper paths.
62
if (currentPath.equals("fs")){
63             currentPath = tok.nextToken(); // Important: skip the file store type
64
}
65         while(tok.hasMoreTokens()) {
66             String JavaDoc element = tok.nextToken();
67             currentPath += "/" + element;
68             results.append("<a HREF=\"fileSystem.do?actionTarget=list&" + LaunchSession.LAUNCH_ID + "=" + launchSession.getId() + "&path=" + currentPath + "\">" + element +"</a>&nbsp/&nbsp");
69         }
70         results.append(" </span></div>");
71         paths = results.toString();
72         return (SKIP_BODY);
73     }
74
75     /* (non-Javadoc)
76      * @see javax.servlet.jsp.tagext.BodyTagSupport#doEndTag()
77      */

78     public int doEndTag() throws JspException JavaDoc {
79         TagUtils.getInstance().write(this.pageContext, paths);
80         return EVAL_PAGE;
81     }
82
83     @Override JavaDoc
84     public void release() {
85         super.release();
86         name = null;
87         property = null;
88         scope = null;
89     }
90
91     public String JavaDoc getName() {
92         return (this.name);
93     }
94
95     public void setName(String JavaDoc name) {
96         this.name = name;
97     }
98
99
100     public String JavaDoc getProperty() {
101         return (this.property);
102     }
103
104     public void setProperty(String JavaDoc property) {
105         this.property = property;
106     }
107     public String JavaDoc getScope() {
108         return (this.scope);
109     }
110
111     public void setScope(String JavaDoc scope) {
112         this.scope = scope;
113     }
114
115 }
Popular Tags