KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > portlets > HelloPortlet


1 package org.apache.jetspeed.modules.actions.portlets;
2
3 import org.apache.jetspeed.portal.portlets.AbstractVTLPortlet;
4
5 // Turbine stuff
6
import org.apache.turbine.util.RunData;
7
8 // Velocity Stuff
9
import org.apache.velocity.context.Context;
10
11
12 /**
13 Hello world portlet supporting min/restore/conf/max/close buttons
14
15 @author <a HREF="mailto:re_carrasco@bco011.sonda.cl">Roberto Carrasco</a>
16 */

17 public class HelloPortlet extends AbstractVTLPortletAction
18 {
19     private final static String JavaDoc DEFAULT_SALUDO = "Welcome";
20     private final static String JavaDoc DEFAULT_ANONIMO = "Welcome anonymous";
21
22     // called when config button pressed
23
public void setConfigureContent( AbstractVTLPortlet xPortlet, Context context, RunData rundata )
24     {
25         String JavaDoc saludo = xPortlet.getAttribute( "saludo", DEFAULT_SALUDO, rundata );
26
27         // In config mode, i require another template
28
context.put( "vtlTemplate", "HelloConfigPortlet" );
29         context.put( "saludo", saludo );
30     }
31
32     // called when max button pressed
33
public void setMaximizedContent( AbstractVTLPortlet xPortlet, Context context, RunData rundata, boolean loggedUser )
34     {
35         String JavaDoc saludo = xPortlet.getAttribute( "saludo", loggedUser ? DEFAULT_SALUDO : DEFAULT_ANONIMO, rundata );
36
37         // just a demo, sorry
38
saludo = "<font style='font-size: 40pt; '>" + saludo + "</font>";
39         context.put( "saludo", saludo );
40     }
41
42     // called in minimized state
43
public void setMinimizedContent( AbstractVTLPortlet xPortlet, Context context, RunData rundata )
44     {
45         String JavaDoc saludo = xPortlet.getAttribute( "saludo", DEFAULT_SALUDO, rundata );
46
47         // i have no data area, so use the title bar
48
xPortlet.setTitle( saludo );
49     }
50
51     // called in normal state
52
public void setNormalContent( AbstractVTLPortlet xPortlet, Context context, RunData rundata, boolean loggedUser )
53     {
54         String JavaDoc saludo = xPortlet.getAttribute( "saludo", loggedUser ? DEFAULT_SALUDO : DEFAULT_ANONIMO, rundata );
55
56         // normal state
57
context.put( "saludo", saludo );
58     }
59
60 }
Popular Tags