1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package com.mycomp.portal.jsr286;
35
36 import java.io.IOException;
37
38 import javax.portlet.Event;
39 import javax.portlet.EventRequest;
40 import javax.portlet.EventResponse;
41 import javax.portlet.GenericPortlet;
42 import javax.portlet.PortletException;
43 import javax.portlet.RenderRequest;
44 import javax.portlet.RenderResponse;
45
46 import com.mycomp.portal.jsr286.WrapperEvent;
47
48 public class SubscribeEventPortlet extends GenericPortlet {
49
50 private static final String VIEW_JSP = "/jsp/subscribeView.jsp";
51 public static final String NAME_ATTR = "NAME";
52 public static final String ZIP_ATTR = "ZIP";
53
54 @Override
55 protected void doView(RenderRequest request, RenderResponse renderResponse)
56 throws PortletException, IOException {
57 renderResponse.setContentType(request.getResponseContentType());
58
59 request.setAttribute(NAME_ATTR, name);
60 request.setAttribute(ZIP_ATTR, zipcode);
61 getPortletContext().getRequestDispatcher(VIEW_JSP).include(request,renderResponse);
62 }
63
64 @Override
65 public void processEvent(EventRequest eventRequest, EventResponse response)
66 throws PortletException, IOException {
67 Event event = eventRequest.getEvent();
68 if(event.getQName().equals(WrapperEvent.QNAME))
69 {
70 WrapperEvent wrapEvent = (WrapperEvent)event.getValue();
71 name = wrapEvent.getName();
72 zipcode = wrapEvent.getZipcode();
73 }
74 }
75
76 private String name = "Default Name";
77 private String zipcode = "Default Zip";
78
79
80 }