01: package pygmy.nntp.http;
02:
03: import pygmy.core.HttpRequest;
04:
05: import java.io.IOException;
06:
07: public class NavigationTabsView extends ViewDecorator {
08:
09: String[] headings;
10: String[] links;
11: String selected;
12:
13: public NavigationTabsView(String urlPrefix, View component,
14: String selected, String[] headings, String[] links) {
15: super (urlPrefix, component);
16: this .headings = headings;
17: this .links = links;
18: this .selected = selected;
19: }
20:
21: public String render(HttpRequest request) throws IOException {
22: buffer.append("<div class=\"tabs\">");
23: for (int i = 0; i < headings.length; i++) {
24: String clazz = "plain";
25: if (headings[i].equalsIgnoreCase(selected)) {
26: clazz = "selected";
27: }
28: if (links[i] == null) {
29: buffer.append("<span class=\"");
30: buffer.append(clazz);
31: buffer.append("\">");
32: buffer.append(headings[i]);
33: buffer.append("</span>\n");
34: } else {
35: createLink(headings[i], links[i], clazz);
36: }
37: }
38: buffer.append("</div>");
39: buffer.append(super.render(request));
40:
41: return buffer.toString();
42: }
43: }
|