28-Oct-06 (Created: 28-Oct-06) | More in 'Java-Portlets'

How to use AspirePortlet in Liferay

Initialize Aspire in your web.xml


       <servlet>
        <servlet-name>
            AppInitServlet
        </servlet-name>
        <servlet-class>
            com.ai.servlets.AppInitServlet1
        </servlet-class>
        <init-param>
            <param-name>AppConfigFilename</param-name>
            <param-value>indent/aspire.properties</param-value>
        </init-param>
      <load-on-startup>
         1
      </load-on-startup>
    </servlet>

The path of aspire.properties will be relative to the sub directories in your web root. If you are using a war distribution with out expansion, you can use AppInitServlet2

Include aspire-portlet.properties in your aspire.properties

Please see this at the end of this page for this as it is a bit long with all the examples

Aspire Portlet Definition


   <portlet>
      <portlet-name>AspirePortlet2</portlet-name>
      <display-name>AspirePortlet2</display-name>
      <portlet-class>com.indent.portals.test.AspirePortlet</portlet-class>
      <expiration-cache>0</expiration-cache>
      <supports>
         <mime-type>text/html</mime-type>
      </supports>
      <portlet-info>
         <title>Aspire Portlet Title 2</title>
         <short-title>Aspire Portlet Short Title 2</short-title>
         <keywords>Aspire Portlet key words 2</keywords>
      </portlet-info>
      <portlet-preferences>
         <preference>
            <name>startingurl</name>
            <value>GlobalStartingURL</value>
         </preference>
      </portlet-preferences>
      <security-role-ref>
         <role-name>power-user</role-name>
      </security-role-ref>
      <security-role-ref>
         <role-name>user</role-name>
      </security-role-ref>
   </portlet>
  

GlobalStartingURL

This a starting parameter for the aspire portlet. when the portlet is displayed this is the url that it is going to go for.

Here is how this is defined


GlobalStartingURL=/indent/aspire-test.jsp
GlobalStartingURL.transformtype=jsp
request.GlobalStartingURL.transform.className=com.ai.jsp.JSPIncludeTransform

GlobalStartingURL.dataRequestName=StandardData

StandardData

StandardData is used to define a common data for a jsp page. Use this data definition if your jsp page does not contan anything but the url and session parameters.


request.StandardData.classname=com.ai.htmlgen.DBHashTableFormHandler1

Example aspire-test.jsp

Notice how the urls back into the system are defined using the portlet tags


<%@ include file="/html/portlet/init.jsp" %>
<h4>Asprie Test JSP</h4>
<p>Hello there </p>

<portlet:renderURL var="homeurl">
   <portlet:param name="url" value="IndentHomeURL"/>
</portlet:renderURL>

<portlet:renderURL var="homeurl2">
   <portlet:param name="url" value="IndentHome2URL"/>
</portlet:renderURL>

<portlet:renderURL var="testUpdateURL">
   <portlet:param name="url" value="TestUpdateURL"/>
</portlet:renderURL>

<p><a href="<%=homeurl%>" >
1. Go home
</a></p>

<p><a href="<%=homeurl2%>" >
2. Go home 2
</a></p>

<p><a href="<%=testUpdateURL%>" >
3. TestUpdate
</a></p>

Example of Update


<%@ include file="/html/portlet/init.jsp" %>
<h4>Asprie Test JSP</h4>
<p>Hello there </p>

<portlet:renderURL var="homeurl">
   <portlet:param name="url" value="IndentHomeURL"/>
</portlet:renderURL>

<portlet:renderURL var="homeurl2">
   <portlet:param name="url" value="IndentHome2URL"/>
</portlet:renderURL>

<form name="TestUpdateForm" method="post" action="<portlet:actionURL/>">
<p>Enter a name
<p>
<input type="text" name="helloText" size="20"/>
<input type="hidden" name="request_name" value="updateTestAction"/>
<input type="submit" name="submitbutton" value="submit"/>
</form>

Update properties section


TestUpdateURL=/indent/test-update.jsp
TestUpdateURL.transformtype=jsp
request.TestUpdateURL.transform.className=com.ai.jsp.JSPIncludeTransform
TestUpdateURL.dataRequestName=StandardData

request.updateTestAction.classname=\
com.indent.portals.liferay.PortletSessionUpdaterPart
request.updateTestAction.keynames=helloText

aspire-portlet.properties


#
#***********************************************************
# Global responses to a portlet processAction
#***********************************************************
#

#
#The following url will be painted if the action is successful
#This will happen if you haven't specified any redirecturl for the action
#You can specialize this using jsp or aspire stuff
#The output will be inside that portlet
#
aspire.portlets.defaultSuccessRedirectURL=/your-webapp/portlet?url=defaultSuccessURL

defaultSuccessURL=aspire:\\indent\\common\\success.html
defaultSuccessURL.dataRequestName=StandardData

#
#The following url will be painted if the action fails
#This will happen if you haven't specified any failure redirecturl for the action
#You can specialize this using jsp or aspire stuff
#The output will be inside that portlet
#
aspire.portlets.globalfailureURL=/yourwebapp/portlet?url=defaultFailureURL\
&error={aspire_error_message}&rootCause={aspire_root_cause}

defaultFailureURL=aspire:\\indent\\common\\failure.html
defaultFailureURL.dataRequestName=StandardData

#
#***********************************************************
# The following class is responsible for handling errors
# in the action phase of the portlet
# optional: default (com.indent.portals.test.PortletActionFailureResponse)
# Usually this is decided by Aspire Portlet development team
# Application developers don't have to deal with this
#***********************************************************
#
aspire.portlets.actionFailureResponse.classname=\
com.indent.portals.test.PortletActionFailureResponse

#
#***********************************************************
# This class provides an abstraction similar to
# clientside and server side redirectors.
# (optional)
# default value (com.indent.portals.test.PortletActionRedirector)
#***********************************************************
#
request.aspire.portlets.portletactionredirector.classname=\
com.indent.portals.test.PortletActionRedirector

#
#***********************************************************
# This class provides an abstraction similar to
# display servlet. Responsible for rendering phase
# Usually this is decided by Aspire Portlet development team
# Application developers don't have to deal with this
#***********************************************************
#
request.aspire.portlets.RenderPortletService.classname=\
com.indent.portals.test.PortletPageDispatcher
#
#***********************************************************
# This class provides an abstraction similar to
# update servlet. Responsible for action phase
# Usually this is decided by Aspire Portlet development team
# Application developers don't have to deal with this
#***********************************************************
#
request.aspire.portlets.ActionPortletService.classname=\
com.indent.portals.test.UpdatePortletService

#
#***********************************************************
# This class loads the user configuration stuff into url
# Usually this is decided by Aspire Portlet development team
# Application developers don't have to deal with this
# This has the potential of separating the liferay dependency
#***********************************************************
#
request.aspire.portlets.putUserDetails.classname=\
com.indent.portals.liferay.FillUserDetailsPart


#
#***********************************************************
# Standard data definition
# you can reuse this data definition if all you need
# is data from the url parameters
#***********************************************************
#
request.StandardData.classname=com.ai.htmlgen.DBHashTableFormHandler1


#
#***********************************************************
# If you don't specify a starting url, this is where each
# aspire portlet starts.
# You are strongly recommended to specify a starting url though
# Usually this is decided by Aspire Portlet development team
# Application developers don't have to deal with this
#***********************************************************
#
AspirePortletGlobalStartingURL=GlobalStartingURL

#GlobalStartingURL=aspire:\\indent\\home.html
#GlobalStartingURL.dataRequestName=StandardData

GlobalStartingURL=/indent/aspire-test.jsp
GlobalStartingURL.transformtype=jsp
request.GlobalStartingURL.transform.className=com.ai.jsp.JSPIncludeTransform

GlobalStartingURL.dataRequestName=StandardData


#
#***********************************************************
# Some example urls
# This is the domain of application developers
#***********************************************************
#
IndentHomeURL=aspire:\\indent\\home.html
IndentHomeURL.dataRequestName=StandardData

IndentHome2URL=aspire:\\indent\\home2.html
IndentHome2URL.dataRequestName=StandardData

#
#***********************************************************
# Testing update
#***********************************************************
#
TestUpdateURL=/indent/test-update.jsp
TestUpdateURL.transformtype=jsp
request.TestUpdateURL.transform.className=com.ai.jsp.JSPIncludeTransform
TestUpdateURL.dataRequestName=StandardData

request.updateTestAction.classname=com.indent.portals.liferay.PortletSessionUpdaterPart
request.updateTestAction.keynames=helloText