Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0-dev/cvs
-
None
-
Linux, J2SE
Description
===============
Header Resource
===============
Overviews:
----------
Header Resource component allows user to add tags, such as <link> and
<script> tag into <head> tag. Currently, Jetspeed2 puts only decorators
stylesheet tag into <head> tag. But, using Header Resource Component,
user can put user-defined stylesheet and javascript file from portal or
portlet.
Design:
-------
i) Process to add tags to HeaderResource component
---------------------------
JetspeedPortletServices.. |
---------------------------
V
--------------------------------------------
o.a.j.headerresource.HeaderResourceFactory |
--------------------------------------------
getHeaderResouce(RequestContext requestContext) V ------------------------------------- |
o.a.j.headerresource.HeaderResource |
-------------------------------------
A Add tag into Set for HeaderResource
addHeaderInfo(), addJavaScript(), addStyleSheet() Tag (<link> and <script>) |
ii) Process to get tags from HeaderResource component
---------------------------
JetspeedPortletServices.. |
---------------------------
V
--------------------------------------------
o.a.j.headerresource.HeaderResourceFactory |
--------------------------------------------
getHeaderResouce(RequestContext requestContext) V ------------------------------------- |
o.a.j.headerresource.HeaderResource |
-------------------------------------
toString() V Template file(ex. decorator-tom.vm) |
Task Lists:
-----------
Added Interfaces
----------------
o org.apache.jetspeed.headerresource.HeaderResource
public abstract HeaderResource getHeaderResouce(RequestContext requestContext);
public abstract HeaderResource getHeaderResouce(PortletRequest request);
o org.apache.jetspeed.headerresource.HeaderResourceFactory
public abstract String toString();
public abstract void addHeaderInfo(String elementName, Map attributes);
public abstract void addJavaScript(String path, boolean defer);
public abstract void addJavaScript(String path);
public abstract void addStyleSheet(String path);
Added Classes
-------------
components/src/java/org/apache/jetspeed/headerresource/impl/HeaderResourceFactoryImpl.java
components/src/java/org/apache/jetspeed/headerresource/impl/HeaderResourceImpl.java
- HeaderResourceImpl class creates LinkedHashSet and put it into
RequestContext#setAttribute(). LinkedHashSet has tags info to put
them into <head> tag.
Usage
In Portal
---------
Example:
HeaderResourceFactory headerResourceFactory
= (HeaderResourceFactory)Jetspeed.getComponentManager().getComponent(HeaderResourceFactory.class);
HeaderResource headerResource = headerResourceFactory.getHeaderResouce(requestContext);
headerResource.addStyleSheet("content/css/styles.css");
In Portlet
----------
Example:
HeaderResourceFactory headerResourceFactory
= getPortletContext().getAttribute(CommonPortletServices.CPS_HEADER_RESOURCE_FACTORY);
HeaderResource headerResource = headerResourceFactory.getHeaderResouce(request);
headerResource.addJavascript("script.js");