raphael 01/05/29 16:15:44
Modified: src/java/org/apache/jetspeed/modules/actions/controls
Customize.java Maximize.java Restore.java
src/java/org/apache/jetspeed/util/customization
PSMLEntry.java
Added: src/java/org/apache/jetspeed/modules/actions/controls
Close.java CustomizeDone.java
src/java/org/apache/jetspeed/modules/actions/portlets
HelloAction.java VelocityPortletAction.java
Log:
initial landing of VelocityPortlet and VelocityPortletAction
+ test Velocity Portlet (HelloVelocity)
+ modification of PSML files to test it out
Revision Changes Path
1.2 +3 -11
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Customize.java
Index: Customize.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Customize.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Customize.java 2001/05/28 15:16:31 1.1
+++ Customize.java 2001/05/29 23:15:38 1.2
@@ -59,11 +59,7 @@
import org.apache.turbine.util.RunData;
// Jetspeed stuff
-import org.apache.jetspeed.portal.Portlet;
-import org.apache.jetspeed.portal.PortletException;
-import org.apache.jetspeed.portal.factory.PortletFactory;
-import org.apache.jetspeed.services.Registry;
-import org.apache.jetspeed.om.newregistry.PortletEntry;
+import org.apache.jetspeed.portal.PortalState;
/**
@@ -79,14 +75,10 @@
String name = rundata.getParameters().getString ( "portlet", null );
if ( name == null )
{
- rundata.setScreenTemplate("Ecs");
return;
}
- // redirect to the default customizer template
- // rundata.setScreenTemplate("Customize");
-
- // redirect to info while customization portlet not committed
- rundata.setScreenTemplate("Info");
+ PortalState.setMaximized(name, rundata);
+ PortalState.setCustomized(name, rundata);
}
}
1.2 +2 -5
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Maximize.java
Index: Maximize.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Maximize.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Maximize.java 2001/05/28 15:16:31 1.1
+++ Maximize.java 2001/05/29 23:15:39 1.2
@@ -61,6 +61,7 @@
// Jetspeed stuff
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortletState;
+import org.apache.jetspeed.portal.PortalState;
import org.apache.jetspeed.portal.PortletException;
import org.apache.jetspeed.portal.factory.PortletFactory;
import org.apache.jetspeed.services.Registry;
@@ -92,10 +93,6 @@
return;
}
- // save the new portal state : maximized
- rundata.getSession().setAttribute("maximize",name);
-
- // redirect to the default Maximized template
- rundata.setScreenTemplate("Show");
+ PortalState.setMaximized(name, rundata);
}
}
1.2 +2 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Restore.java
Index: Restore.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Restore.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Restore.java 2001/05/28 15:16:31 1.1
+++ Restore.java 2001/05/29 23:15:39 1.2
@@ -61,6 +61,7 @@
// Jetspeed stuff
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortletState;
+import org.apache.jetspeed.portal.PortalState;
import org.apache.jetspeed.portal.PortletException;
import org.apache.jetspeed.portal.factory.PortletFactory;
import org.apache.jetspeed.services.Registry;
@@ -101,7 +102,7 @@
}
// if restore was called because of maximize, remove the maximize state
- rundata.getSession().removeAttribute("maximize");
+ PortalState.reset(rundata);
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Close.java
Index: Close.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.modules.actions.controls;
// Turbine stuff
import org.apache.turbine.modules.Action;
import org.apache.turbine.util.RunData;
// Jetspeed stuff
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortalState;
import org.apache.jetspeed.portal.PortletState;
import org.apache.jetspeed.portal.PortletException;
import org.apache.jetspeed.portal.factory.PortletFactory;
import org.apache.jetspeed.services.Registry;
import org.apache.jetspeed.om.newregistry.PortletEntry;
/**
* Change the internal state of a portlet from normal to closed
*
* @author <a href="mailto:[EMAIL PROTECTED]">Roberto Carrasco</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
*/
public class Close extends Action
{
public void doPerform( RunData rundata ) throws Exception
{
if( rundata.getUser() == null || !rundata.getUser().hasLoggedIn() )
{
return;
}
String name = rundata.getParameters().getString ( "portlet", null );
if ( name == null )
{
return;
}
PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET, name
);
if ( entry == null )
{
return;
}
Portlet portlet = PortletFactory.getPortlet( entry );
if (( portlet != null )&&( portlet instanceof PortletState ))
{
((PortletState)portlet).setClosed( true, rundata );
}
//make sure the portal reset its state
PortalState.reset(rundata);
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/CustomizeDone.java
Index: CustomizeDone.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.modules.actions.controls;
// Turbine stuff
import org.apache.turbine.modules.Action;
import org.apache.turbine.util.RunData;
// Jetspeed stuff
import org.apache.jetspeed.portal.PortalState;
/**
* Reset the customization state to null.
* This action must be called by any customizer element when it has finished
* customizing the element.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
*/
public class CustomizeDone extends Action
{
public void doPerform( RunData rundata ) throws Exception
{
PortalState.reset(rundata);
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/HelloAction.java
Index: HelloAction.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.modules.actions.portlets;
import org.apache.jetspeed.portal.portlets.VelocityPortlet;
// Turbine stuff
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
// Velocity Stuff
import org.apache.velocity.context.Context;
/**
* An abstract action class to build VelocityPortlet actions.
*
* <p>Don't call it from the URL, the Portlet and the Action are automatically
* associated through the registry PortletName
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
*/
public class HelloAction extends VelocityPortletAction
{
/**
* Subclasses should override this method if they wish to
* build specific content when maximized. Default behavior is
* to do the same as normal content.
*/
protected void buildMaximizedContext( VelocityPortlet portlet,
Context context,
RunData rundata )
{
buildNormalContext( portlet, context, rundata);
String text = (String)context.get("text");
if (text == null)
{
text = "Hello World ";
}
context.put("text", text+" (Maximized !)");
}
/**
* Subclasses should override this method if they wish to
* provide their own customization behavior.
* Default is to use Portal base customizer action
*/
protected void buildConfigureContext( VelocityPortlet portlet,
Context context,
RunData rundata )
{
buildNormalContext( portlet, context, rundata);
setTemplate(rundata, "hello-customize");
}
/**
* Subclasses must override this method to provide default behavior
* for the portlet action
*/
protected void buildNormalContext( VelocityPortlet portlet,
Context context,
RunData rundata )
{
context.put("text",portlet.getPortletConfig().getInitParameter("text"));
}
public void doUpdate(RunData data, Context context)
{
String text = data.getParameters().getString("text");
if (text!=null)
{
VelocityPortlet portlet = (VelocityPortlet)context.get("portlet");
portlet.setAttribute("text",text,data);
context.put("text",text);
context.put("message", "Text successfully updated");
}
else
{
context.put("message", "You must specify a new text");
}
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/VelocityPortletAction.java
Index: VelocityPortletAction.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.modules.actions.portlets;
import org.apache.jetspeed.portal.portlets.VelocityPortlet;
import org.apache.jetspeed.portal.PortalState;
// Turbine stuff
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
import org.apache.turbine.modules.Action;
import org.apache.turbine.modules.actions.VelocityAction;
// Velocity Stuff
import org.apache.velocity.context.Context;
/**
* An abstract action class to build VelocityPortlet actions.
*
* <p>Don't call it from the URL, the Portlet and the Action are automatically
* associated through the registry PortletName
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Roberto Carrasco</a>
*/
public abstract class VelocityPortletAction extends VelocityAction
{
/**
* This overrides the default Action.perform() to execute the
* doEvent() method. If that fails, then it will execute the
* doPerform() method instead.
*
* @param data A Turbine RunData object.
* @exception Exception, a generic exception.
*/
protected void perform( RunData rundata )
throws Exception
{
try
{
// first try to see if there are some events registered for this
// action...
executeEvents(rundata, getContext(rundata) );
}
catch (NoSuchMethodException e)
{
// no event selected
doPerform(rundata);
}
}
/**
* This method is used when you want to short circuit an Action
* and change the template that will be executed next.
*
* @param data Turbine information.
* @param template The template that will be executed next.
*/
public void setTemplate(RunData data,
String template)
{
getContext(data).put( "template" , template );
}
/**
* Return the Context needed by Velocity.
*
* @param RunData data
* @return Context, a context for web pages.
*/
protected Context getContext(RunData data)
{
return (Context)data.getTemplateInfo()
.getTemplateContext( "VelocityPortletContext" );
}
public void doPerform( RunData rundata, Context context )
{
VelocityPortlet portlet = (VelocityPortlet)context.get( "portlet" );
// we're bein configured
if ( portlet.getName().equals( PortalState.getCustomized( rundata ) ) )
{
buildConfigureContext( portlet, context, rundata);
return;
}
// we're maximized
if ( portlet.getName().equals( PortalState.getMaximized( rundata ) ) )
{
buildMaximizedContext( portlet, context, rundata);
return;
}
buildNormalContext( portlet, context, rundata);
}
/**
* Subclasses should override this method if they wish to
* build specific content when maximized. Default behavior is
* to do the same as normal content.
*/
protected void buildMaximizedContext( VelocityPortlet portlet,
Context context,
RunData rundata )
{
buildNormalContext( portlet, context, rundata);
}
/**
* Subclasses should override this method if they wish to
* provide their own customization behavior.
* Default is to use Portal base customizer action
*/
protected void buildConfigureContext( VelocityPortlet portlet,
Context context,
RunData rundata )
{
//FIXME: call the default CustomizePortlet action when written
}
/**
* Subclasses must override this method to provide default behavior
* for the portlet action
*/
protected abstract void buildNormalContext( VelocityPortlet portlet,
Context context,
RunData rundata );
}
1.3 +0 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/util/customization/PSMLEntry.java
Index: PSMLEntry.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/customization/PSMLEntry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PSMLEntry.java 2001/05/28 16:08:26 1.2
+++ PSMLEntry.java 2001/05/29 23:15:43 1.3
@@ -68,7 +68,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Yoo </a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ernest Ros </a>
- * @version $Id: PSMLEntry.java,v 1.2 2001/05/28 16:08:26 raphael Exp $
+ * @version $Id: PSMLEntry.java,v 1.3 2001/05/29 23:15:43 raphael Exp $
*
*/
public class PSMLEntry
@@ -187,7 +187,6 @@
Entry result = new Entry();
result.setParent(entry.getName());
result.setLayout(layout);
- result.setType(entry.getType().toString());
return result;
}// end portletEntryToEntry
}// end class PSMLEntry
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]