1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.portals.bridges.frameworks;
18
19 import java.io.IOException;
20
21 import javax.portlet.RenderRequest;
22 import javax.portlet.RenderResponse;
23 import javax.servlet.jsp.JspWriter;
24 import javax.servlet.jsp.tagext.TagSupport;
25
26 import org.apache.portals.bridges.frameworks.model.PortletApplicationModel;
27
28
29 /***
30 * ForwardTag
31 *
32 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
33 * @version $Id: ForwardTag.java 517068 2007-03-12 01:44:37Z ate $
34 */
35 public class ForwardTag extends TagSupport
36 {
37 private String view = null;
38 private String action = null;
39 private String forward = null;
40
41 public int doStartTag()
42 {
43 String content;
44 try
45 {
46 RenderRequest request = (RenderRequest)
47 pageContext.getRequest().getAttribute("javax.portlet.request");
48 RenderResponse response = (RenderResponse)
49 pageContext.getRequest().getAttribute("javax.portlet.response");
50
51 if (request == null || response == null)
52 {
53 JspWriter out = pageContext.getOut();
54 out.print("request response not found");
55 return SKIP_BODY;
56 }
57 PortletApplicationModel model = (PortletApplicationModel)request.getAttribute(FrameworkConstants.MODEL_TOOL);
58 if (model == null)
59 {
60 JspWriter out = pageContext.getOut();
61 out.print("model not found");
62 return SKIP_BODY;
63 }
64
65 Forwarder forwarder = new Forwarder(model, request, response);
66 if (view != null)
67 {
68 content = forwarder.getView(view).toString();
69 }
70 else if (forward != null)
71 {
72 if (action != null)
73 {
74 content = forwarder.getLink(forward, action).toString();
75 }
76 else
77 {
78 content = forwarder.getLink(forward).toString();
79 }
80 }
81 else
82 {
83 content = forwarder.toString();
84 }
85 JspWriter out = pageContext.getOut();
86 out.print(content);
87 }
88 catch (IOException e)
89 {
90 System.err.println("Error printing tag: " + e);
91 }
92 return SKIP_BODY;
93 }
94
95
96 /***
97 * @return Returns the action.
98 */
99 public String getAction()
100 {
101 return action;
102 }
103 /***
104 * @param action The action to set.
105 */
106 public void setAction(String action)
107 {
108 this.action = action;
109 }
110 /***
111 * @return Returns the view.
112 */
113 public String getView()
114 {
115 return view;
116 }
117 /***
118 * @param view The view to set.
119 */
120 public void setView(String view)
121 {
122 this.view = view;
123 }
124 /***
125 * @return Returns the forward.
126 */
127 public String getForward()
128 {
129 return forward;
130 }
131 /***
132 * @param forward The forward to set.
133 */
134 public void setForward(String forward)
135 {
136 this.forward = forward;
137 }
138 }