001: package __PACKAGE__;
002:
003: import java.io.IOException;
004: import java.util.ResourceBundle;
005:
006: import javax.portlet.GenericPortlet;
007: import javax.portlet.PortletConfig;
008: import javax.portlet.PortletRequest;
009: import javax.portlet.ActionRequest;
010: import javax.portlet.ActionResponse;
011: import javax.portlet.PortletException;
012: import javax.portlet.RenderRequest;
013: import javax.portlet.RenderResponse;
014:
015: /**
016: * The <CODE>GenericPortlet</CODE> class provides a default implementation
017: * for the <CODE>Portlet</CODE> interface.
018: * <p>
019: * It is recommended not to extend the Portlet interface directly.
020: * Rather, a portlet should derive
021: * from this or any other derived class and use the provided helper
022: * methods for the different modes.
023: */
024: public class __NAME__ extends GenericPortlet {
025:
026: public __NAME__() {
027: }
028:
029: /**
030: * Optional init should call GenericPortlet.init() to register config.
031: *
032: public void init (PortletConfig config) throws PortletException
033: {
034: super(config);
035: }
036: */
037:
038: public void processAction(ActionRequest request,
039: ActionResponse actionResponse) throws PortletException,
040: java.io.IOException {
041: }
042:
043: /*
044: * superclass getTitle() uses resource bundle string "javax.portlet.title".
045: public String getTitle(PortletRequest request) {
046: }
047: */
048:
049: /**
050: * The default implementation of render() routes the request
051: * to a set of helper methods based on the portlet mode.
052: *
053: public void render (PortletRequest request,
054: RenderResponse response)
055: throws PortletException, java.io.IOException
056: {
057: response.setTitle(getTitle(request));
058: WindowState state = request.getWindowState();
059:
060: if ( ! state.equals(WindowState.MINIMIZED)) {
061: PortletMode mode = request.getPortletMode();
062: if (mode.equals(PortletMode.VIEW)) {
063: doView (request, response);
064: }
065: else if (mode.equals(PortletMode.EDIT)) {
066: doEdit (request, response);
067: }
068: else if (mode.equals(PortletMode.HELP)) {
069: doHelp (request, response);
070: }
071: else {
072: doCustom (request, response);
073: }
074: }
075: }
076: **/
077:
078: /**
079: * Helper method to serve up the mandatory VIEW mode.
080: * <p>
081: * The default implementation throws an exception.
082: *
083: * @param request
084: * the portlet request
085: * @param response
086: * the render response
087: *
088: * @exception PortletException
089: * if the portlet cannot fulfilling the request
090: * @exception UnavailableException
091: * if the portlet is unavailable to perform render
092: * @exception PortletSecurityException
093: * if the portlet cannot fullfill this request because of security reasons
094: * @exception IOException
095: * if the streaming causes an I/O problem
096: *
097: */
098:
099: protected void doView(RenderRequest request, RenderResponse response)
100: throws PortletException, java.io.IOException {
101: response.setContentType("text/html");
102: response.getWriter().write("VIEW CONTENT\n");
103: }
104:
105: /**
106: * Helper method to serve up the EDIT mode.
107: * <p>
108: * The default implementation throws an exception.
109: *
110: * @param request
111: * the portlet request
112: * @param response
113: * the render response
114: *
115: * @exception PortletException
116: * if the portlet cannot fulfilling the request
117: * @exception UnavailableException
118: * if the portlet is unavailable to perform render
119: * @exception PortletSecurityException
120: * if the portlet cannot fullfill this request because of security reasons
121: * @exception IOException
122: * if the streaming causes an I/O problem
123: *
124: */
125:
126: protected void doEdit(RenderRequest request, RenderResponse response)
127: throws PortletException, java.io.IOException {
128: response.setContentType("text/html");
129: response.getWriter().write("EDIT CONTENT\n");
130: }
131:
132: /**
133: * Helper method to serve up the HELP mode.
134: * <p>
135: * The default implementation throws an exception.
136: *
137: * @param request
138: * the portlet request
139: * @param response
140: * the render response
141: *
142: * @exception PortletException
143: * if the portlet cannot fulfilling the request
144: * @exception UnavailableException
145: * if the portlet is unavailable to perform render
146: * @exception PortletSecurityException
147: * if the portlet cannot fullfill this request because of security reasons
148: * @exception IOException
149: * if the streaming causes an I/O problem
150: */
151:
152: protected void doHelp(RenderRequest request, RenderResponse response)
153: throws PortletException, java.io.IOException {
154: response.setContentType("text/html");
155: response.getWriter().write("HELP CONTENT\n");
156: }
157:
158: /**
159: * Helper method to serve up the custom modes.
160: * <p>
161: * The default implementation throws an exception.
162: *
163: * @param request
164: * the portlet request
165: * @param response
166: * the render response
167: *
168: * @exception PortletException
169: * if the portlet cannot fulfilling the request
170: * @exception UnavailableException
171: * if the portlet is unavailable to perform render
172: * @exception PortletSecurityException
173: * if the portlet cannot fullfill this request because of security reasons
174: * @exception IOException
175: * if the streaming causes an I/O problem
176: */
177:
178: protected void doCustom(PortletRequest request,
179: RenderResponse response) throws PortletException,
180: java.io.IOException {
181: response.setContentType("text/html");
182: response.getWriter().write("CUSTOM CONTENT\n");
183: }
184:
185: /**
186: * Called by the portlet container to indicate to a portlet that the portlet
187: * is being taken out of service.
188: *
189: * The default implementation does nothing.
190: *
191: public void destroy ()
192: {
193: }
194: *
195: */
196: }
|