KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > controllers > PanedControllerAction


1 /*
2  * Copyright 2000-2001,2004 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  
17 package org.apache.jetspeed.modules.actions.controllers;
18
19 import org.apache.jetspeed.portal.Portlet;
20 import org.apache.jetspeed.portal.PortletSet;
21 import org.apache.jetspeed.portal.PortletController;
22 import org.apache.jetspeed.portal.PortletControllerConfig;
23 import org.apache.jetspeed.portal.PanedPortletController;
24 import org.apache.jetspeed.services.resources.JetspeedResources;
25
26 // Turbine stuff
27
import org.apache.turbine.util.RunData;
28
29 // Velocity Stuff
30
import org.apache.velocity.context.Context;
31
32 /**
33  * This action builds a context suitable for controllers portlets
34  * in panes, ie with only a subsetof defined portlets defined at any
35  * time.
36  * Should be associated with a controller implementing PanedPortletController
37  * to work correctly
38  *
39  * @author <a HREF="mailto:raphael@apache.org">Raphaël Luta</a>
40  * @author <a HREF="mailto:taylor@apache.org">David Sean Taylor</a>
41  *
42  * @version $Id: PanedControllerAction.java,v 1.13 2004/02/23 02:49:58 jford Exp $
43  */

44 public class PanedControllerAction extends RowColumnControllerAction
45 {
46     /**
47      * Adds a "pane" portlet object in the context which represents the
48      * currently selected pane
49      */

50     protected void buildNormalContext( PortletController controller,
51                                        Context context,
52                                        RunData rundata )
53     {
54         PanedPortletController cont = (PanedPortletController)controller;
55         
56         PortletSet myPortlets = cont.getPortlets();
57         PortletControllerConfig conf = cont.getConfig();
58
59         Portlet portlet = null;
60         String JavaDoc paneID = null;
61         String JavaDoc paneName = rundata.getParameters().getString( JetspeedResources.PATH_PANENAME_KEY );
62
63         if (null != paneName)
64         {
65             portlet = myPortlets.getPortletByName(paneName);
66             if (portlet != null)
67             {
68                 paneID = portlet.getID();
69                 rundata.getParameters().setString(JetspeedResources.PATH_PANEID_KEY, paneID);
70             }
71         }
72
73         if (null == portlet)
74         {
75             paneID = cont.retrievePaneID(rundata, true);
76             portlet = myPortlets.getPortletByID(paneID);
77             if (null == portlet)
78             {
79                 paneID = cont.retrievePaneID(rundata, false);
80                 portlet = myPortlets.getPortletByID(paneID);
81             }
82         }
83
84         if (portlet != null)
85         {
86             context.put("pane", portlet);
87             String JavaDoc state = portlet.getAttribute("_menustate", "open", rundata);
88             //System.out.println("State = [" + state +"]");
89
// if(state == null || !state.equals("closed"))
90
{
91                 cont.savePaneID(rundata, paneID);
92             }
93         }
94     }
95
96 }
97
Popular Tags