WCM tutorial: creating index pages

Document created by resplin Employee on Jun 6, 2015
Version 1Show Document
  • View in full screen mode

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



Alfresco has just begun to integrate web content management (WCM) features into its core repository and interface. As always, your feedback is appreciated!

CAVEAT:  This page is seriously out of date..


Alfresco published a 'WCM Preview Release' in October of 2006 that contains a sample website which illustrates a technique for creating a JSP-based index page.

After you load alfresco-sample-website.zip into a 'staging' sandbox, take note of the following set of files:

  •   ROOT/WEB-INF/web.xml
  •   ROOT/WEB-INF/pr.tld
  •   ROOT/WEB-INF/classes/org/alfresco/web/pr/Util.java
  •   ROOT/WEB-INF/classes/org/alfresco/web/pr/PressReleaseBean.java
  •   ROOT/media/releases/index.jsp

Let's examine them one at a time.


Within this file you should see a snippet that reads:


This creates an association between the  http://www.alfresco.org/pr  tag library, and its tag library definition file  /WEB-INF/pr.tld.  The index.jsp file will make use of this association later.


The press release tag definition library associates a tag library URI (e.g.http://www.alfresco.org/pr) with a set of functions.  For example, the first function defined is:


This says:

  • getPressReleases is declared as a function visible within JSPs
  • org.alfresco.web.pr.Util is the class implementing this function
  • java.util.List getPressReleases(javax.servlet.jsp.PageContext) is the Java API

There's another function defined in this file as well called getCompanyFooters (see the pr.tld file for details).  Both of these functions are associated with the tag library URI  http://www.alfresco.org/pr.  The point being illustrated here is that you can define as many functions in a tag library definition file as you'd like.


Contains implementations of the functions used by the tag libraries.

TODO:  remove everything but the low-level operations (e.g.loadXMLDocuments)  from this file, and modify pr.tld accordingly.  The webapp-specific convenience functions should be sequestered elsewhere.


This file provides the implementation of the java bean returned by the function getPressReleases.  This bean has getter functions that are used by JSP's expression language (e.g.: statements within a JSP of the form:



An index file that constructs a dynamic list of files within Alfresco's repository.  Note that this index page begins with the following declaration:

<jsp:root version='1.2'

The fourth line (in bold) says 'import the tag lib URI named http://www.alfresco.org/pr and associate it with the XML namespace prefix  pr.  Recall that we defined this tag lib URI earlier in web.xml (see above).

Around line 90, you'll see a JSP statement like this:

 <c:forEach items='${pr:getPressReleases(pageContext)}' var='pressRelease'>

That means 'loop over all items returned by the function call ${pr:getPressReleases(pageContext)} using a temporary variable for the 'current' item called pressRelease.  Recall that:

  •   ${ ... } is interpreted as a statement in the JSP expression language
  •   pr: is an alias for the http://www.alfresco.org/pr tag lib namespace
  •   getPressReleases(pageContext) returns a list of PressReleaseBean objects.

Thus the following expression invokes the press release listing convenience function within our index.jsp:


On around line 91, you can see this loop variable being used:

 <jsp:attribute name='href'><c:out value='${pressRelease.href}'/></jsp:attribute>

Note, within PressReleaseBean.java, the PressReleaseBean class has the following getter:

 public String getHref()
     return this.href;

Thus, in JSP expression language the following statement in your index.jsp:


is translated into a call to that getter.