KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > meshcms > taglib > Links


1 /*
2  * MeshCMS - A simple CMS based on SiteMesh
3  * Copyright (C) 2004-2007 Luciano Vernaschi
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
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 License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * You can contact the author at http://www.cromoteca.com
20  * and at info@cromoteca.com
21  */

22
23 package org.meshcms.taglib;
24
25 import java.io.*;
26 import java.util.*;
27 import org.meshcms.core.*;
28 import org.meshcms.util.*;
29
30 /**
31  * Writes a list of links related to the current page.
32  */

33 public final class Links extends AbstractTag {
34   private String JavaDoc separator = " ";
35   private String JavaDoc style;
36   private String JavaDoc target;
37   private String JavaDoc current;
38   private String JavaDoc pre;
39   private String JavaDoc post;
40
41   public void setSeparator(String JavaDoc separator) {
42     if (separator != null) {
43       this.separator = separator;
44     }
45   }
46
47   public void setStyle(String JavaDoc style) {
48     this.style = style;
49   }
50
51   public void setTarget(String JavaDoc target) {
52     this.target = target;
53   }
54
55   public void setPre(String JavaDoc pre) {
56     this.pre = pre;
57   }
58
59   public void setPost(String JavaDoc post) {
60     this.post = post;
61   }
62
63   public void writeTag() throws IOException {
64     List list = webSite.getSiteMap().getPagesInDirectory(pagePath,
65         Utils.isTrue(current));
66
67     if (list != null) {
68       Writer w = getOut();
69       PageInfo[] pages = (PageInfo[]) list.toArray(new PageInfo[list.size()]);
70       String JavaDoc[] outs = webSite.getLinkList(pages, request.getContextPath(),
71           target, style);
72
73       if (outs != null && outs.length > 0) {
74         if (pre != null) {
75           w.write(pre);
76         }
77
78         w.write(Utils.generateList(outs, separator));
79
80         if (post != null) {
81           w.write(post);
82         }
83       } else {
84         w.write(" ");
85       }
86     }
87   }
88
89   public String JavaDoc getSeparator() {
90     return separator;
91   }
92
93   public String JavaDoc getStyle() {
94     return style;
95   }
96
97   public String JavaDoc getTarget() {
98     return target;
99   }
100
101   public String JavaDoc getCurrent() {
102     return current;
103   }
104
105   public void setCurrent(String JavaDoc current) {
106     this.current = current;
107   }
108
109   public String JavaDoc getPre() {
110     return pre;
111   }
112
113   public String JavaDoc getPost() {
114     return post;
115   }
116 }
117
Popular Tags