1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.fatwire.gst.foundation.taglib.navigation;
18
19 import java.io.IOException;
20 import java.util.Collection;
21
22 import javax.servlet.jsp.JspException;
23
24 import org.apache.commons.lang.StringUtils;
25
26 import COM.FutureTense.Interfaces.ICS;
27
28 import com.fatwire.gst.foundation.navigation.NavigationNode;
29 import com.fatwire.gst.foundation.navigation.NavigationService;
30 import com.fatwire.gst.foundation.taglib.GsfSimpleTag;
31
32
33
34
35
36
37
38
39
40 public class PluggableNavigationTag extends GsfSimpleTag {
41
42 private String name;
43 private int depth = 1;
44 private String pagename;
45
46
47
48
49 public void setName(final String name) {
50 this.name = name;
51 }
52
53
54
55
56 public void setDepth(final int depth) {
57 this.depth = depth;
58 }
59
60
61
62
63 public void setPagename(final String pagename) {
64 this.pagename = pagename;
65 }
66
67
68
69
70
71
72 @Override
73 public void doTag() throws JspException, IOException {
74 super.doTag();
75 final ICS ics = (ICS) getICS();
76
77 final NavigationService nh = getService("navigationService", NavigationService.class);
78 if (nh == null)
79 throw new IllegalStateException("No NavigationService found, cannot retrieve navigation node.");
80 String site = ics.GetVar("site");
81 if (StringUtils.isBlank(site))
82 throw new IllegalStateException("site is not a valid 'ics' variable.");
83 if (StringUtils.isBlank(pagename)) {
84
85 Collection<NavigationNode> nav = nh.getRootNodesForSite(site, depth);
86 getJspContext().setAttribute(name, nav);
87 } else {
88 NavigationNode nav = nh.getNodeByName(site, pagename, depth);
89 getJspContext().setAttribute(name, nav);
90
91 }
92 depth = 1;
93 pagename = null;
94
95 }
96 }