ColdFusion 9.0 Resources |
ColdFusion portlet componentsYou can configure your ColdFusion portlet components to define its modes, window states, title, scope, and parameters. For references of ColdFusion Portlet API, see the JSR-168 specification for all javax.portlet.* classes. Currently, WSRP 1.0 is the supported standard for portlets. Portlet modesPortal servers typically allow three portlet modes: View, Edit, and Help. The View mode is the default state when rendering a portlet. The portlet window has links in the title bar that enable you to change the mode to Help or Edit. To add a Help mode view, add the doHelp() with the same signature as the doView() function. To support the edit mode create the doEdit(). Portlet window statesMost portal servers support three window states (normal, minimized, and maximized). You can obtain the current window state by calling the getWindowState() method of the ColdFusionPortlet base component. Portlet titleTo set the portlet title, add a method to the CFC called getTitle as follows: <cffunction name="getTitle" returntype="string" output="false" access="public"> <cfargument name="renderRequest" type="any" required="true" hint="A javax.portlet.RenderRequest java object"> <cfreturn "My ColdFusion Portlet"> </cffunction> Portlet scopeThe ColdFusion portlet toolkit defines the variable request.portlet. It contains the following structures: request.portlet.parameters - Parameters of the Portlet Request request.portlet.attributes - attributes of the Portlet Request request.portlet.properties - properties of the Portlet Request These variables are defined for convenience and convention. Create portlet parametersTo create different page views within your portlet you can configure the render parameters such as renderURL. For example, to set the renderURL parameter:
Processing actions using form postsTo process a form post, use the createActionURL() function, which generates the form action URL. For example: <cfoutput> <form action="#createActionURL()#" method="post"> Value: <input type="text" name="action_value" > <input type="submit" value="Process Action" /> </form> </cfoutput> When the form is submitted, the portal container calls the processAction() method in your CFC. So, add this method as follows: <cffunction name="processAction" returntype="void" access="public" output="false" hint="Called by the portlet container to allow the portlet to process an action request."> <cfargument name="actionRequest" type="any" required="true" hint="A javax.portlet.ActionRequest java object"> <cfargument name="actionResponse" type="any" required="true" hint="A javax.portlet.ActionResponse java object"> <cfif IsDefined("request.portlet.parameters.action_value")> <!--- do something with this value, such as update your database ---> </cfif> </cffunction> ExamplesThe following examples show how you can configure portlets. You can add the following code to the doView() method depending on whether you are configuring the portlet on a local or remote server.
|