mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
-doing the jsp2.0 with the callout example from the sample website. for one, it seems to help avoid some errors i was seeing earlier with classcastexceptions (no clear understanding of why they were happening, but whatever). and it's a nicer example - the jsp is well formed xml and emits well formed xml. good learning experience for catching up with the latest of the jstl nonsense.
- cleaning up build procedure for the sample website - still not perfect, but better. - removing default value for company footer for the xsd - i'll revisit how to set default values on dynamic callout types some other time. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3984 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
<from-email-address>alfresco@alfresco.org</from-email-address>
|
||||
|
||||
<!-- WCM domain and port for virtualisation server -->
|
||||
<wcm-domain>alfresco.dyndns.org</wcm-domain>
|
||||
<wcm-domain>localdomain.lan</wcm-domain>
|
||||
<wcm-port>8180</wcm-port>
|
||||
</client>
|
||||
</config>
|
||||
|
@@ -104,15 +104,29 @@
|
||||
</target>
|
||||
|
||||
<target name="sample-website" depends="init">
|
||||
<mkdir dir="${dir.build}/sample-website/alfresco"/>
|
||||
<copy todir="${dir.build}/sample-website/alfresco">
|
||||
<fileset dir="source/test-resources/websites/alfresco" excludes="**/.svn"/>
|
||||
</copy>
|
||||
<javac srcdir="source/test-resources/websites/alfresco/ROOT/WEB-INF/classes"
|
||||
destdir="${dir.build}/sample-website/alfresco/ROOT/WEB-INF/classes"
|
||||
deprecation="on" debug="on" target="1.5" source="1.5"
|
||||
classpathref="classpath.compile"/>
|
||||
<mkdir dir="source/test-resources/websites/alfresco/ROOT/WEB-INF/lib"/>
|
||||
<jar basedir="source/test-resources/websites/alfresco/ROOT/WEB-INF/classes"
|
||||
destfile="source/test-resources/websites/alfresco/ROOT/WEB-INF/lib/alfresco-sample-website.jar"
|
||||
<mkdir dir="${dir.build}/sample-website/alfresco/ROOT/WEB-INF/lib"/>
|
||||
<jar basedir="${dir.build}/sample-website/alfresco/ROOT/WEB-INF/classes"
|
||||
destfile="${dir.build}/sample-website/alfresco/ROOT/WEB-INF/lib/alfresco-sample-website.jar"
|
||||
includes="**/*.class"/>
|
||||
<delete>
|
||||
<fileset dir="${dir.build}/sample-website/alfresco/ROOT/WEB-INF/classes" includes="**/*.class"/>
|
||||
</delete>
|
||||
<copy todir="${dir.build}/sample-website/alfresco/ROOT/WEB-INF/lib">
|
||||
<fileset dir="${dir.common.lib}">
|
||||
<include name="standard.jar"/>
|
||||
<include name="jstl.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<mkdir dir="${dir.dist}"/>
|
||||
<zip destfile="${dir.dist}/alfresco-sample-website.zip"
|
||||
basedir="source/test-resources/websites/alfresco/"
|
||||
excludes="**/.svn"/>
|
||||
basedir="${dir.build}/sample-website/alfresco"/>
|
||||
</target>
|
||||
</project>
|
||||
|
@@ -18,6 +18,7 @@ package org.alfresco.web.pr;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import org.alfresco.jndi.*;
|
||||
@@ -29,12 +30,10 @@ import java.text.*;
|
||||
|
||||
public class Util
|
||||
{
|
||||
public static List<PressReleaseBean> getPressReleases(final HttpServletRequest request,
|
||||
final ServletContext servletContext)
|
||||
public static List<PressReleaseBean> getPressReleases(final PageContext pageContext)
|
||||
throws Exception
|
||||
{
|
||||
final Map<String, Document> entries = Util.loadXMLDocuments(request,
|
||||
servletContext,
|
||||
final Map<String, Document> entries = Util.loadXMLDocuments(pageContext,
|
||||
"/media/releases/content",
|
||||
"alfresco:press-release");
|
||||
final List<PressReleaseBean> result = new ArrayList<PressReleaseBean>(entries.size());
|
||||
@@ -56,12 +55,10 @@ public class Util
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<CompanyFooterBean> getCompanyFooters(final HttpServletRequest request,
|
||||
final ServletContext servletContext)
|
||||
public static List<CompanyFooterBean> getCompanyFooters(final PageContext pageContext)
|
||||
throws Exception
|
||||
{
|
||||
final Map<String, Document> entries = Util.loadXMLDocuments(request,
|
||||
servletContext,
|
||||
final Map<String, Document> entries = Util.loadXMLDocuments(pageContext,
|
||||
"/media/releases/content/company_footers",
|
||||
"alfresco:company-footer");
|
||||
final List<CompanyFooterBean> result = new ArrayList<CompanyFooterBean>(entries.size());
|
||||
@@ -77,8 +74,7 @@ public class Util
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, Document> loadXMLDocuments(final HttpServletRequest request,
|
||||
final ServletContext servletContext,
|
||||
private static Map<String, Document> loadXMLDocuments(final PageContext pageContext,
|
||||
final String path,
|
||||
final String documentElementNodeName)
|
||||
throws Exception
|
||||
@@ -90,33 +86,31 @@ public class Util
|
||||
|
||||
// The real_path will look somethign like this:
|
||||
// /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
||||
//
|
||||
String real_path = servletContext.getRealPath(path);
|
||||
final String realPath = pageContext.getServletContext().getRealPath(path);
|
||||
|
||||
// The avm_path to the root of the context will look something like this:
|
||||
// alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
||||
//
|
||||
String avm_path = real_path.substring(real_path.indexOf('$', real_path.indexOf('$') + 1) + 1);
|
||||
avm_path = avm_path.replace('\\','/');
|
||||
String avmPath = realPath.substring(realPath.indexOf('$', realPath.indexOf('$') + 1) + 1);
|
||||
avmPath = avmPath.replace('\\','/');
|
||||
|
||||
final AVMRemote avm_remote = AVMFileDirContext.getAVMRemote();
|
||||
final Map<String, AVMNodeDescriptor> entries = avm_remote.getDirectoryListing(-1, avm_path);
|
||||
final Map<String, AVMNodeDescriptor> entries = avm_remote.getDirectoryListing(-1, avmPath);
|
||||
|
||||
Map<String, Document> result = new HashMap<String, Document>();
|
||||
for (Map.Entry<String, AVMNodeDescriptor> entry : entries.entrySet() )
|
||||
{
|
||||
final String entry_name = entry.getKey();
|
||||
AVMNodeDescriptor entry_node = entry.getValue();
|
||||
if (entry_node.isFile())
|
||||
final String entryName = entry.getKey();
|
||||
AVMNodeDescriptor entryNode = entry.getValue();
|
||||
if (entryNode.isFile())
|
||||
{
|
||||
final InputStream istream =
|
||||
new AVMRemoteInputStream(avm_remote.getInputHandle(-1, avm_path + '/' + entry_name),
|
||||
new AVMRemoteInputStream(avm_remote.getInputHandle(-1, avmPath + '/' + entryName),
|
||||
avm_remote );
|
||||
try
|
||||
{
|
||||
final Document d = db.parse(istream);
|
||||
if (documentElementNodeName.equals(d.getDocumentElement().getNodeName()))
|
||||
result.put(entry_name, d);
|
||||
result.put(entryName, d);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
21
source/test-resources/websites/alfresco/ROOT/WEB-INF/pr.tld
Normal file
21
source/test-resources/websites/alfresco/ROOT/WEB-INF/pr.tld
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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/pr</uri>
|
||||
<function>
|
||||
<name>getPressReleases</name>
|
||||
<function-class>org.alfresco.web.pr.Util</function-class>
|
||||
<function-signature>java.util.List getPressReleases(javax.servlet.jsp.PageContext)</function-signature>
|
||||
</function>
|
||||
<function>
|
||||
<name>getCompanyFooters</name>
|
||||
<function-class>org.alfresco.web.pr.Util</function-class>
|
||||
<function-signature>java.util.List getCompanyFooters(javax.servlet.jsp.PageContext)</function-signature>
|
||||
</function>
|
||||
</taglib>
|
@@ -6,10 +6,13 @@
|
||||
|
||||
<web-app>
|
||||
<display-name>Alfresco Website</display-name>
|
||||
|
||||
<description>Alfresco Website</description>
|
||||
|
||||
<!-- Faces Servlet -->
|
||||
<taglib>
|
||||
<taglib-uri>http://www.alfresco.org/pr</taglib-uri>
|
||||
<taglib-location>/WEB-INF/pr.tld</taglib-location>
|
||||
</taglib>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
|
@@ -1,25 +1,24 @@
|
||||
<jsp:root version="1.2"
|
||||
xmlns:jsp="http://java.sun.com/JSP/Page"
|
||||
xmlns:c="http://java.sun.com/jsp/jstl/core"
|
||||
xmlns:pr="http://www.alfresco.org/pr">
|
||||
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
|
||||
|
||||
<jsp:directive.page import="java.util.*"/>
|
||||
<jsp:directive.page import="org.alfresco.web.pr.*"/>
|
||||
|
||||
<jsp:directive.page isELIgnored="false"/>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="qualified">
|
||||
<xs:simpleType name="company-footer">
|
||||
<xs:restriction base="xs:string">
|
||||
<%
|
||||
List<CompanyFooterBean> companyFooters = Util.getCompanyFooters(request, application);
|
||||
for (CompanyFooterBean companyFooter : companyFooters)
|
||||
{
|
||||
%>
|
||||
<xs:enumeration value="<%= companyFooter.getHref() %>">
|
||||
<c:forEach items="${pr:getCompanyFooters(pageContext)}" var="companyFooter">
|
||||
<jsp:element name="xs:enumeration">
|
||||
<jsp:attribute name="value"><c:out value="${companyFooter.href}"/></jsp:attribute>
|
||||
<jsp:body>
|
||||
<xs:annotation>
|
||||
<xs:documentation><%= companyFooter.getName() %></xs:documentation>
|
||||
<xs:documentation><c:out value="${companyFooter.name}"/></xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:enumeration>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</jsp:body>
|
||||
</jsp:element>
|
||||
</c:forEach>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
||||
</jsp:root>
|
@@ -1,9 +1,16 @@
|
||||
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
|
||||
<jsp:directive.page import="java.text.*"/>
|
||||
<jsp:directive.page import="java.util.*"/>
|
||||
<jsp:directive.page import="org.alfresco.web.pr.*"/>
|
||||
<jsp:root version="1.2"
|
||||
xmlns:jsp="http://java.sun.com/JSP/Page"
|
||||
xmlns:c="http://java.sun.com/jsp/jstl/core"
|
||||
xmlns:pr="http://www.alfresco.org/pr"
|
||||
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt">
|
||||
|
||||
<jsp:output doctype-root-element="html"
|
||||
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
|
||||
|
||||
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
|
||||
<jsp:directive.page isELIgnored="false"/>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>Alfresco Press Releases - Open Source Content Management</title>
|
||||
@@ -68,7 +75,7 @@
|
||||
<div id="outer">
|
||||
<div id="inner">
|
||||
<div id="sabout">
|
||||
<p><a href="/about/index.html">Company</a> | <a href="/about/contact/index.html">Contact</a> | <a href="/media/releases/index.jsp">News</a> | <a href="/about/events/index.html">Events</a> | <a href="/about/people/index.html">People</a></p>
|
||||
<p><a href="/about/index.html">Company</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/about/contact/index.html">Contact</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/media/releases/index.jsp">News</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/about/events/index.html">Events</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/about/people/index.html">People</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,16 +87,16 @@
|
||||
|
||||
<h1>Alfresco Press Releases</h1>
|
||||
|
||||
<%
|
||||
List<PressReleaseBean> pressReleases = Util.getPressReleases(request, application);
|
||||
for (PressReleaseBean pr : pressReleases)
|
||||
{
|
||||
%>
|
||||
<h2 class="headline"><a href="<%= pr.getHref() %>"><%= pr.getTitle() %></a></h2>
|
||||
<p class="date"><%= DateFormat.getDateInstance(DateFormat.LONG).format(pr.getLaunchDate()) %></p><p class="abstract"><%= pr.getAbstract() %></p>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<c:forEach items="${pr:getPressReleases(pageContext)}" var="pressRelease">
|
||||
<h2 class="headline">
|
||||
<jsp:element name="a">
|
||||
<jsp:attribute name="href"><c:out value="${pressRelease.href}"/></jsp:attribute>
|
||||
<jsp:body><c:out value="${pressRelease.title}"/></jsp:body>
|
||||
</jsp:element>
|
||||
</h2>
|
||||
<p class="date"><fmt:formatDate value="${pressRelease.launchDate}" dateStyle="long"/></p>
|
||||
<p class="abstract"><c:out value="${pressRelease.abstract}"/></p>
|
||||
</c:forEach>
|
||||
|
||||
<!-- END MAIN CONTENT -->
|
||||
|
||||
@@ -103,7 +110,7 @@ for (PressReleaseBean pr : pressReleases)
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="clear"></div>
|
||||
<div id="clear"> </div>
|
||||
</div>
|
||||
<!--All Three End -->
|
||||
<!-- Footer -->
|
||||
@@ -133,13 +140,14 @@ for (PressReleaseBean pr : pressReleases)
|
||||
<a href="/services/support/index.html">Management Services</a> |
|
||||
<a href="/resources/index.html">EMS Resources</a>
|
||||
</p>
|
||||
<p>© 2005-2006 Alfresco Software, Inc., All Rights Reserved</p>
|
||||
<p>&copy; 2005-2006 Alfresco Software, Inc., All Rights Reserved</p>
|
||||
<p><img src="/assets/images/icons/powered_by_alfresco.gif" alt="Powered by Alfresco" width="88" height="32" /></p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear:both; padding-bottom: 10px;"></div>
|
||||
<div style="clear:both; padding-bottom: 10px;"> </div>
|
||||
</div>
|
||||
<div style="clear:both; padding-bottom: 20px;"></div>
|
||||
<div style="clear:both; padding-bottom: 20px;"> </div>
|
||||
<!-- End Footer -->
|
||||
</body>
|
||||
</html>
|
||||
</jsp:root>
|
||||
|
@@ -20,7 +20,7 @@
|
||||
<xs:element name="abstract" type="xs:string"/>
|
||||
<xs:element name="location" type="xs:string"/>
|
||||
<xs:element name="body" type="xs:anyType" minOccurs="1" maxOccurs="unbounded"/>
|
||||
<xs:element name="include_company_footer" type="alfresco:company-footer" minOccurs="1" maxOccurs="unbounded" default="Alfresco"/>
|
||||
<xs:element name="include_company_footer" type="alfresco:company-footer" minOccurs="1" maxOccurs="unbounded"/>
|
||||
<xs:element name="include_media_contacts" type="xs:boolean" default="true"/>
|
||||
<xs:element name="keywords" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="category" type="alfresco:category" default="Company"/>
|
||||
|
Reference in New Issue
Block a user