need help in tutorial Getting_Started_with_WCM_for_Alfresco
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2010 05:25 AM
i have gone through this tutorial and try to modify it according to my needs.
i m facing problem when i try to modify PressReleaseBean.java file.
i have added more elements to the existing press-release.xsd file and accordingly modify the java class, so that more information will be displayed on related index.jsp, but when i view the page i got the error Unable to find a value for "Authors" in object of class "org.alfresco.web.pr.PressReleaseBean" using operator "."
i don't modify the pr.tld file
can body help where i go wrong or where may i forgot something
thankx in advance
i m facing problem when i try to modify PressReleaseBean.java file.
i have added more elements to the existing press-release.xsd file and accordingly modify the java class, so that more information will be displayed on related index.jsp, but when i view the page i got the error Unable to find a value for "Authors" in object of class "org.alfresco.web.pr.PressReleaseBean" using operator "."
i don't modify the pr.tld file
can body help where i go wrong or where may i forgot something
thankx in advance
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2010 02:58 AM
using the files i mentioned below, html form generated correctly but the index.jsp page which use PressReleaseBean.class is showing error.
i need to mention more information on the index.jsp page for all press releases.
PressReleaseBean.java is complied successfully.
can body help where i go wrong???
the files modified by me are:
press-release.xsd is:
<?xml version="1.0"?>
<!–
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
Describes a book release of journal and related assets.
–>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns
r="http://www.alfresco.org/alfresco/pr"
targetNamespace="http://www.alfresco.org/alfresco/pr"
elementFormDefault="qualified">
<!– dynamically loads the company footer choices simple type –>
<xs:include schemaLocation="/media/releases/get_company_footer_choices_simple_type.jsp"/>
<xs:simpleType name="category">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="Books"/>
<xs:enumeration value="Journals"/>
<xs:enumeration value="Newsletters"/>
<xs:enumeration value="Magazines"/>
<xs:enumeration value="Others"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BLanguage">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="English"/>
<xs:enumeration value="Hindi"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BType">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="HandBook"/>
<xs:enumeration value="PaperBack"/>
</xs:restriction>
</xs:simpleType>
<!– defines the form for creating a journal release –>
<xs:element name="press_release">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:normalizedString"/>
<xs:element name="Authors" type="xs:normalizedString"/>
<xs:element name="Language" type="pr:BLanguage" default="Hindi"/>
<xs:element name="Price" type="xs:normalizedString"/>
<xs:element name="Pages" type="xs:normalizedString"/>
<xs:element name="BookType" type="pr:BType" default="HandBook"/>
<xs:element name="ISBNno" type="xs:normalizedString"/>
<xs:element name="YearOfPublication" type="xs:normalizedString"/>
<xs:element name="Publisher" type="xs:normalizedString"/>
<xs:element name="abstract" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="UploadFiles" minOccurs="0"
maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="TOC " type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="CoverPage" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="BackPage" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="keywords" type="xs:normalizedString" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="category" type="pr:category" default="Books"/>
<xs:element name="launch_date" type="xs:date"/>
<xs:element name="expiration_date" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
press-release.xsl is:
<?xml version="1.0" encoding="UTF-8"?>
<!–
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
Produces an html rendition of a press release
–>
<xsl:stylesheet version="1.0"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns
r="http://www.alfresco.org/alfresco/pr"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
exclude-result-prefixes="xhtml">
<xsl
utput method="html" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'/>
<xsl
reserve-space elements="*"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!– include common navigation components using SSIs (see web.xml for more information) –>
<xsl:comment>#include virtual="/assets/include_in_head.html"</xsl:comment>
<title><xsl:value-of select="/pr
ress_release/pr:title"/></title>
<meta name="description" lang="en" >
<xsl:attribute name="content"><xsl:value-of select="/pr
ress_release/pr:title"/></xsl:attribute>
</meta>
<style type="text/css">
p.leader {
font-weight: 700;
}
</style>
</head>
<body>
<div id="container">
<xsl:comment>#include virtual="/assets/include_main_navigation.html"</xsl:comment>
<xsl:comment>#include virtual="/about/navigation.html"</xsl:comment>
<div id="content"> </div>
<!– Main Content –>
<div id="main_content">
<!– BEGIN MAIN CONTENT –>
<h1><xsl:value-of select="/pr
ress_release/pr:title"/></h1>
<p>
<table border="0"><tr><td>
<strong>Authors: </strong><xsl:value-of select="/pr
ress_release/pr:Authors"/>
<p><strong>Language: </strong><xsl:value-of select="/pr
ress_release/pr:BLanguage"/>
</p><p><strong>Price: </strong><xsl:value-of select="/pr
ress_release/pr
rice"/>
</p><p><strong>Pages: </strong><xsl:value-of select="/pr
ress_release/pr
ages"/>
</p><p><strong>Type: </strong><xsl:value-of select="/pr
ress_release/pr:BType"/>
</p><p><strong>ISBN no: </strong><xsl:value-of select="/pr
ress_release/pr:ISBN"/>
</p><p><strong>Year of Publication: </strong><xsl:value-of select="/pr
ress_release/pr:YearOfPublication"/>
</p><p><strong>Publisher: </strong><xsl:value-of select="/pr
ress_release/pr
ublisher"/>
</p></td>
<td><p>Cover Page</p>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="/pr
ress_release/pr:UploadFiles/pr:CoverPage"/>
</xsl:attribute>
<xsl:attribute name="align"> <xsl:text>left</xsl:text>
</xsl:attribute>
</xsl:element>
</td>
<td><p>
Back Page</p>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="/pr
ress_release/pr:UploadFiles/pr:BackPage"/>
</xsl:attribute>
<xsl:attribute name="align"> <xsl:text>left</xsl:text>
</xsl:attribute>
</xsl:element>
</td>
</tr>
</table></p>
<p><strong>Abstract: </strong><xsl:value-of select="/pr
ress_release/pr:abstract"/></p>
<p>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="/pr
ress_release/pr:UploadFiles/pr:TOC"/>
</xsl:attribute>
<xsl:text>view Table of Content</xsl:text>
</xsl:element>
</p>
<p></p>
</div>
<!– Feature Content –>
<div id="right_content">
<div class="box_blue">
<h2>ICAR Publications</h2>
<!– store the current category in a variable for later comparison –>
<xsl:variable name="my_category"
select="/pr
ress_release/pr:category"/>
<!– store the current title in a variable for later comparison –>
<xsl:variable name="my_title"
select="/pr
ress_release/pr:title"/>
<!– load all press releases into a variable by calling into a form data function –>
<xsl:variable name="all_press_release"
select="alf
arseXMLDocuments('press_release')"/>
<ul>
<!– select a unique set of categories for the first level navigation –>
<xsl:for-each select="$all_press_release[not(pr:category=preceding-sibling:
r
ress_release/pr:category)]">
<xsl:sort select="pr:category"/>
<li>
<xsl:choose>
<!– for the current category, present all press releases in this category –>
<xsl:when test="pr:category=$my_category">
<b><xsl:value-of select="pr:category"/></b>
<ul>
<!– iterate all press releases which are in my_category –>
<xsl:for-each select="$all_press_release[pr:category=$my_category]">
<xsl:sort select="pr:title"/>
<li>
<xsl:element name="a">
<xsl:if test="$my_title=pr:title">
<xsl:attribute name="style">font-weight:bold;</xsl:attribute>
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of select="fn:replaceAll(string(@alf:file_name), '.xml', '.html')"/>
</xsl:attribute>
<xsl:value-of select="pr:title"/>
</xsl:element>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl
therwise>
<!–
for other categories present a link to the first document in that category
with the category label
–>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="fn:replaceAll(string(@alf:file_name), '.xml', '.html')"/>
</xsl:attribute>
<xsl:value-of select="pr:category"/>
</xsl:element>
</xsl
therwise>
</xsl:choose>
</li>
</xsl:for-each>
</ul>
</div>
</div>
<div id="clear"> </div>
</div>
<!–All Three End –>
<xsl:comment>#include virtual="/assets/footer.html"</xsl:comment>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
PressReleaseBean.java is:
package org.alfresco.web.pr;
import java.util.*;
import java.text.*;
import javax.servlet.jsp.PageContext;
import org.w3c.dom.*;
import org.alfresco.web.forms.*;
/**
* Bean for getting data for press releases.
* It's used by /media/releases/index.jsp to aggregate all forms created by press-release.xsd in
* /media/releases/content and generate an index page for them.
*/
public class PressReleaseBean
{
/**
* Loads all xml assets created by press-release.xsd in /media/releases/content and populates
* PressReleaseBeans with their contents.
*
* @param pageContext the page context from the jsp, needed for accessing the
* servlet context for the ServletContextFormDataFunctionsAdapter class.
*
* @return a list of populated PressReleaseBeans.
*/
public static List<PressReleaseBean> getPressReleases(final PageContext pageContext)
throws Exception
{
final FormDataFunctions ef =
new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext());
final Map<String, Document> entries =
ef.parseXMLDocuments("press-release", "/media/releases/content");
final List<PressReleaseBean> result = new ArrayList<PressReleaseBean>(entries.size());
for (Map.Entry<String, Document> entry : entries.entrySet())
{
result.add(PressReleaseBean.loadPressRelease(entry.getValue(), entry.getKey()));
}
return result;
}
/**
* Provides a list of press releases for a specified category.
*
* @param pageContext the page context from the jsp
* @param category the category to search for
*
* @return all press releases within the specified category.
*/
public static List<PressReleaseBean> getPressReleasesInCategory(final PageContext pageContext,
final String category)
throws Exception
{
final FormDataFunctions ef =
new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext());
final Map<String, Document> entries =
ef.parseXMLDocuments("press-release", "/media/releases/content");
final List<PressReleaseBean> result = new ArrayList<PressReleaseBean>(entries.size());
for (Map.Entry<String, Document> entry : entries.entrySet())
{
final Document d = entry.getValue();
final Element cEl = (Element)
d.getElementsByTagName("pr:category").item(0);
if (category.equals(cEl.getFirstChild().getNodeValue()))
{
result.add(PressReleaseBean.loadPressRelease(d, entry.getKey()));
}
}
return result;
}
/**
* Returns a set of unique categories used by the press releases in sorted order.
*
* @param pageContext the page context variable from the jsp
*
* @return a set of unique categories used by the press releases in sorted order.
*/
public static Set<String> getPressReleaseCategories(final PageContext pageContext)
throws Exception
{
final FormDataFunctions ef =
new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext());
final TreeSet<String> result = new TreeSet<String>();
final Map<String, Document> entries =
ef.parseXMLDocuments("press-release", "/media/releases/content");
for (Map.Entry<String, Document> entry : entries.entrySet())
{
final Element cEl = (Element)
entry.getValue().getElementsByTagName("pr:category").item(0);
}
return result;
}
/**
* Utility function to create an instance of a press release using
* form instance data.
*
* @param d the xml document
* @param fileName the filename of the file from which the document was loaded.
*
* @return a press release representing the content of the file.
*/
private static PressReleaseBean loadPressRelease(final Document d,
final String fileName)
throws Exception
{
final Element t = (Element)d.getElementsByTagName("pr:title").item(0);
final Element a = (Element)d.getElementsByTagName("pr:Authors").item(0);
final Element dateEl = (Element)d.getElementsByTagName("pr:launch_date").item(0);
final Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateEl.getFirstChild().getNodeValue());
final Element p = (Element)d.getElementsByTagName("pr
rice").item(0);
final Element y = (Element)d.getElementsByTagName("pr:YearOfPublication").item(0);
String href = "/media/releases/content/" + fileName;
href = href.replaceAll(".xml$", ".html");
return new PressReleaseBean(t.getFirstChild().getNodeValue(),
a.getFirstChild().getNodeValue(),
date,
href,p.getFirstChild().getNodeValue(),y.getFirstChild().getNodeValue());
}
private final String title;
private final String Authors;//it is used for authors name
private final Date launchDate;
private final String href;// for more details link
private final String Price;
private final String YearOfPublication;
public PressReleaseBean(final String title,
final String Authors,
final Date launchDate,
final String href,final String Price,final String YearOfPublication)
{
this.title = title;
this.Authors = Authors;
this.launchDate = launchDate;
this.href = href;
this.Price = Price;
this.YearOfPublication= YearOfPublication;
}
/**
* The title of the press release as defined in the xml asset.
*/
public String getTitle()
{
return this.title;
}
/**
* The abstract of the press release as defined in the xml asset.
*/
public String getAuthors()
{
return this.Authors;
}
/**
* The launch date of the press release as defined in the xml asset.
*/
public Date getLaunchDate()
{
return this.launchDate;
}
/**
* Returns the url within the webapp to the xml file describing this press release
*
* @return the url to the xml file which will be something like /media/releases/content/[filename].xml
*/
public String getHref()
{
return this.href;
}
public String getPrice()
{
return this.Price;
}
public String getYearOfPublication()
{
return this.YearOfPublication;
}
}
pr.tld is: this file is not modifed
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<short-name>pr</short-name>
<uri>http://www.alfresco.org/alfresco/pr</uri>
<function>
<name>getPressReleases</name>
<function-class>org.alfresco.web.pr.PressReleaseBean</function-class>
<function-signature>java.util.List getPressReleases(javax.servlet.jsp.PageContext)</function-signature>
</function>
<function>
<name>getPressReleasesInCategory</name>
<function-class>org.alfresco.web.pr.PressReleaseBean</function-class>
<function-signature>java.util.List getPressReleasesInCategory(javax.servlet.jsp.PageContext, java.lang.String)</function-signature>
</function>
<function>
<name>getPressReleaseCategories</name>
<function-class>org.alfresco.web.pr.PressReleaseBean</function-class>
<function-signature>java.util.Set getPressReleaseCategories(javax.servlet.jsp.PageContext)</function-signature>
</function>
<function>
<name>getCompanyFooterChoices</name>
<function-class>org.alfresco.web.pr.CompanyFooterBean</function-class>
<function-signature>java.util.List getCompanyFooterChoices(javax.servlet.jsp.PageContext)</function-signature>
</function>
</taglib>
i need to mention more information on the index.jsp page for all press releases.
PressReleaseBean.java is complied successfully.
can body help where i go wrong???
the files modified by me are:
press-release.xsd is:
<?xml version="1.0"?>
<!–
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
Describes a book release of journal and related assets.
–>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns

targetNamespace="http://www.alfresco.org/alfresco/pr"
elementFormDefault="qualified">
<!– dynamically loads the company footer choices simple type –>
<xs:include schemaLocation="/media/releases/get_company_footer_choices_simple_type.jsp"/>
<xs:simpleType name="category">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="Books"/>
<xs:enumeration value="Journals"/>
<xs:enumeration value="Newsletters"/>
<xs:enumeration value="Magazines"/>
<xs:enumeration value="Others"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BLanguage">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="English"/>
<xs:enumeration value="Hindi"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BType">
<xs:restriction base="xs:normalizedString">
<xs:enumeration value="HandBook"/>
<xs:enumeration value="PaperBack"/>
</xs:restriction>
</xs:simpleType>
<!– defines the form for creating a journal release –>
<xs:element name="press_release">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:normalizedString"/>
<xs:element name="Authors" type="xs:normalizedString"/>
<xs:element name="Language" type="pr:BLanguage" default="Hindi"/>
<xs:element name="Price" type="xs:normalizedString"/>
<xs:element name="Pages" type="xs:normalizedString"/>
<xs:element name="BookType" type="pr:BType" default="HandBook"/>
<xs:element name="ISBNno" type="xs:normalizedString"/>
<xs:element name="YearOfPublication" type="xs:normalizedString"/>
<xs:element name="Publisher" type="xs:normalizedString"/>
<xs:element name="abstract" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="UploadFiles" minOccurs="0"
maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="TOC " type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="CoverPage" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
<xs:element name="BackPage" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="keywords" type="xs:normalizedString" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="category" type="pr:category" default="Books"/>
<xs:element name="launch_date" type="xs:date"/>
<xs:element name="expiration_date" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
press-release.xsl is:
<?xml version="1.0" encoding="UTF-8"?>
<!–
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
Produces an html rendition of a press release
–>
<xsl:stylesheet version="1.0"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns

xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
exclude-result-prefixes="xhtml">
<xsl

doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'/>
<xsl

<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!– include common navigation components using SSIs (see web.xml for more information) –>
<xsl:comment>#include virtual="/assets/include_in_head.html"</xsl:comment>
<title><xsl:value-of select="/pr

<meta name="description" lang="en" >
<xsl:attribute name="content"><xsl:value-of select="/pr

</meta>
<style type="text/css">
p.leader {
font-weight: 700;
}
</style>
</head>
<body>
<div id="container">
<xsl:comment>#include virtual="/assets/include_main_navigation.html"</xsl:comment>
<xsl:comment>#include virtual="/about/navigation.html"</xsl:comment>
<div id="content"> </div>
<!– Main Content –>
<div id="main_content">
<!– BEGIN MAIN CONTENT –>
<h1><xsl:value-of select="/pr

<p>
<table border="0"><tr><td>
<strong>Authors: </strong><xsl:value-of select="/pr

<p><strong>Language: </strong><xsl:value-of select="/pr

</p><p><strong>Price: </strong><xsl:value-of select="/pr


</p><p><strong>Pages: </strong><xsl:value-of select="/pr


</p><p><strong>Type: </strong><xsl:value-of select="/pr

</p><p><strong>ISBN no: </strong><xsl:value-of select="/pr

</p><p><strong>Year of Publication: </strong><xsl:value-of select="/pr

</p><p><strong>Publisher: </strong><xsl:value-of select="/pr


</p></td>
<td><p>Cover Page</p>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="/pr

</xsl:attribute>
<xsl:attribute name="align"> <xsl:text>left</xsl:text>
</xsl:attribute>
</xsl:element>
</td>
<td><p>
Back Page</p>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="/pr

</xsl:attribute>
<xsl:attribute name="align"> <xsl:text>left</xsl:text>
</xsl:attribute>
</xsl:element>
</td>
</tr>
</table></p>
<p><strong>Abstract: </strong><xsl:value-of select="/pr

<p>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="/pr

</xsl:attribute>
<xsl:text>view Table of Content</xsl:text>
</xsl:element>
</p>
<p></p>
</div>
<!– Feature Content –>
<div id="right_content">
<div class="box_blue">
<h2>ICAR Publications</h2>
<!– store the current category in a variable for later comparison –>
<xsl:variable name="my_category"
select="/pr

<!– store the current title in a variable for later comparison –>
<xsl:variable name="my_title"
select="/pr

<!– load all press releases into a variable by calling into a form data function –>
<xsl:variable name="all_press_release"
select="alf

<ul>
<!– select a unique set of categories for the first level navigation –>
<xsl:for-each select="$all_press_release[not(pr:category=preceding-sibling:


<xsl:sort select="pr:category"/>
<li>
<xsl:choose>
<!– for the current category, present all press releases in this category –>
<xsl:when test="pr:category=$my_category">
<b><xsl:value-of select="pr:category"/></b>
<ul>
<!– iterate all press releases which are in my_category –>
<xsl:for-each select="$all_press_release[pr:category=$my_category]">
<xsl:sort select="pr:title"/>
<li>
<xsl:element name="a">
<xsl:if test="$my_title=pr:title">
<xsl:attribute name="style">font-weight:bold;</xsl:attribute>
</xsl:if>
<xsl:attribute name="href">
<xsl:value-of select="fn:replaceAll(string(@alf:file_name), '.xml', '.html')"/>
</xsl:attribute>
<xsl:value-of select="pr:title"/>
</xsl:element>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl

<!–
for other categories present a link to the first document in that category
with the category label
–>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="fn:replaceAll(string(@alf:file_name), '.xml', '.html')"/>
</xsl:attribute>
<xsl:value-of select="pr:category"/>
</xsl:element>
</xsl

</xsl:choose>
</li>
</xsl:for-each>
</ul>
</div>
</div>
<div id="clear"> </div>
</div>
<!–All Three End –>
<xsl:comment>#include virtual="/assets/footer.html"</xsl:comment>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
PressReleaseBean.java is:
package org.alfresco.web.pr;
import java.util.*;
import java.text.*;
import javax.servlet.jsp.PageContext;
import org.w3c.dom.*;
import org.alfresco.web.forms.*;
/**
* Bean for getting data for press releases.
* It's used by /media/releases/index.jsp to aggregate all forms created by press-release.xsd in
* /media/releases/content and generate an index page for them.
*/
public class PressReleaseBean
{
/**
* Loads all xml assets created by press-release.xsd in /media/releases/content and populates
* PressReleaseBeans with their contents.
*
* @param pageContext the page context from the jsp, needed for accessing the
* servlet context for the ServletContextFormDataFunctionsAdapter class.
*
* @return a list of populated PressReleaseBeans.
*/
public static List<PressReleaseBean> getPressReleases(final PageContext pageContext)
throws Exception
{
final FormDataFunctions ef =
new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext());
final Map<String, Document> entries =
ef.parseXMLDocuments("press-release", "/media/releases/content");
final List<PressReleaseBean> result = new ArrayList<PressReleaseBean>(entries.size());
for (Map.Entry<String, Document> entry : entries.entrySet())
{
result.add(PressReleaseBean.loadPressRelease(entry.getValue(), entry.getKey()));
}
return result;
}
/**
* Provides a list of press releases for a specified category.
*
* @param pageContext the page context from the jsp
* @param category the category to search for
*
* @return all press releases within the specified category.
*/
public static List<PressReleaseBean> getPressReleasesInCategory(final PageContext pageContext,
final String category)
throws Exception
{
final FormDataFunctions ef =
new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext());
final Map<String, Document> entries =
ef.parseXMLDocuments("press-release", "/media/releases/content");
final List<PressReleaseBean> result = new ArrayList<PressReleaseBean>(entries.size());
for (Map.Entry<String, Document> entry : entries.entrySet())
{
final Document d = entry.getValue();
final Element cEl = (Element)
d.getElementsByTagName("pr:category").item(0);
if (category.equals(cEl.getFirstChild().getNodeValue()))
{
result.add(PressReleaseBean.loadPressRelease(d, entry.getKey()));
}
}
return result;
}
/**
* Returns a set of unique categories used by the press releases in sorted order.
*
* @param pageContext the page context variable from the jsp
*
* @return a set of unique categories used by the press releases in sorted order.
*/
public static Set<String> getPressReleaseCategories(final PageContext pageContext)
throws Exception
{
final FormDataFunctions ef =
new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext());
final TreeSet<String> result = new TreeSet<String>();
final Map<String, Document> entries =
ef.parseXMLDocuments("press-release", "/media/releases/content");
for (Map.Entry<String, Document> entry : entries.entrySet())
{
final Element cEl = (Element)
entry.getValue().getElementsByTagName("pr:category").item(0);
}
return result;
}
/**
* Utility function to create an instance of a press release using
* form instance data.
*
* @param d the xml document
* @param fileName the filename of the file from which the document was loaded.
*
* @return a press release representing the content of the file.
*/
private static PressReleaseBean loadPressRelease(final Document d,
final String fileName)
throws Exception
{
final Element t = (Element)d.getElementsByTagName("pr:title").item(0);
final Element a = (Element)d.getElementsByTagName("pr:Authors").item(0);
final Element dateEl = (Element)d.getElementsByTagName("pr:launch_date").item(0);
final Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateEl.getFirstChild().getNodeValue());
final Element p = (Element)d.getElementsByTagName("pr

final Element y = (Element)d.getElementsByTagName("pr:YearOfPublication").item(0);
String href = "/media/releases/content/" + fileName;
href = href.replaceAll(".xml$", ".html");
return new PressReleaseBean(t.getFirstChild().getNodeValue(),
a.getFirstChild().getNodeValue(),
date,
href,p.getFirstChild().getNodeValue(),y.getFirstChild().getNodeValue());
}
private final String title;
private final String Authors;//it is used for authors name
private final Date launchDate;
private final String href;// for more details link
private final String Price;
private final String YearOfPublication;
public PressReleaseBean(final String title,
final String Authors,
final Date launchDate,
final String href,final String Price,final String YearOfPublication)
{
this.title = title;
this.Authors = Authors;
this.launchDate = launchDate;
this.href = href;
this.Price = Price;
this.YearOfPublication= YearOfPublication;
}
/**
* The title of the press release as defined in the xml asset.
*/
public String getTitle()
{
return this.title;
}
/**
* The abstract of the press release as defined in the xml asset.
*/
public String getAuthors()
{
return this.Authors;
}
/**
* The launch date of the press release as defined in the xml asset.
*/
public Date getLaunchDate()
{
return this.launchDate;
}
/**
* Returns the url within the webapp to the xml file describing this press release
*
* @return the url to the xml file which will be something like /media/releases/content/[filename].xml
*/
public String getHref()
{
return this.href;
}
public String getPrice()
{
return this.Price;
}
public String getYearOfPublication()
{
return this.YearOfPublication;
}
}
pr.tld is: this file is not modifed
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<short-name>pr</short-name>
<uri>http://www.alfresco.org/alfresco/pr</uri>
<function>
<name>getPressReleases</name>
<function-class>org.alfresco.web.pr.PressReleaseBean</function-class>
<function-signature>java.util.List getPressReleases(javax.servlet.jsp.PageContext)</function-signature>
</function>
<function>
<name>getPressReleasesInCategory</name>
<function-class>org.alfresco.web.pr.PressReleaseBean</function-class>
<function-signature>java.util.List getPressReleasesInCategory(javax.servlet.jsp.PageContext, java.lang.String)</function-signature>
</function>
<function>
<name>getPressReleaseCategories</name>
<function-class>org.alfresco.web.pr.PressReleaseBean</function-class>
<function-signature>java.util.Set getPressReleaseCategories(javax.servlet.jsp.PageContext)</function-signature>
</function>
<function>
<name>getCompanyFooterChoices</name>
<function-class>org.alfresco.web.pr.CompanyFooterBean</function-class>
<function-signature>java.util.List getCompanyFooterChoices(javax.servlet.jsp.PageContext)</function-signature>
</function>
</taglib>
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2010 05:49 AM
Try "authors".
Ainga
Ainga
