Build a portlet for a local server

To write a ColdFusion portlet:

  1. Create a CFC that extends the CFIDE.portlets.ColdFusionPortlet package.

    For example, the following HelloPortlet.cfc extends this package and defines the doView() and doHelp() methods:

    <cfcomponent extends="CFIDE.portlets.ColdFusionPortlet"> 
         
        <cffunction name="doView" returntype="void" output="true"> 
            <cfargument name="renderRequest" type="any" required="true" hint="A 
            javax.portlet.RenderRequest java object"> 
            <cfargument name="renderResponse" type="any" required="true" hint="A 
            javax.portlet.RenderResponse java object"> 
            <cfoutput> 
                Hello World ColdFusion Portlet 
            </cfoutput> 
        </cffunction> 
        <cffunction name="doHelp" returntype="void" output="true"> 
            <cfargument name="renderRequest" type="any" required="true" hint="A                  
            javax.portlet.RenderRequest java object"> 
            <cfargument name="renderResponse" type="any" required="true" hint="A 
            javax.portlet.RenderResponse java object"> 
            <h1>ColdFusion Help</h1> 
            <p>This is a Help message for the Hello Portlet.</p> 
        </cffunction> 
    </cfcomponent>
  2. Save HelloPortlet.cfc in <jboss_server_home>\server\default\deploy\cfusion.ear\cfusion.war\portlets\hello.

  3. Define HelloPortlet.cfc in portlet.xml, which is located in the WEB-INF folder of ColdFusion web root. The portlet.xml file looks similar to the following:

    <?xml version="1.0" encoding="UTF-8"?> 
    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0"> 
        <portlet> 
            <description xml:lang="en">This Portlet is a Hello World CF Portlet</description> 
            <portlet-name>ColdFusionPortlet</portlet-name> 
            <display-name xml:lang="en">CF Hello Portlet</display-name> 
            <portlet-class>coldfusion.portlet.ColdFusionPortlet</portlet-class> 
            <init-param> 
                    <name>cfcName</name> 
                      <value>portlets.hello.HelloPortlet</value> 
            </init-param> 
            <supports> 
                <mime-type>text/html</mime-type> 
                <portlet-mode>VIEW</portlet-mode> 
                <portlet-mode>HELP</portlet-mode> 
            </supports> 
            <portlet-info> 
                <title>ColdFusion Hello World Portlet</title> 
            </portlet-info> 
        </portlet> 
    </portlet-app>

    The portlet is defined and registered for portlet definition, with targeted cfcName defined as the INIT parameter. The INIT parameter value must be from the web root of ColdFusion.

  4. Run the JBoss server by running one of the following commands:

    On UNIX

    <JBoss_home>/bin/run.sh

    On Windows

    <JBoss_home>\bin\run.bat

    By default JBoss only binds to localhost. You can have it bind to any IP address by running bin/run.sh -b 0.0.0.0 on UNIX or bin/run.bat -b 0.0.0.0 on Windows.

  5. Launch the JBoss portal server. By default, JBoss binds to port 8080, so launch the server using the URL: http://<matching_IP>:<port>/portal/.

    For example: http://127.0.0.1:8080/portal.

  6. Log in to the portal by clicking the login link in the upper-right corner. The default credentials are admin/admin.

  7. Click the Admin option in the upper-right corner.

  8. Click the Portlet Definitions tab. The portlet name, CF HelloPortlet is listed here.

    View full size graphic
    Portal definition tab displaying CFHelloPortlet

  9. Create an instance of this portlet by clicking Create Instance under Actions.

  10. Specify the instance name.

  11. Add the instance display name.

    View full size graphic
    Adding instance of CFHelloPortlet

  12. Click the Portal Objects tab.

  13. Create a new portal page by specifying the portal name in the Create a portal named box.

    View full size graphic
    Creating a portal

  14. Select the created portal page from the list of portals.

  15. From Actions, select Page Layout.

    View full size graphic
    Managing created portal

  16. From the Portlet instance associated with this Window list, select the portlet instance you created in step 10.

    View full size graphic
    Portal instance selected

  17. In the Page Layout section, click Add for the center region or left region to add the portlet container in the required area.

  18. Go back to the Portal Objects > Portals page and select Make Default option to set the new portal as default.

  19. Click the Portal option on the upper-right corner to view the new portal page containing the portlet.

    View full size graphic
    Portal displaying CFHelloPortlet