You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bd...@apache.org on 2005/09/28 10:10:38 UTC
svn commit: r292140 [2/4] - in /cocoon/whiteboard/example-apps/bricks-cms:
./ lib/commons/ lib/derby/ lib/derby/derby-10.1.1.0/ lib/hivemind/
lib/hivemind/hivemind-1.1-rc-1/ lib/hivemind/javassist-3.0/ lib/ojb/
lib/ojb/db-ojb-1.0.3/ lib/servlet/ src/bu...
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/sitemap.xmap Wed Sep 28 01:08:23 2005
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ document-editor sitemap for the bricks-cms project
+
+ $Id: sitemap.xmap,v 1.4 2005/09/26 19:48:28 bdelacretaz Exp $
+-->
+<map:sitemap
+ xmlns:map="http://apache.org/cocoon/sitemap/1.0"
+ >
+
+ <map:flow language="javascript">
+ <map:script src="flow/document-editor.js"/>
+ </map:flow>
+
+ <map:resources>
+ <map:resource name="layout">
+ <map:transform src="../xslt/page-to-html.xsl"/>
+ <map:serialize type="html"/>
+ </map:resource>
+ </map:resources>
+
+ <map:pipelines>
+
+ <map:pipeline>
+ <!-- handle continuations -->
+ <map:match pattern="*.continue">
+ <map:call continuation="{1}"/>
+ </map:match>
+ <map:match pattern="**/*.continue">
+ <map:call continuation="{2}"/>
+ </map:match>
+
+ <map:match pattern="">
+ <map:generate src="document-editor-homepage.xml"/>
+ <map:call resource="layout"/>
+ </map:match>
+
+ <map:match pattern="create">
+ <map:call function="handleForm">
+ <map:parameter name="function" value="form_editDocument"/>
+ <map:parameter name="docId" value="NEW_DOCUMENT"/>
+ <map:parameter name="bindingURI" value="forms/document-binding.xml"/>
+ <map:parameter name="formDisplayURI" value="document-form-display"/>
+ <map:parameter name="nextURI" value="view/"/>
+
+ <!-- TODO after 2.1.7 this parameter will need to be named "definitionURI" -->
+ <map:parameter name="form-definition" value="forms/document-model.xml"/>
+
+ </map:call>
+ </map:match>
+
+ <map:match pattern="edit/*">
+ <map:call function="handleForm">
+ <map:parameter name="function" value="form_editDocument"/>
+ <map:parameter name="docId" value="{1}"/>
+ <map:parameter name="bindingURI" value="forms/document-binding.xml"/>
+ <map:parameter name="formDisplayURI" value="document-form-display"/>
+ <map:parameter name="nextURI" value="../view/{1}"/>
+
+ <!-- TODO after 2.1.7 this parameter will need to be named "definitionURI" -->
+ <map:parameter name="form-definition" value="forms/document-model.xml"/>
+
+ </map:call>
+ </map:match>
+
+ <map:match pattern="view/*">
+ <map:call function="viewDocument">
+ <map:parameter name="docId" value="{1}"/>
+ <map:parameter name="displayURI" value="document-display"/>
+ </map:call>
+ </map:match>
+ </map:pipeline>
+
+ <map:pipeline internal-only="true">
+ <map:match pattern="*-form-display">
+ <map:generate type="jx" src="forms/{1}-template.xml"/>
+ <map:transform src="../xslt/page-to-html.xsl"/>
+ <map:transform src="context://bricks-cms/common/forms/form-styling.xsl">
+ <map:parameter name="resources-uri" value="admin-resources"/>
+ </map:transform>
+ <map:serialize type="html"/>
+ </map:match>
+
+ <map:match pattern="document-display">
+ <map:generate type="jx" src="view/document.jx.xml"/>
+ <map:call resource="layout"/>
+ </map:match>
+
+ </map:pipeline>
+
+ </map:pipelines>
+
+</map:sitemap>
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml Wed Sep 28 01:08:23 2005
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ JXTemplate used to display a BricksDocument
+ $Id$
+-->
+
+<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+ <metadata>
+ <title>#{document/title}</title>
+ <menu>
+ <item>
+ <a href="../edit/#{document/id}">edit</a>
+ </item>
+ <item>
+ <a href="../">cancel</a>
+ </item>
+ </menu>
+ </metadata>
+
+ <content>
+ <page>
+ <p class="note">
+ This is document
+ <b>#{document/id}</b>,
+ you might want to note this ID for further testing.
+ </p>
+ <p>#{document/content}</p>
+ <div class="note">
+ created: #{document/created}
+ <br/>
+ last modified:#{document/lastModified}
+ </div>
+ </page>
+ </content>
+</page>
\ No newline at end of file
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/document-editor/view/document.jx.xml
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/sitemap.xmap?rev=292140&r1=292139&r2=292140&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/sitemap.xmap (original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/sitemap.xmap Wed Sep 28 01:08:23 2005
@@ -19,7 +19,7 @@
<!--
admin sitemap for the bricks-cms project
- $Id$
+ $Id: sitemap.xmap,v 1.2 2005/09/26 15:24:12 bdelacretaz Exp $
-->
<map:sitemap
xmlns:map="http://apache.org/cocoon/sitemap/1.0"
@@ -50,6 +50,15 @@
-->
<map:match pattern="**/admin-resources/**">
<map:read src="static-content/resources/{2}"/>
+ </map:match>
+
+ <!-- mount sub-sitemaps, one level down from this directory -->
+ <map:match pattern="*/**">
+ <map:mount
+ check-reload="yes"
+ src="{1}/"
+ uri-prefix="{1}/"
+ />
</map:match>
</map:pipeline>
Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml?rev=292140&r1=292139&r2=292140&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml (original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml Wed Sep 28 01:08:23 2005
@@ -16,6 +16,10 @@
limitations under the License.
-->
+<!--
+ homepage of the bricks-cms admin
+ $Id$
+-->
<page>
<metadata>
<title>bricks-cms admin homepage</title>
@@ -23,7 +27,8 @@
<content>
<p>
- This is the admin homepage, soon you'll find lots of cool links here.
+ For now, the only admin functionality is the
+ <a href="document-editor/">document-editor</a>.
</p>
</content>
</page>
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/pages/admin-homepage.xml
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css?rev=292140&r1=292139&r2=292140&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css (original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css Wed Sep 28 01:08:23 2005
@@ -21,5 +21,24 @@
}
h1 {
- border-bottom: solid gray 1px;
+ border-bottom: solid blue 1px;
+}
+
+.note {
+ font-size:80%;
+ font-style:italic;
+}
+
+#menu {
+ border: solid #CCCCCC;
+ border-width: 0 0 1px 0;
+ text-align: right;
+ font-size: 80%;
+ border-right: solid #CCCCCC 1px;
+}
+
+.menuItem {
+ display: inline;
+ padding: 0 0.4em;
+ border-left: solid #CCCCCC 1px;
}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/static-content/resources/css/bricks-cms.css
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/page-to-html.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/page-to-html.xsl?rev=292140&r1=292139&r2=292140&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/page-to-html.xsl (original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/admin/xslt/page-to-html.xsl Wed Sep 28 01:08:23 2005
@@ -18,7 +18,7 @@
<!--
Convert a <page> document to HTML
- $Id$
+ $Id: page-to-html.xsl,v 1.2 2005/09/26 19:33:15 bdelacretaz Exp $
-->
<xsl:stylesheet version="1.0"
@@ -41,11 +41,11 @@
</head>
<body>
+ <xsl:apply-templates select="page/metadata/menu"/>
<h1 class="pageTitle">
<xsl:value-of select="$title"/>
</h1>
<xsl:apply-templates select="page/content" mode="copy-content"/>
-
</body>
</html>
</xsl:template>
@@ -56,6 +56,19 @@
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="copy-content"/>
</xsl:copy>
+ </xsl:template>
+
+ <!-- generate the page menu, if any -->
+ <xsl:template match="metadata/menu">
+ <div id="menu">
+ <xsl:apply-templates mode="copy-content"/>
+ </div>
+ </xsl:template>
+
+ <xsl:template match="menu/item" mode="copy-content">
+ <div class="menuItem">
+ <xsl:apply-templates mode="copy-content"/>
+ </div>
</xsl:template>
</xsl:stylesheet>
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/component-manager.js
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/component-manager.js?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/component-manager.js (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/component-manager.js Wed Sep 28 01:08:23 2005
@@ -0,0 +1,35 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+// flowscript utilities for accessing the ApplicationComponentManager
+
+var CM_ATTRIBUTE = Packages.org.apache.cocoon.apps.bricks.cms.componentmanager.ComponentManagerInitializer.COMPONENT_MANAGER_ATTRIBUTE;
+
+// get component manager
+function get_cm() {
+ var cm = cocoon.context.getAttribute(CM_ATTRIBUTE);
+ if(cm==null) {
+ throw "Could not get component manager from content attribute '" + CM_ATTRIBUTE + "'";
+ }
+ return cm;
+}
+
+// get the object store via the component manager
+function get_objectStore() {
+ var cm = get_cm();
+ var objectStore = cm.getService(Packages.org.apache.cocoon.apps.bricks.cms.objectstore.ObjectStore);
+ return objectStore;
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/component-manager.js
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/form-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/form-styling.xsl?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/form-styling.xsl (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/form-styling.xsl Wed Sep 28 01:08:23 2005
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <!--+ Include styling stylesheets, one for the widgets, the other one for the
+ | page. As 'forms-advanced-field-styling.xsl' is a specialization of
+ | 'forms-field-styling.xsl' the latter one is imported there. If you don't
+ | want advanced styling of widgets, change it here!
+ | See xsl:include as composition and xsl:import as extension/inheritance.
+ +-->
+
+ <!--
+ -->
+ <xsl:include href="forms-field-styling.xsl"/>
+ <xsl:include href="forms-page-styling.xsl"/>
+
+ <xsl:template match="/">
+ <html>
+ <xsl:apply-templates select="html/*"/>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="head">
+ <head>
+ <xsl:apply-templates/>
+ <xsl:apply-templates select="." mode="forms-page"/>
+ <xsl:apply-templates select="." mode="forms-field"/>
+ </head>
+ </xsl:template>
+
+ <xsl:template match="body">
+ <body>
+ <!--+ !!! If template with mode 'forms-page' adds text or elements
+ | template with mode 'forms-field' can no longer add attributes!!!
+ +-->
+ <xsl:apply-templates select="." mode="forms-page"/>
+ <xsl:apply-templates select="." mode="forms-field"/>
+ <xsl:apply-templates/>
+ </body>
+ </xsl:template>
+
+</xsl:stylesheet>
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-field-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-field-styling.xsl?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-field-styling.xsl (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-field-styling.xsl Wed Sep 28 01:08:23 2005
@@ -0,0 +1,525 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+ exclude-result-prefixes="fi">
+ <!--+
+ | This stylesheet is designed to be included by 'forms-samples-styling.xsl'.
+ | Version CVS $Id: forms-field-styling.xsl,v 1.1 2005/09/26 15:24:46 bdelacretaz Exp $
+ +-->
+
+ <!-- Location of the resources directory, where JS libs and icons are stored -->
+ <xsl:param name="resources-uri">resources</xsl:param>
+
+ <xsl:template match="head" mode="forms-field">
+ <!-- [olange] deprecated and moved to the various form templates
+ (use style/add-stylesheet and style/add-script instead)
+ <script src="{$resources-uri}/forms-lib.js" type="text/javascript"/>
+ <link rel="stylesheet" type="text/css" href="{$resources-uri}/forms.css"/> -->
+ </xsl:template>
+
+ <xsl:template match="body" mode="forms-field">
+ <xsl:copy-of select="@*"/>
+<!-- <xsl:attribute name="onload">forms_onload(); <xsl:value-of select="@onload"/></xsl:attribute> -->
+ </xsl:template>
+
+ <!--+
+ | Generic fi:field : produce an <input>
+ +-->
+ <xsl:template match="fi:field">
+ <input name="{@id}" id="{@id}" value="{fi:value}" title="{fi:hint}" type="text">
+ <xsl:apply-templates select="." mode="styling"/>
+ </input>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--+
+ | Common stuff like fi:validation-message, @required.
+ +-->
+ <xsl:template match="fi:*" mode="common">
+ <!-- validation message -->
+ <xsl:apply-templates select="fi:validation-message"/>
+ <!-- required mark -->
+ <xsl:if test="@required='true'">
+ <span class="forms-field-required"> * </span>
+ </xsl:if>
+ </xsl:template>
+
+ <!--+
+ | Handling the common styling. You may only add attributes to the output
+ | in this template as later processing might add attributes too, for
+ | example @checked or @selected
+ +-->
+ <xsl:template match="fi:*" mode="styling">
+ <xsl:apply-templates select="fi:styling/@*" mode="styling"/>
+
+ <!--+
+ | @listbox-size needs to be handled separately as even if it is not
+ | specified some output (@size) must be generated.
+ +-->
+ <xsl:if test="self::fi:field[fi:selection-list][fi:styling/@list-type = 'listbox'] or
+ self::fi:multivaluefield[not(fi:styling/@list-type = 'checkbox')]">
+ <xsl:variable name="size">
+ <xsl:value-of select="fi:styling/@listbox-size"/>
+ <xsl:if test="not(fi:styling/@listbox-size)">5</xsl:if>
+ </xsl:variable>
+ <xsl:attribute name="size">
+ <xsl:value-of select="$size"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="fi:styling/@*" mode="styling" priority="-1">
+ <!-- NOTE: lowered priority to accomodate Saxon ambiguous rules conflicts reporting [olange] -->
+ <xsl:copy-of select="."/>
+ </xsl:template>
+
+ <xsl:template match="fi:styling/@submit-on-change" mode="styling">
+ <xsl:if test=". = 'true'">
+ <xsl:attribute name="onchange">forms_submitForm(this)</xsl:attribute>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="fi:styling/@list-type | fi:styling/@list-orientation |
+ fi:styling/@listbox-size | fi:styling/@format | fi:styling/@layout"
+ mode="styling">
+ <!--+
+ | Ignore marker attributes so they don't go into the resuling HTML.
+ +-->
+ </xsl:template>
+
+ <xsl:template match="fi:styling/@type" mode="styling">
+ <!--+
+ | Do we have a duplicate semantic usage of @type?
+ | @type is only a marker for the stylesheet in general, but some of the
+ | types must/should be in the HTML output too.
+ +-->
+ <xsl:variable name="validHTMLTypes"
+ select="'text hidden textarea checkbox radio password image reset submit'"/>
+ <xsl:if test="normalize-space(.) and
+ contains(concat(' ', $validHTMLTypes, ' '), concat(' ', ., ' '))">
+ <xsl:copy-of select="."/>
+ </xsl:if>
+ </xsl:template>
+
+ <!--+
+ |
+ +-->
+ <xsl:template match="fi:validation-message">
+ <a href="#" class="forms-validation-message" onclick="alert('{normalize-space(.)}');return false;"> ! </a>
+ </xsl:template>
+
+ <!--+
+ | Hidden fi:field : produce input with type='hidden'
+ +-->
+ <xsl:template match="fi:field[fi:styling/@type='hidden']" priority="2">
+ <input type="hidden" name="{@id}" id="{@id}" value="{fi:value}">
+ <xsl:apply-templates select="." mode="styling"/>
+ </input>
+ </xsl:template>
+
+ <!--+
+ | fi:field with a selection list and @list-type 'radio' : produce
+ | radio-buttons oriented according to @list-orientation
+ | ("horizontal" or "vertical" - default)
+ +-->
+ <xsl:template match="fi:field[fi:selection-list][fi:styling/@list-type='radio']" priority="2">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="value" select="fi:value"/>
+ <xsl:variable name="vertical" select="string(fi:styling/@list-orientation) != 'horizontal'"/>
+ <xsl:choose>
+ <xsl:when test="$vertical">
+ <table cellpadding="0" cellspacing="0" border="0" title="{fi:hint}">
+ <xsl:for-each select="fi:selection-list/fi:item">
+ <tr>
+ <td>
+ <input type="radio" id="{generate-id()}" name="{$id}" value="{@value}">
+ <xsl:if test="@value = $value">
+ <xsl:attribute name="checked">checked</xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="." mode="styling"/>
+ </input>
+ </td>
+ <td>
+ <label for="{generate-id()}"><xsl:copy-of select="fi:label/node()"/></label>
+ </td>
+ <xsl:if test="position() = 1">
+ <td rowspan="{count(../fi:item)}">
+ <xsl:apply-templates select="../.." mode="common"/>
+ </td>
+ </xsl:if>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:when>
+ <xsl:otherwise>
+ <span title="{fi:hint}">
+ <xsl:for-each select="fi:selection-list/fi:item">
+ <input type="radio" id="{generate-id()}" name="{$id}" value="{@value}">
+ <xsl:if test="@value = $value">
+ <xsl:attribute name="checked">checked</xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="." mode="styling"/>
+ </input>
+ <label for="{generate-id()}"><xsl:copy-of select="fi:label/node()"/></label>
+ </xsl:for-each>
+ </span>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!--+
+ | fi:field with a selection list (not 'radio' style)
+ | Rendering depends on the attributes of fi:styling :
+ | - if @list-type is "listbox" : produce a list box with @listbox-size visible
+ | items (default 5)
+ | - otherwise, produce a dropdown menu
+ +-->
+ <xsl:template match="fi:field[fi:selection-list]" priority="1">
+ <xsl:variable name="value" select="fi:value"/>
+
+ <!-- dropdown or listbox -->
+ <select title="{fi:hint}" id="{@id}" name="{@id}">
+ <xsl:apply-templates select="." mode="styling"/>
+ <xsl:for-each select="fi:selection-list/fi:item">
+ <option value="{@value}">
+ <xsl:if test="@value = $value">
+ <xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:copy-of select="fi:label/node()"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--+
+ | fi:field with a selection list and @type 'output'
+ +-->
+ <xsl:template match="fi:field[fi:selection-list][fi:styling/@type='output']" priority="3">
+ <xsl:variable name="value" select="fi:value"/>
+ <xsl:variable name="selected" select="fi:selection-list/fi:item[@value = $value]"/>
+ <xsl:choose>
+ <xsl:when test="$selected/fi:label">
+ <xsl:apply-templates select="$selected/fi:label"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!--+
+ | fi:field with @type 'textarea'
+ +-->
+ <xsl:template match="fi:field[fi:styling/@type='textarea']">
+ <textarea id="{@id}" name="{@id}" title="{fi:hint}">
+ <xsl:apply-templates select="." mode="styling"/>
+ <!-- remove carriage-returns (occurs on certain versions of IE and doubles linebreaks at each submit) -->
+ <xsl:copy-of select="translate(fi:value/node(), ' ', '')"/>
+ </textarea>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--+
+ | fi:field with @type 'output' and fi:output are both rendered as text
+ +-->
+ <xsl:template match="fi:output | fi:field[fi:styling/@type='output']" priority="2">
+ <xsl:copy-of select="fi:value/node()"/>
+ </xsl:template>
+
+ <!--+
+ | Labels for form elements.
+ +-->
+ <xsl:template match="fi:*" mode="label">
+ <label for="{@id}" title="{fi:hint}">
+ <xsl:copy-of select="fi:label/node()"/>
+ </label>
+ </xsl:template>
+
+ <!--+
+ | Labels for pure outputs must not contain <label/> as there is no element to point to.
+ +-->
+ <xsl:template match="fi:output | fi:field[fi:styling/@type='output']" mode="label">
+ <xsl:copy-of select="fi:label/node()"/>
+ </xsl:template>
+
+ <!--+
+ | fi:booleanfield : produce a checkbox
+ +-->
+ <xsl:template match="fi:booleanfield">
+ <input id="{@id}" type="checkbox" value="true" name="{@id}" title="{fi:hint}">
+ <xsl:apply-templates select="." mode="styling"/>
+ <xsl:if test="fi:value = 'true'">
+ <xsl:attribute name="checked">checked</xsl:attribute>
+ </xsl:if>
+ </input>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--+
+ | fi:booleanfield with @type 'output' : rendered as text
+ +-->
+ <xsl:template match="fi:booleanfield[fi:styling/@type='output']">
+ <xsl:choose>
+ <xsl:when test="fi:value = 'true'">
+ yes
+ </xsl:when>
+ <xsl:otherwise>
+ no
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!--+
+ | fi:action
+ +-->
+ <xsl:template match="fi:action">
+ <input id="{@id}" type="submit" name="{@id}" title="{fi:hint}">
+ <xsl:attribute name="value"><xsl:value-of select="fi:label/node()"/></xsl:attribute>
+ <xsl:apply-templates select="." mode="styling"/>
+ </input>
+ </xsl:template>
+
+ <!--+
+ | fi:continuation-id : produce a hidden "continuation-id" input
+ +-->
+ <xsl:template match="fi:continuation-id">
+ <xsl:variable name="name">
+ <xsl:value-of select="@name"/>
+ <xsl:if test="not(@name)">continuation-id</xsl:if>
+ </xsl:variable>
+ <input name="{$name}" type="hidden" value="{.}"/>
+ </xsl:template>
+
+ <!--+
+ | fi:multivaluefield : produce a list of checkboxes
+ +-->
+ <xsl:template match="fi:multivaluefield[fi:styling/@list-type='checkbox']">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="values" select="fi:values/fi:value/text()"/>
+
+ <span title="{fi:hint}">
+ <xsl:for-each select="fi:selection-list/fi:item">
+ <xsl:variable name="value" select="@value"/>
+ <input id="{generate-id()}" type="checkbox" value="{@value}" name="{$id}">
+ <xsl:if test="$values[. = $value]">
+ <xsl:attribute name="checked">checked</xsl:attribute>
+ </xsl:if>
+ </input>
+ <label for="{generate-id()}"><xsl:copy-of select="fi:label/node()"/></label>
+ <br/>
+ </xsl:for-each>
+ </span>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--+
+ | fi:multivaluefield : produce a multiple-selection list
+ +-->
+ <xsl:template match="fi:multivaluefield">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="values" select="fi:values/fi:value/text()"/>
+
+ <span title="{fi:hint}">
+ <select id="{@id}" name="{$id}" multiple="multiple">
+ <xsl:apply-templates select="." mode="styling"/>
+ <xsl:for-each select="fi:selection-list/fi:item">
+ <xsl:variable name="value" select="@value"/>
+ <option value="{$value}">
+ <xsl:if test="$values[. = $value]">
+ <xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:copy-of select="fi:label/node()"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ </span>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--+
+ | fi:upload
+ +-->
+ <xsl:template match="fi:upload">
+ <xsl:choose>
+ <xsl:when test="fi:value">
+ <!-- Has a value (filename): display it with a change button -->
+ <span title="{fi:hint}">
+ [<xsl:value-of select="fi:value"/>] <input type="submit" id="{@id}" name="{@id}" value="..."/>
+ </span>
+ </xsl:when>
+ <xsl:otherwise>
+ <input type="file" id="{@id}" name="{@id}" title="{fi:hint}" accept="{@mime-types}"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--+
+ | fi:repeater
+ +-->
+ <xsl:template match="fi:repeater">
+ <input type="hidden" name="{@id}.size" value="{@size}"/>
+ <table border="1">
+ <tr>
+ <xsl:for-each select="fi:headings/fi:heading">
+ <th><xsl:value-of select="."/></th>
+ </xsl:for-each>
+ </tr>
+ <xsl:apply-templates select="fi:repeater-row"/>
+ </table>
+ </xsl:template>
+
+ <!--+
+ | fi:repeater-row
+ +-->
+ <xsl:template match="fi:repeater-row">
+ <tr>
+ <xsl:for-each select="*">
+ <td>
+ <xsl:apply-templates select="."/>
+ </td>
+ </xsl:for-each>
+ </tr>
+ </xsl:template>
+
+ <!--+
+ | fi:repeater-size
+ +-->
+ <xsl:template match="fi:repeater-size">
+ <input type="hidden" name="{@id}.size" value="{@size}"/>
+ </xsl:template>
+
+ <!--+
+ | fi:form-template|fi:form-generated
+ +-->
+ <xsl:template match="fi:form-template|fi:form-generated">
+ <form>
+ <xsl:copy-of select="@*"/>
+ <xsl:attribute name="onsubmit">forms_onsubmit(); <xsl:value-of select="@onsubmit"/></xsl:attribute>
+ <!-- hidden field to store the submit id -->
+ <div><input type="hidden" name="forms_submit_id"/></div>
+ <xsl:apply-templates/>
+
+ <!-- TODO: consider putting this in the xml stream from the generator? -->
+ <xsl:if test="self::fi:form-generated">
+ <input type="submit"/>
+ </xsl:if>
+ </form>
+ </xsl:template>
+
+ <!--+
+ | fi:form
+ +-->
+ <xsl:template match="fi:form">
+ <table border="1">
+ <xsl:for-each select="fi:widgets/*">
+ <tr>
+ <xsl:choose>
+ <xsl:when test="self::fi:repeater">
+ <td colspan="2">
+ <xsl:apply-templates select="."/>
+ </td>
+ </xsl:when>
+ <xsl:when test="self::fi:booleanfield">
+ <td> </td>
+ <td>
+ <xsl:apply-templates select="."/>
+ <xsl:text> </xsl:text>
+ <xsl:copy-of select="fi:label"/>
+ </td>
+ </xsl:when>
+ <xsl:otherwise>
+ <td>
+ <xsl:copy-of select="fi:label"/>
+ </td>
+ <td>
+ <xsl:apply-templates select="."/>
+ </td>
+ </xsl:otherwise>
+ </xsl:choose>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="fi:aggregatefield">
+ <input id="{@id}" name="{@id}" value="{fi:value}" title="{fi:hint}">
+ <xsl:apply-templates select="." mode="styling"/>
+ </input>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <xsl:template match="fi:messages">
+ <xsl:if test="fi:message">
+ <xsl:copy-of select="fi:label/node()"/>:
+ <ul>
+ <xsl:for-each select="fi:message">
+ <li><xsl:apply-templates/></li>
+ </xsl:for-each>
+ </ul>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="fi:validation-errors">
+ <xsl:variable name="header">
+ <xsl:choose>
+ <xsl:when test="header">
+ <xsl:copy-of select="header"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="forms-validation-errors">The following errors have been detected (marked with !):</p>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="footer">
+ <xsl:choose>
+ <xsl:when test="footer">
+ <xsl:copy-of select="footer"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="forms-validation-errors">Please, correct them and re-submit the form.</p>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="frm" select="ancestor::fi:form-template"/>
+ <xsl:if test="$frm and $frm//fi:validation-message">
+ <xsl:copy-of select="$header"/>
+ <ul>
+ <xsl:for-each select="$frm//fi:validation-message">
+ <li class="forms-validation-error">
+ <xsl:if test="../fi:label">
+ <xsl:value-of select="../fi:label"/><xsl:text>: </xsl:text>
+ </xsl:if>
+ <xsl:value-of select="."/>
+ </li>
+ </xsl:for-each>
+ </ul>
+ <xsl:copy-of select="$footer"/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="@*|node()" priority="-1">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-page-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-page-styling.xsl?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-page-styling.xsl (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/common/forms/forms-page-styling.xsl Wed Sep 28 01:08:23 2005
@@ -0,0 +1,336 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+ exclude-result-prefixes="fi">
+ <!--+
+ | This stylesheet is designed to be included by 'forms-samples-styling.xsl'.
+ +-->
+ <xsl:template match="head" mode="forms-page">
+ <!--+ 'forms-page-styling.xsl' relies on 'forms-field-styling.xsl' for the
+ | inclusion of the correct JS and CSS files. To fix it, we have to
+ | separate the page specific parts into their own files.
+ +-->
+ </xsl:template>
+
+ <xsl:template match="body" mode="forms-page"/>
+
+ <!--
+ fi:group : default is to enclose items in a div
+ -->
+ <xsl:template match="fi:group">
+ <div title="{fi:hint}">
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="group-layout" select="."/>
+ </div>
+ </xsl:template>
+
+ <!--
+ fi:group of type tabs
+ -->
+ <xsl:template match="fi:group[fi:styling/@type='tabs']">
+ <!-- find the currently selected tab.
+ Thoughts still needed here, such as autogenerating a field in the
+ forms transformer to hold this state.
+ -->
+ <xsl:variable name="active">
+ <xsl:variable name="value" select="normalize-space(fi:state/fi:*/fi:value)"/>
+ <xsl:choose>
+ <xsl:when test="$value">
+ <xsl:value-of select="$value"/>
+ </xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- copy the "state-widget" attribute for use in for-each -->
+ <xsl:variable name="state-widget" select="fi:state/fi:*/@id"/>
+ <xsl:variable name="id" select="generate-id()"/>
+
+ <div id="{$id}" title="{fi:hint}">
+ <!-- add an hidden input for the state -->
+ <xsl:if test="$state-widget">
+ <input type="hidden" name="{$state-widget}" value="{$active}"/>
+ </xsl:if>
+ <!-- div containing the tabs -->
+ <div class="forms-tabArea">
+ <xsl:for-each select="fi:items/fi:*">
+ <xsl:variable name="pos" select="position() - 1"/>
+ <span id="{$id}_tab_{$pos}" onclick="forms_showTab('{$id}', {$pos}, {last()}, '{$state-widget}')">
+ <xsl:attribute name="class">
+ <xsl:text>forms-tab</xsl:text>
+ <xsl:if test="$active = $pos"> forms-activeTab</xsl:if>
+ </xsl:attribute>
+ <xsl:copy-of select="fi:label/node()"/>
+ <xsl:if test="fi:items/*//fi:validation-message">
+ <span class="forms-validation-message"> ! </span>
+ </xsl:if>
+ </span>
+ </xsl:for-each>
+ </div>
+ <!-- a div for each of the items -->
+ <xsl:for-each select="fi:items/fi:*">
+ <xsl:variable name="pos" select="position() - 1"/>
+ <div class="forms-tabContent" id="{$id}_items_{$pos}">
+ <xsl:if test="$active != $pos">
+ <xsl:attribute name="style">display:none</xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="."/>
+ </div>
+ </xsl:for-each>
+ </div>
+ </xsl:template>
+
+ <!--
+ fi:group of type choice : a popup is used instead of tabs
+ -->
+ <xsl:template match="fi:group[fi:styling/@type='choice']">
+ <!-- find the currently selected tab.
+ Thoughts still needed here, such as autogenerating a field in the formstransformer
+ to hold this state.
+ -->
+ <xsl:variable name="active">
+ <xsl:variable name="value" select="normalize-space(fi:state/fi:*/fi:value)"/>
+ <xsl:choose>
+ <xsl:when test="$value">
+ <xsl:value-of select="$value"/>
+ </xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- copy the "state-widget" attribute for use in for-each -->
+ <xsl:variable name="state-widget" select="fi:state/fi:*/@id"/>
+ <xsl:variable name="id" select="generate-id()"/>
+
+ <fieldset id="{$id}">
+ <legend title="{fi:hint}">
+ <xsl:apply-templates select="fi:label/node()"/>
+ <select name="{$state-widget}" onchange="forms_showTab('{$id}', this.selectedIndex, {count(fi:items/*)}, '{$state-widget}')">
+ <xsl:for-each select="fi:items/fi:*">
+ <xsl:variable name="pos" select="position() - 1"/>
+ <option>
+ <xsl:attribute name="value">
+ <xsl:choose>
+ <xsl:when test="fi:value">
+ <xsl:value-of select="fi:value"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$pos"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:if test="$active = $pos">
+ <xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:copy-of select="fi:label/node()"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ <xsl:if test="fi:items/*//fi:validation-message">
+ <span class="forms-validation-message"> ! </span>
+ </xsl:if>
+ </legend>
+ <!-- a div for each of the items -->
+ <xsl:for-each select="fi:items/fi:*">
+ <xsl:variable name="pos" select="position() - 1"/>
+ <div id="{$id}_items_{$pos}">
+ <xsl:if test="$active != $pos">
+ <xsl:attribute name="style">display:none</xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="."/>
+ </div>
+ </xsl:for-each>
+ </fieldset>
+ </xsl:template>
+
+ <!--
+ fi:group of type fieldset : enclose items in a fieldset frame
+ -->
+ <xsl:template match="fi:group[fi:styling/@type='fieldset']">
+ <fieldset>
+ <xsl:apply-templates select="." mode="styling"/>
+ <legend title="{fi:hint}"><xsl:copy-of select="fi:label/node()"/></legend>
+ <xsl:apply-templates mode="group-layout" select="."/>
+ </fieldset>
+ </xsl:template>
+
+ <!--
+ Group items layout : default is no layout
+ -->
+ <xsl:template match="fi:group" mode="group-layout">
+ <xsl:apply-templates select="fi:items/*"/>
+ </xsl:template>
+
+ <!--
+ Column group items layout
+ -->
+ <xsl:template match="fi:group[fi:styling/@layout='column']" mode="group-layout">
+ <table border="0" summary="{fi:hint}">
+ <tbody>
+ <xsl:apply-templates select="fi:items/*" mode="group-column-content"/>
+ </tbody>
+ </table>
+ </xsl:template>
+
+ <!--
+ Default column layout : label above and input below
+ -->
+ <xsl:template match="fi:*" mode="group-column-content">
+ <tr>
+ <td><xsl:apply-templates select="." mode="label"/></td>
+ </tr>
+ <tr>
+ <td><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="fi:action" mode="group-column-content">
+ <tr>
+ <td><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
+ <!--
+ Columns group items layout
+ -->
+ <xsl:template match="fi:group[fi:styling/@layout='columns']" mode="group-layout">
+ <table border="0" summary="{fi:hint}">
+ <tbody>
+ <xsl:apply-templates select="fi:items/*" mode="group-columns-content"/>
+ </tbody>
+ </table>
+ </xsl:template>
+
+ <!--
+ Default columns layout : label left and input right
+ -->
+ <xsl:template match="fi:*" mode="group-columns-content">
+ <tr>
+ <td><xsl:apply-templates select="." mode="label"/></td>
+ <td><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
+ <!--
+ Row group items layout
+ -->
+ <xsl:template match="fi:group[fi:styling/@layout='row']" mode="group-layout">
+ <table border="0" summary="{fi:hint}">
+ <tbody>
+ <tr>
+ <xsl:apply-templates select="fi:items/*" mode="group-row-content"/>
+ </tr>
+ </tbody>
+ </table>
+ </xsl:template>
+
+ <!--
+ Default row layout : label left and input right
+ -->
+ <xsl:template match="fi:*" mode="group-row-content">
+ <td><xsl:apply-templates select="." mode="label"/></td>
+ <td><xsl:apply-templates select="."/></td>
+ </xsl:template>
+
+ <xsl:template match="fi:action" mode="group-row-content">
+ <td><xsl:apply-templates select="."/></td>
+ </xsl:template>
+ <!--
+ Rows group items layout
+ -->
+ <xsl:template match="fi:group[fi:styling/@layout='rows']" mode="group-layout">
+ <table border="0" summary="{fi:hint}">
+ <tbody>
+ <tr>
+ <xsl:apply-templates select="fi:items/*" mode="group-rows-labels"/>
+ </tr>
+ <tr>
+ <xsl:apply-templates select="fi:items/*" mode="group-rows-content"/>
+ </tr>
+ </tbody>
+ </table>
+ </xsl:template>
+
+ <!--
+ Default rows layout : label above and input below
+ -->
+ <xsl:template match="fi:*" mode="group-rows-labels">
+ <td><xsl:apply-templates select="." mode="label"/></td>
+ </xsl:template>
+
+ <xsl:template match="fi:action" mode="group-rows-labels">
+ <td> </td>
+ </xsl:template>
+
+ <xsl:template match="fi:*" mode="group-rows-content">
+ <td><xsl:apply-templates select="."/></td>
+ </xsl:template>
+
+ <!-- boolean field : checkbox and label on a single line -->
+ <xsl:template match="fi:booleanfield" mode="group-columns-content">
+ <tr>
+ <td colspan="2">
+ <xsl:apply-templates select="."/>
+ <xsl:apply-templates select="." mode="label"/>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <!-- action : on a single line -->
+ <xsl:template match="fi:action" mode="group-columns-content">
+ <tr>
+ <td colspan="2"><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
+ <!-- any other element : on a single line -->
+ <xsl:template match="*" mode="group-columns-content">
+ <tr>
+ <td colspan="2"><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
+ <!-- double-list multivaluefield : lists under the label -->
+ <xsl:template match="fi:multivaluefield[fi:styling/@list-type='double-listbox']"
+ mode="group-columns-content">
+ <tr>
+ <td colspan="2"><xsl:apply-templates select="." mode="label"/></td>
+ </tr>
+ <tr>
+ <td colspan="2"><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
+ <!-- nested group -->
+ <xsl:template match="fi:group" mode="group-columns-content">
+ <tr>
+ <td colspan="2"><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
+ <!--
+ The same rule exists in forms-fields-styling and forms-page-styling,
+ make sure they have different priorities, saxon complains if not
+ (or refactor, but it ain't really broke for now)
+ -->
+ <xsl:template match="@*|node()" priority="-2">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/sitemap.xmap?rev=292140&r1=292139&r2=292140&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/sitemap.xmap (original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/sitemap.xmap Wed Sep 28 01:08:23 2005
@@ -19,7 +19,7 @@
<!--
Main sitemap for the bricks-cms project
- $Id$
+ $Id: sitemap.xmap,v 1.1.1.1 2005/09/26 07:33:32 bdelacretaz Exp $
-->
<map:sitemap
xmlns:map="http://apache.org/cocoon/sitemap/1.0"
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/db-connect.js
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/db-connect.js?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/db-connect.js (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/db-connect.js Wed Sep 28 01:08:23 2005
@@ -0,0 +1,44 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+cocoon.load("context://bricks-cms/common/component-manager.js");
+
+// test database connection
+function public_db_connect() {
+ var displayUrl = cocoon.parameters.displayUrl;
+ var title = "Database connection test";
+ var message = "Testing...";
+
+ var registry = get_cm();
+ message += "Registry access ok...";
+
+ var dbConnector = registry.getService(Packages.org.apache.cocoon.apps.bricks.cms.ojb.DbConnectionProvider);
+ message += "DbConnectionProvider access ok...";
+
+ var conn = dbConnector.lookupConnection("UNUSED_PARAMETER");
+ message += "database connection ok...";
+
+ dbConnector.releaseConnection(conn);
+ message += "database connection released...";
+
+ message += "ok.";
+ var comment = "All tests successful";
+
+ cocoon.sendPage(
+ displayUrl,
+ { "title":title, "message":message, "comment":comment }
+ );
+}
\ No newline at end of file
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/db-connect.js
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/get-document.js
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/get-document.js?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/get-document.js (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/get-document.js Wed Sep 28 01:08:23 2005
@@ -0,0 +1,49 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+cocoon.load("context://bricks-cms/common/component-manager.js");
+
+// test reading a document via ObjectStore
+function public_get_document() {
+ var displayUrl = cocoon.parameters.displayUrl;
+ var docId = cocoon.parameters.id;
+ var title = "Retrieve BricksDocument having id=" + docId;
+ var message = "Testing...";
+
+ var registry = get_cm();
+ message += "Registry access ok...";
+
+ var objectStore = registry.getService(Packages.org.apache.cocoon.apps.bricks.cms.objectstore.ObjectStore);
+ message += "ObjectStore access ok...";
+
+ var documentClass = Packages.org.apache.cocoon.apps.bricks.cms.data.BricksDocument;
+ var template = objectStore.getTemplateObject(documentClass,docId);
+ message += "template object ok...";
+
+ var document = objectStore.queryByKey(template,false);
+ if(document==null) {
+ throw "BricksDocument having id " + docId + " not found"
+ }
+ message += "BricksDocument having id " + docId + " retrieved, title='" + document.title + "', content='" + document.content + "'...";
+
+ message += "ok.";
+ var comment = "All tests successful";
+
+ cocoon.sendPage(
+ displayUrl,
+ { "title":title, "message":message, "comment":comment }
+ );
+}
\ No newline at end of file
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/get-document.js
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/ping.js
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/ping.js?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/ping.js (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/ping.js Wed Sep 28 01:08:23 2005
@@ -0,0 +1,38 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+cocoon.load("context://bricks-cms/common/component-manager.js");
+
+// ping the component manager, try accessing a component
+function public_ping() {
+ var displayUrl = cocoon.parameters.displayUrl;
+ var title = "Ping!";
+ var message = "Flowscript is alive";
+
+ var registry = get_cm();
+ var pingComponent = registry.getService(Packages.org.apache.cocoon.apps.bricks.cms.componentmanager.ComponentManagerPing);
+ message = pingComponent.ping();
+
+ var comment =
+ "Above this text you should see a message saying 'Hello from the ComponentManagerPing component', "
+ + "which shows that access to components managed by Hivemind works."
+ ;
+
+ cocoon.sendPage(
+ displayUrl,
+ { "title":title, "message":message, "comment":comment }
+ );
+}
\ No newline at end of file
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/ping.js
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/sitemap.xmap?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/sitemap.xmap (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/sitemap.xmap Wed Sep 28 01:08:23 2005
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ admin sitemap for the bricks-cms project
+
+ $Id: sitemap.xmap,v 1.3 2005/09/26 14:37:48 bdelacretaz Exp $
+-->
+<map:sitemap
+ xmlns:map="http://apache.org/cocoon/sitemap/1.0"
+ >
+
+ <map:flow language="javascript">
+ <map:script src="ping.js"/>
+ <map:script src="db-connect.js"/>
+ <map:script src="get-document.js"/>
+ </map:flow>
+
+ <map:resources>
+ <!-- use admin layout for tests -->
+ <map:resource name="layout">
+ <map:transform src="../admin/xslt/page-to-html.xsl"/>
+ <map:serialize type="html"/>
+ </map:resource>
+ </map:resources>
+
+ <map:pipelines>
+
+ <map:pipeline internal-only="true">
+ <map:match pattern="user-message">
+ <map:generate type="jx" src="user-message.jx.xml"/>
+ <map:call resource="layout"/>
+ </map:match>
+ </map:pipeline>
+
+ <map:pipeline>
+ <map:match pattern="">
+ <map:redirect-to uri="test-homepage"/>
+ </map:match>
+
+ <map:match pattern="flowscript-test/*">
+ <map:call function="public_{1}">
+ <map:parameter name="displayUrl" value="user-message"/>
+ </map:call>
+ </map:match>
+
+ <map:match pattern="flowscript-test/*/id-*">
+ <map:call function="public_{1}">
+ <map:parameter name="displayUrl" value="user-message"/>
+ <map:parameter name="id" value="{2}"/>
+ </map:call>
+ </map:match>
+
+ <!--
+ serve static images, CSS, etc from the admin path
+ accept any path before admin-resources to make it easier
+ -->
+ <map:match pattern="**/admin-resources/**">
+ <map:read src="../admin/static-content/resources/{2}"/>
+ </map:match>
+
+ <map:match pattern="*">
+ <map:generate type="jx" src="{1}.xml"/>
+ <map:call resource="layout"/>
+ </map:match>
+ </map:pipeline>
+
+ </map:pipelines>
+
+</map:sitemap>
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/test-homepage.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/test-homepage.xml?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/test-homepage.xml (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/test-homepage.xml Wed Sep 28 01:08:23 2005
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<page>
+ <metadata>
+ <title>bricks-cms test homepage</title>
+ </metadata>
+
+ <content>
+ <ul>
+ <li>
+ <a href="flowscript-test/ping">ping</a> - tests access to a simple Hivemind component.
+ </li>
+ <li>
+ <a href="flowscript-test/db_connect">db_connect</a> - makes a connection to the Derby database,
+ via a java component managed by Hivemind.
+ </li>
+ <li>
+ <a href="flowscript-test/get_document/id-1">get_document/id-1</a> - attempts to
+ retrieve document having ID 1 via OJB.
+ </li>
+ </ul>
+ </content>
+</page>
\ No newline at end of file
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/test-homepage.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/user-message.jx.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/user-message.jx.xml?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/user-message.jx.xml (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/user-message.jx.xml Wed Sep 28 01:08:23 2005
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ JXTemplate used to display a user message
+-->
+
+<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+ <metadata>
+ <title>bricks-cms message: #{title}</title>
+ </metadata>
+
+ <content>
+ <page>
+ <p>${message}</p>
+ <p><em>${comment}</em></p>
+ </page>
+ </content>
+</page>
\ No newline at end of file
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/bricks-cms/test/user-message.jx.xml
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/welcome.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/welcome.xml?rev=292140&r1=292139&r2=292140&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/welcome.xml (original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/welcome.xml Wed Sep 28 01:08:23 2005
@@ -26,6 +26,11 @@
<message>
Use
<link href="bricks-cms/">bricks-cms/</link>
- to access the bricks-cms Cocoon application.
+ to access the main bricks-cms Cocoon application.
+ </message>
+ <message>
+ Use
+ <link href="bricks-cms/test/">bricks-cms/test/</link>
+ to access the bricks-cms test functions.
</message>
</welcome>
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/webapp/welcome.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/xconf/ComponentManagerInitializer.xweb
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/xconf/log4j-logger.xweb
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/xconf/log4j-logger.xweb?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/xconf/log4j-logger.xweb (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/xconf/log4j-logger.xweb Wed Sep 28 01:08:23 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ patch web.xml to use log4j for logging
+ (mainly because OJB uses it as by default)
+
+ $Id$
+-->
+
+<xweb
+ xpath="/web-app/servlet"
+ unless="/web-app/servlet/init-param[param-name='logger-class']"
+ insert-after="init-param"
+>
+ <!-- use log4j for logging, patch defined in log4j-logger.xweb -->
+ <init-param>
+ <param-name>logger-class</param-name>
+ <param-value>LOG4J</param-value>
+ </init-param>
+</xweb>
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/cocoon/xconf/log4j-logger.xweb
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ApplicationComponentManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ApplicationComponentManager.java?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ApplicationComponentManager.java (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ApplicationComponentManager.java Wed Sep 28 01:08:23 2005
@@ -0,0 +1,68 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package org.apache.cocoon.apps.bricks.cms.componentmanager;
+
+import java.util.Date;
+import org.apache.hivemind.Registry;
+
+/** Facade to our actual component manager (resources), created for strict
+ * control of what we use from the resources Registry. Would make it easier to
+ * switch to another component manager, assuming all application components
+ * are created via this class.
+ */
+
+public class ApplicationComponentManager {
+ private final Registry registry;
+ private final Date creationDate = new Date();
+ private static ApplicationComponentManager singleInstance;
+
+ public ApplicationComponentManager(Registry reg) {
+ if(singleInstance != null) {
+ throw new Error("There must be only one instance of the ApplicationComponentManager");
+ }
+ singleInstance = this;
+ registry = reg;
+ }
+
+ /** singleton-like access, use this instead of using the resources Registry directly */
+ public static ApplicationComponentManager getInstance() {
+ return singleInstance;
+ }
+
+ /** identify this */
+ public String toString() {
+ return getClass().getName() + " created on " + creationDate;
+ }
+
+ /** obtain a service with a single implementation from the registry.
+ * Exactly one service point must implement the service.
+ */
+ public Object getService(Class aClass) {
+ return registry.getService(aClass);
+ }
+
+ /** obtain a service by name, checking that it implements the required interface
+ */
+ public Object getService(String name,Class aClass) {
+ return registry.getService(name,aClass);
+ }
+
+ /** shutdown the component manager */
+ public void shutdown() {
+ registry.shutdown();
+ }
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ApplicationComponentManager.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerInitializer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerInitializer.java?rev=292140&r1=292139&r2=292140&view=diff
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerInitializer.java (original)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerInitializer.java Wed Sep 28 01:08:23 2005
@@ -18,6 +18,8 @@
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
+import org.apache.hivemind.Registry;
+import org.apache.hivemind.impl.RegistryBuilder;
/**
* Called as a ServletContextListener at startup, initializes the Hivemind Registry
@@ -28,13 +30,11 @@
public static final String COMPONENT_MANAGER_ATTRIBUTE = "application.component.manager";
- /**
- * Notification that the web application initialization process is starting.
- * Create our ApplicationComponentManager, and add it to the servlet context,
- * so that it is easily accessible from flowscript or java code.
+ /** Notification that the web application initialization process is starting.
+ * Create our ApplicationComponentManager, and add it to the servlet context,
+ * so that it is easily accessible from flowscript or java code.
*/
public void contextInitialized(ServletContextEvent event) {
- /* TODO setup component manager
event.getServletContext().log("ComponentManagerInitializer: initializing hivemind registry...");
final Registry r = RegistryBuilder.constructDefaultRegistry();
final ApplicationComponentManager cm = new ApplicationComponentManager(r);
@@ -43,15 +43,11 @@
"ComponentManagerInitializer: ApplicationComponentManager added to servlet context as attribute '"
+ COMPONENT_MANAGER_ATTRIBUTE + "'"
);
- */
}
- /**
- * Notification that the servlet context is about to be shut down.
- * Shutdown the hivemind registry
- */
+ /** Notification that the servlet context is about to be shut down.
+ * Shutdown the hivemind registry */
public void contextDestroyed(ServletContextEvent event) {
- /* TODO setup component manager
event.getServletContext().log("ComponentManagerInitializer: processing contextDestroyed event");
final ApplicationComponentManager cm = (ApplicationComponentManager)event.getServletContext().getAttribute(COMPONENT_MANAGER_ATTRIBUTE);
@@ -61,6 +57,5 @@
event.getServletContext().log("ComponentManagerInitializer: hivemind registry shutdown");
cm.shutdown();
}
- */
}
}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerInitializer.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerPing.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerPing.java?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerPing.java (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerPing.java Wed Sep 28 01:08:23 2005
@@ -0,0 +1,21 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package org.apache.cocoon.apps.bricks.cms.componentmanager;
+
+public interface ComponentManagerPing {
+ String ping();
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/ComponentManagerPing.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/impl/ComponentManagerPingImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/impl/ComponentManagerPingImpl.java?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/impl/ComponentManagerPingImpl.java (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/impl/ComponentManagerPingImpl.java Wed Sep 28 01:08:23 2005
@@ -0,0 +1,35 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package org.apache.cocoon.apps.bricks.cms.componentmanager.impl;
+
+import org.apache.cocoon.apps.bricks.cms.componentmanager.ComponentManagerPing;
+
+import java.util.Date;
+
+public class ComponentManagerPingImpl implements ComponentManagerPing {
+
+ private String message = "ComponentManagerPingImpl: MESSAGE NOT SET??";
+
+ public String ping() {
+ return message + ", it's now " + new Date();
+ }
+
+ public void setMessage(String msg) {
+ message = msg;
+ }
+
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/componentmanager/impl/ComponentManagerPingImpl.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/data/BricksDocument.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/data/BricksDocument.java?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/data/BricksDocument.java (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/data/BricksDocument.java Wed Sep 28 01:08:23 2005
@@ -0,0 +1,71 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package org.apache.cocoon.apps.bricks.cms.data;
+
+import org.apache.cocoon.apps.bricks.cms.objectstore.ObjectStore;
+
+import java.util.Date;
+import java.sql.Timestamp;
+
+public class BricksDocument implements ObjectStore.TemplateObjectProvider {
+ private int id;
+ private int persistentStorageVersion;
+ private String title = "";
+ private String content = "";
+ private Timestamp created = new Timestamp(System.currentTimeMillis());
+ private Timestamp lastModified = new Timestamp(System.currentTimeMillis());
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ updated();
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ updated();
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getLastModified() {
+ return lastModified;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ private void updated() {
+ lastModified = new Timestamp(System.currentTimeMillis());
+ }
+
+ public Object getTemplateObject(int key) throws Exception {
+ final BricksDocument result = new BricksDocument();
+ result.id = key;
+ return result;
+ }
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/data/BricksDocument.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java Wed Sep 28 01:08:23 2005
@@ -0,0 +1,37 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package org.apache.cocoon.apps.bricks.cms.objectstore;
+
+public interface ObjectStore {
+
+ /** data objects implement this to provide a key object for retrieval */
+ static interface TemplateObjectProvider {
+ Object getTemplateObject(int key) throws Exception;
+ };
+
+ /** save or update given object */
+ void store(Object o) throws Exception;
+
+ /** generic object retrieval */
+ Object queryByKey(Object exampleHavingSpecifiedKey,boolean forWriting) throws Exception;
+
+ /** create a template object, for retrieval by key */
+ Object getTemplateObject(Class clazz,int key) throws Exception;
+
+ /** create an empty object of the given class */
+ Object createNew(Class clazz) throws Exception;
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/ObjectStore.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java Wed Sep 28 01:08:23 2005
@@ -0,0 +1,99 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package org.apache.cocoon.apps.bricks.cms.objectstore.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.query.QueryByIdentity;
+import org.apache.ojb.broker.query.Query;
+import org.apache.cocoon.apps.bricks.cms.ojb.OjbTransactionHelper;
+import org.apache.cocoon.apps.bricks.cms.objectstore.ObjectStore;
+
+public class OjbObjectStore implements ObjectStore {
+ private Log log;
+
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ /** create or save given Object */
+ public void store(final Object data) throws Exception {
+ if(log.isDebugEnabled()) {
+ log.debug("Storing object of class " + data.getClass().getName());
+ }
+
+ final OjbTransactionHelper oth = new OjbTransactionHelper() {
+ protected void runTransaction(PersistenceBroker broker) throws Exception {
+ broker.store(data);
+ }
+ };
+
+ oth.execute();
+ }
+
+ /** create a template object, for retrieval by key */
+ public Object getTemplateObject(Class clazz,int key) throws Exception {
+ ObjectStore.TemplateObjectProvider top = null;
+ try {
+ top = (ObjectStore.TemplateObjectProvider)clazz.newInstance();
+ } catch(Exception e) {
+ throw new Exception("Cannot create a ObjectStore.TemplateObjectProvider from class '" + clazz.getName() + "':" + e);
+ }
+ return top.getTemplateObject(key);
+ }
+
+ /**
+ * generic object retrieval
+ */
+ public Object queryByKey(final Object template, final boolean forWriting) throws Exception {
+ if(log.isDebugEnabled()) {
+ log.debug("Retrieving object of class " + template.getClass().getName());
+ }
+
+ final OjbTransactionHelper oth = new OjbTransactionHelper() {
+ protected void runTransaction(PersistenceBroker broker) throws Exception {
+ final Query q = new QueryByIdentity(template);
+ final Object result = broker.getObjectByQuery(q);
+
+ // if forWriting, remove object from OJB cache, so that optimistic locking works
+ if(result != null && forWriting) {
+ broker.removeFromCache(result);
+ }
+
+ setResult(result);
+ }
+ };
+
+ oth.execute();
+ return oth.getResult();
+ }
+
+ /**
+ * Create an empty object of the given class
+ * Clients could go directly to constructors, but having them go through here
+ * makes this more similar to the queryByKey works
+ */
+ public Object createNew(Class clazz) throws Exception {
+ Object result = null;
+ try {
+ result = clazz.newInstance();
+ } catch(Exception e) {
+ throw new Exception("Unable to create object of class '" + clazz.getName() + "': " + e);
+ }
+ return result;
+ }
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/objectstore/impl/OjbObjectStore.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/ojb/DbConnectionProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/ojb/DbConnectionProvider.java?rev=292140&view=auto
==============================================================================
--- cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/ojb/DbConnectionProvider.java (added)
+++ cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/ojb/DbConnectionProvider.java Wed Sep 28 01:08:23 2005
@@ -0,0 +1,28 @@
+/*
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package org.apache.cocoon.apps.bricks.cms.ojb;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public interface DbConnectionProvider {
+ /** get a Connection given its alias */
+ Connection lookupConnection(String alias) throws SQLException;
+
+ /** release given connection */
+ void releaseConnection(Connection connection) throws SQLException;
+}
Propchange: cocoon/whiteboard/example-apps/bricks-cms/src/java/org/apache/cocoon/apps/bricks/cms/ojb/DbConnectionProvider.java
------------------------------------------------------------------------------
svn:keywords = Id