Locating assets

It is possible to reference an asset both inside and outside of the portlet's WAR file.

If a portlet needs to reference assets (for example, images) that are contained in the portlet's WAR file, an asset group policy should not be used in conjunction with the asset policy. The XDIME aggregator wrappers each portlet's markup with the following elements when Image Conversion Service is installed on the WebSphere® Portal server:
<mcsi:portlet-context xmlns:mcsi="http://www.ibm.com/mwp/mcs-integration">
<mcsi:jdbc-policies name="portlet-jdbc-project-name"/>
<mcsi:assets base-url="/wps-context-root/portlet-object-id/"/>
<mcsi:portlet-content>
<%
  The XDIME aggregator will include the portlet's markup here:
%>
</mcsi:portlet-content>
</mcsi:portlet-context>
where
The relative URL to access assets in the portlet's WAR file is constructed as follows:
/base-url-value/value-setting-from-policy-file
where
For example, assume that the following are true: In this case, WebSphere Portal constructs the following relative URL:
/wps/PA_1_0_2H9/images/Cloudy.gif

Using the mwp:mobilePortletContent JSP tag to wrapper XDIME elements

If the portlet needs to reference assets that are outside its WAR file or that require a prefix to be added to the relative URL, it should wrapper the XDIME elements that reference asset policies–for example, the <img> element) with the <mwp:mobilePortletContent> JSP tag. There are different ways to use this JSP tag:

These approaches are described in the following sections.

Referencing an asset within the portlet's WAR file and adding a prefix to the relative URL

To use this approach, invoke the <mwp:mobilePortletContent> JSP tag and specify the <prefixURL> tag. The following example shows how the portlet used in the preceding example could use Image Conversion Service to convert an image that is located inside the portlet's WAR file when Image Conversion Service is installed on the WebSphere_Portal application server:
<mwp:mobilePortletContent enable="true" prefixURL="/ics/ics">

  <unit>
         <img pane="G" src="/weather-cloudy.mimg" alt="no cloud image"/>
  </unit>

</mwp:mobilePortletContent>
Note: In this example, the weather-cloudy.mimg policy would need to define a convertible image asset instead of a generic image asset.

/ics/ics identifies the Image Conversion Service context root and servlet name on the WebSphere_Portal application server.

The mwp:MobilePortletContent JSP tag will generate the following XDIME markup for this example:
<mcsi:portlet-context xmlns:mcsi="http://www.ibm.com/mwp/mcs-integration">
<mcsi:jdbc-policies name="<portlet-jdbc-project-name>"/>
<mcsi:assets base-url="/ics/ics/wps/PA_1_0_2H9/"/>
<mcsi:portlet-content>

  <unit>
         <img pane="G" src="/weather-cloudy.mimg" alt="no cloud image"/>
  </unit>

</mcsi:portlet-content>
</mcsi:portlet-context>
In this case, Multi-Channel Server would construct the following relative URL to access the image:
/ics/ics/wps/PA_1_0_2H9/images/Cloudy.gif

Referencing an asset that is not located in the portlet's WAR file

To use this approach, invoke the <mwp:mobilePortletContent> JSP tag and specify the fullURL parameter. For example, if Cloudy.gif is not in the portlet's project, the portlet used in the preceding example could also contain the following markup:
<mwp:mobilePortletContent enable="true" fullURL="/weather/" />

  <unit>
         <img pane="G" src="/weather-cloudy.mimg" alt="no cloud image"/>
  </unit>

</mwp:mobilePortletContent>
In this case, the <mwp:MobilePortletContent> JSP tag generates the following XDIME markup:
 <mcsi:portlet-context xmlns:mcsi="http://www.ibm.com/mwp/mcs-integration">
<mcsi:jdbc-policies name="<portlet-jdbc-project-name>"/>
<mcsi:assets base-url="/weather/"/>
<mcsi:portlet-content>

  <unit>
         <img pane="G" src="/weather-cloudy.mimg" alt="no cloud image"/>
  </unit>

</mcsi:portlet-content>
</mcsi:portlet-context>
For this example, Multi-Channel Server would generate the following relative URL:
/weather/images/Cloudy.gif
Note: An asset group could be used by the weather-cloudy.mimg policy for this case. The asset group's value would be added to the beginning of the relative URL.



Terms of use
(C) Copyright IBM Corporation 2012. All Rights Reserved.