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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.portal;
1819import org.apache.jetspeed.util.MimeType;
20import org.apache.turbine.util.RunData;
21import org.apache.ecs.ConcreteElement;
2223import java.io.Serializable;
24/***25A portlet is an implementation of a small control (usually rendered in HTML)26that is available to a client application. Portlets were designed to be27extensible so that 3rd parties implement their own Portlets.2829@author <a href="mailto:burton@apache.org">Kevin A. Burton</a>30@version $Id: Portlet.java,v 1.48 2004/03/29 21:38:42 taylor Exp $31*/32publicinterfacePortletextends Serializable
33 {
3435publicint PORTLET_NORMAL = 0;
36publicint PORTLET_MINIMIZED = 1;
37publicint PORTLET_MAXIMIZED = 2;
3839/***40 Returns a name for this portlet. This is used by PSML to identify a Portlet41 within the PortletRegistry42 */43public String getName();
4445/***46 Sets the name on this Portlet.4748 @see #getName()49 */50publicvoid setName(String name);
5152/***53 <p>54 Allows a Portlet to define its title. This can be used by a PortletControl55 for rendering its content.56 </p>5758 <p>59 In order to define a default title you should not override this but should60 call setTitle() within your init() method61 </p>6263 <p>64 This should return null if not specified.65 </p>66 */67public String getTitle();
6869/***70 * Get a title for this instance of the portlet. This method is called71 * from the context variable portlet_instance and from PortletInstance72 *73 * If you wish to append to the title, then you code should look like74 * getTitle( String instanceTitle)75 * {76 * return super.getTitle( instanceTitle) + " - Appened title text";77 * }78 *79 * @param instanceTitle Title from PSML80 */81public String getTitle( String instanceTitle);
8283/***84 Set the title for this Portlet85 */86publicvoid setTitle( String title );
8788/***89 <p>90 Returns a description of this portlet. This should describe what the91 capabilities of the portlet and how it can help the user.92 </p>9394 <p>95 In order to define a default title you should not override (in the96 AbstractPortlet implementation) this but should call setDescription()97 within your init() method98 </p>99100 <p>101 This should return null if not specified.102 </p>103 */104public String getDescription();
105106/***107 * Get a Description for this instance of the portlet. This method is called108 * from the context variable portlet_instance and from PortletInstance109 *110 * If you wish to append to the Description, then you code should look like111 * getDescription( String instanceTitle)112 * {113 * return super.getDescription( instanceDescription) + " - Appened Description text";114 * }115 *116 * @param instanceDescription Description from PSML117 */118public String getDescription( String instanceDescription);
119120/***121 Set the description for this Portlet122 */123publicvoid setDescription( String description );
124125/***126 * Getter for property image. 127 * @return Name of portlet image, icon. The name is expected to be in the form of a URL.128 */129public String getImage(String instanceImage);
130131/***132 * Setter for property image. 133 */134publicvoid setImage(String instanceImage);
135136/***137 Returns an HTML representation of this portlet. Usually a Portlet would138 initialized itself within init() and then when getContent is called it139 would return its presentation.140 */141public ConcreteElement getContent(RunData rundata);
142143144/***145 All initialization should be performed here. If your Portlet wants to146 do any work it should be done here. You are not guaranteed that any147 particular order of method call will happen just that init() will happen148 first. Therefore if you have to calculate things like a title, a149 description, etc it should happen here.150 */151publicvoid init( ) throws PortletException;
152153154/***155 Set's the configuration of this servlet.156 */157publicvoid setPortletConfig(PortletConfig pc);
158159160/***161 Get the config of this servlet.162 */163publicPortletConfig getPortletConfig();
164165/***166 <p>Return true if this portlet is allowed to be edited in the rundata's context .</p>167168 <p>Note: PortletControl implementations should pay attention to this so169 that they don't allow this option if it returns false.</p>170 */171publicboolean getAllowEdit( RunData rundata );
172173/***174 <p>Return true if this portlet is allowed to be viewed in the rundata's context .</p>175176 <p>Note: PortletControl implementations should pay attention to this so177 that they don't allow this option if it returns false.</p>178 */179publicboolean getAllowView( RunData rundata );
180181/***182 <p>Return true if this portlets is allowed to be maximized.</p>183184 <p>Note: PortletControl implementations should pay attention to this so185 that they don't allow this option if it returns false.</p>186 */187publicboolean getAllowMaximize( RunData rundata );
188189/***190 Get the creation time for this Portlet191 */192publiclong getCreationTime();
193194/***195 * Returns TRUE if the title bar in should be displayed. The title bar includes196 * the portlet title and action buttons. This197 * 198 * @param rundata The RunData object for the current request199 */200publicboolean isShowTitleBar(RunData rundata);
201202/***203 Set the creation time for this Portlet204 */205publicvoid setCreationTime( long creationTime );
206207/***208 Returns true portlet is able to output content for given mimetype209 */210publicboolean supportsType( MimeType mimeType );
211212/***213 * Retrieve a portlet attribute from persistent storage214 *215 * @param attrName The attribute to retrieve216 * @param attrDefValue The value if the attr doesn't exists217 * @param rundata The RunData object for the current request218 * @return The attribute value219 */220public String getAttribute( String attrName, String attrDefValue, RunData rundata );
221222223/***224 * Stores a portlet attribute in persistent storage225 *226 * @param attrName The attribute to retrieve227 * @paarm attrValue The value to store228 * @param rundata The RunData object for the current request229 */230publicvoid setAttribute( String attrName, String attrValue, RunData rundata );
231232233/***234 * Gets the portlet instance associated with this portlet.235 *236 * @return PortletInstance237 */238publicPortletInstance getInstance(RunData rundata);
239240/***241 Retrieve a unique portlet id 242 */243public String getID();
244245publicvoid setID(String id);
246247/***248 * @return true if the portlet does its own customization249 */250publicboolean providesCustomization();
251252 }
253