KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portlet > admin > controller > PageRegistryPortlet


1 /*
2  * Copyright 2003,2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.pluto.portlet.admin.controller;
17
18 import java.io.IOException JavaDoc;
19
20 import javax.portlet.ActionRequest;
21 import javax.portlet.ActionResponse;
22 import javax.portlet.PortletException;
23 import javax.portlet.RenderRequest;
24 import javax.portlet.RenderResponse;
25
26 import org.apache.pluto.portlet.admin.PlutoAdminConstants;
27 import org.apache.pluto.portlet.admin.services.PageRegistryService;
28
29 /**
30  * PageRegistryPortlet
31  *
32  * @author Craig Doremus
33  *
34  */

35 public class PageRegistryPortlet extends ControllerPortlet {
36
37     private PageRegistryService service = null;
38
39     /* (non-Javadoc)
40      * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
41      */

42     protected void doEdit(RenderRequest request, RenderResponse response)
43     throws PortletException, IOException JavaDoc {
44         String JavaDoc rows = request.getParameter("rows");
45         String JavaDoc cols = request.getParameter("cols");
46         if (rows != null && cols != null) {
47             request.setAttribute("rows", rows);
48             request.setAttribute("cols", cols);
49             _incEdit = "/PageRegistryEdit2.jsp";
50         }
51         super.doEdit(request, response);
52     }
53     /* (non-Javadoc)
54      * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
55      */

56     protected void doView(RenderRequest request, RenderResponse response)
57             throws PortletException, IOException JavaDoc {
58         service.getAllPages(request);
59         super.doView(request, response);
60     }
61     /* (non-Javadoc)
62      * @see javax.portlet.GenericPortlet#init()
63      */

64     public void init() throws PortletException {
65         super.init();
66         service = new PageRegistryService();
67     }
68     /* (non-Javadoc)
69      * @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
70      */

71     protected void doHelp(RenderRequest request, RenderResponse response)
72             throws PortletException, IOException JavaDoc {
73         // TODO Auto-generated method stub
74
super.doHelp(request, response);
75     }
76     /* (non-Javadoc)
77      * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
78      */

79     public void processAction(ActionRequest request, ActionResponse response)
80         throws PortletException, IOException JavaDoc {
81
82     try {
83             String JavaDoc action = request.getParameter("action");
84             log("Action param == " + action);
85
86             /* TODO: Implement portlet deletion
87             if (action == null) {
88                 ;//do nothing
89             } else if (action.equals("showallpages")) {
90
91             } else if (action.equals("showhome")) {
92                 _incView = "/PageRegistryView.jsp";
93                 response.setPortletMode(PortletMode.VIEW);
94             } else if (action.equals("showpage")) {
95                 //TODO: finish implementation
96                 //shows page for editing of attributes
97                 service.getPage(request);
98                 _incEdit = "/PageRegistryEdit.jsp";
99                 response.setPortletMode(PortletMode.EDIT);
100             } else if (action.equals("showpagelayout")) {
101                 //TODO: finish implementation
102                 //shows page for editing of layout cells
103                 service.modifyPageAttributes(request);
104                 _incEdit = "/PageRegistryEdit2.jsp";
105                 response.setPortletMode(PortletMode.EDIT);
106             } else if (action.equals("savepagelayout")) {
107                 //TODO: process new layout
108 // delegate.savePage(prPath, request);
109                 response.setPortletMode(PortletMode.VIEW);
110             _incView = "/PageRegistryView.jsp";
111             }
112     */

113         } catch (Throwable JavaDoc e) {
114             log("Error! ", e);
115             request.getPortletSession().setAttribute(PlutoAdminConstants.ERROR_ATTR, e);
116         }
117     }
118 }
119
Popular Tags