Define references to static content in an MVCPortlet JSP file


+

Search Tips   |   Advanced Search

 

According to Portal's portlet programming best practices, all static content asset files, such as images and static HTML, should be included into the portlet application for ease of installation and deployment. However, the MVCPortlet also allows external references to these static contents using a URL defined in the URL provider, with a default JNDI name...

However, this JNDI name can be overriden by defining a portlet preference, .ExternalContentURLReference.

A JSP tag, <wcp:encodeURL>, is provided to automatically set the URL prefix of the given static content. This tag uses a JNDI name, defaulted to...

...and can be overriden by using a portlet preference called .ExternalContentURLReference, to resolve the deployed location of static content. This tag takes in two optional attributes as well:

remote

States whether to use the URL prefix from the URL provider. The default is true.

escapeStore

States whether to exclude the store directory prefix. The default is false.

There are three possible use case scenarios for store related static content:

  1. On the WebSphere Portal web server. For example:

      <wcp:encodeURL url="images/catalog/something.jsp" />

    ...with external URL reference set to...

      http://portal_server_web_server/alias

  2. Within the MVCPortlet WAR. For example:

      <wcp:encodeURL url="images/catalog/something.jsp" remote="false" />

  3. Remotely on a WebSphere Commerce web server. For example:

      <wcp:encodeURL url="images/catalog/something.jsp" />

    ...with external URL reference set to...

      http://hostname/wcsstore

With the additional escapeStore attribute, it is possible to include references to static content which can be used generically across all stores. Setting the escapeStore attribute to "true" will make the tag exclude the store directory in the resulting URL.

The final URL to the static content will be composed of 3 parts:

An example of a non-store specific local static content reference is:

and this will produce an output of:

this URL will be encoded by WebSphere Portal Server.

An example of a store specific remote static content reference is:

and this will produce an output of:

where the URL provider says http://hostname/wcsstore and ConsumerDirect is the store directory used for the current storeId in the business content.

Related concepts


WebSphere Commerce Portal integration and WebSphere Commerce stores


WebSphere Commerce integration with WebSphere Portal


WebSphere Commerce Portal Integration site architecture

Last updated: 25 November 2009