Examples

The 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.

  • To get portal user information:JSR:

    <cfoutput>#renderRequest.getRemoteUser()#</cfoutput>

    WSRP:

    <cfdump var = #renderRequest.getAttribute("javax.portlet.userinfo")#>

     

  • To display PDF:

    <cfdocument format="pdf" src="http://www.google.com" filename="cfdoc1.pd f " overwrite="true">
    </cfdocument>
    <cfset pdfURL = getPortletResponse().encodeURL(getPortletRequest().getContextPath() & "/<path of pdf>/cfdoc1.pdf")>
    <cfoutput>
    <object data="#pdfURL#" type="application/pdf" width="600" height="400">
    </object>
    </cfoutput>

     

  • To display Ajax components, all the URLs used in portlets must be encoded.

    CFPOD:
    <cfset sourceURL = getPortletResponse().encodeURL(getPortletRequest().getContextPath() & "/<path to cfm>/expandpath.cfm")>
    <cfpod name="pod01" source="#sourceURL#" height="500" width="300" title="Example CFPod"/>
    expandpath:
    <cfoutput>#ExpandPath("./")#</cfoutput>
    CFWINDOW:
    <cfset sourceURL = getPortletResponse().encodeURL(getPortletRequest().getContextPath() & "/<path to cfm>/expandpath.cfm")>
    <cfwindow title="Test Window" name="myWindow" width="200" height="200" initShow="true" source="#sourceURL#">
    </cfwindow>

     

Get help faster and easier

New user?