01: package test;
02:
03: import javax.portlet.GenericPortlet;
04: import javax.portlet.ActionRequest;
05: import javax.portlet.RenderRequest;
06: import javax.portlet.ActionResponse;
07: import javax.portlet.RenderResponse;
08: import javax.portlet.PortletException;
09: import javax.portlet.PortletURL;
10:
11: import java.io.IOException;
12: import java.io.PrintWriter;
13:
14: import java.util.Map;
15: import java.util.HashMap;
16: import java.util.Iterator;
17: import java.util.Collections;
18:
19: public class NavStatePortlet extends GenericPortlet {
20:
21: public void processAction(ActionRequest request,
22: ActionResponse response) throws PortletException {
23: Map nav = new HashMap();
24: nav.put("actionSetNavParam.1", new String[] { "A", "AA" });
25: nav.put("actionSetNavParam.2", new String[] { "B", "BB" });
26: response.setRenderParameters(nav);
27: }
28:
29: public void doView(RenderRequest request, RenderResponse response)
30: throws PortletException, IOException {
31:
32: response.setContentType(request.getResponseContentType());
33: PrintWriter writer = response.getWriter();
34: writer.write("Current Navigational State:<P>");
35: Map params = request.getParameterMap();
36:
37: // after bug is fix this line can be removed
38: //if (params==null) params = Collections.EMPTY_MAP;
39:
40: Iterator names = params.keySet().iterator();
41: while (names.hasNext()) {
42: String name = (String) names.next();
43: String[] values = (String[]) params.get(name);
44: writer.write(" " + name + " :");
45: for (int i = 0; i < values.length; i++) {
46: writer.write(" " + values[i]);
47: }
48: writer.write("<P>");
49: }
50: writer.write("<P>");
51: PortletURL actionURL = response.createActionURL();
52: PortletURL renderURL = response.createRenderURL();
53: renderURL.setParameter("renderURLSetNavParam.1", "C");
54: renderURL.setParameter("renderURLSetNavParam.2", "D");
55: writer.write("<A HREF=\"" + actionURL.toString()
56: + "\">Action Link</A><P>");
57: writer.write("<A HREF=\"" + renderURL.toString()
58: + "\">Render Link</A><P>");
59: }
60:
61: }
|