Static content in Struts


Portlet JSPs cannot link directly to static content within the portlet's WAR directory structure. Instead, they have to use the services of the portlet container to create portlet URIs from which the content can be referenced. Links within static pages (for example, HTML pages) also need to be converted into portlet URIs. The Struts Portlet Framework processes links to static content and converts them to the form of portlet URIs so that linked content is brought back into the portlet and displayed.

 

Create a Home button for static content

When the Struts Portlet Framework is used to display static content, it can be difficult to navigate back through a number of screens to a location earlier in the browser history. To overcome this, you can add a homeFromStatic forward to your action mapping which references the static content. This causes a home button to be added to your static content. Pressing the home button causes the link specified by the homeFromStatic forward to be used.

As with any action mapping, it is possible also to use a global forward. Thus, if for all sequences of static pages it was desired to use the same link for every home button, one could use a global forward, as follows:

  <global-forwards>
    <forward name="homeFromStatic"     path="/index.jsp"/>
     ...
  </global-forwards>

A homeForStatic forward can also be created for a specific ActionMapping, as follows:

  <action path="/staticpage"             
          type="org.apache.struts.actions.ForwardAction"
     parameter="/html/view/static.html">
     <forward   name="homeFromStatic"       path="/index.jsp"/>
  </action>

The home button is not only placed on the first static content page, but on all pages generated by links resulting from that page. If no homeFromStatic forward is found with the action mapping which initiated the sequence of static content pages, and there is no global homeFromStatic forward either, the home button is not generated.

 

See also

Home |