You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/06/13 15:46:55 UTC

svn commit: r413894 - in /lenya/trunk/src/modules/usecase: ./ config/ config/cocoon-xconf/ java/ java/src/ java/src/org/ java/src/org/apache/ java/src/org/apache/lenya/ java/src/org/apache/lenya/cms/ java/src/org/apache/lenya/cms/cocoon/ java/src/org/a...

Author: andreas
Date: Tue Jun 13 06:46:54 2006
New Revision: 413894

URL: http://svn.apache.org/viewvc?rev=413894&view=rev
Log:
Added usecase resource type module - this allows to execute usecases as documents.

Added:
    lenya/trunk/src/modules/usecase/
    lenya/trunk/src/modules/usecase/config/
    lenya/trunk/src/modules/usecase/config/cocoon-xconf/
    lenya/trunk/src/modules/usecase/config/cocoon-xconf/modules.xconf
    lenya/trunk/src/modules/usecase/config/cocoon-xconf/resource-type-usecase.xconf
    lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-contactForm.xconf
    lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-createUsecaseDocument.xconf
    lenya/trunk/src/modules/usecase/config/menu.xsp
    lenya/trunk/src/modules/usecase/java/
    lenya/trunk/src/modules/usecase/java/src/
    lenya/trunk/src/modules/usecase/java/src/org/
    lenya/trunk/src/modules/usecase/java/src/org/apache/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/modules/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/modules/input/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/site/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/site/usecases/
    lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java
    lenya/trunk/src/modules/usecase/menus.xmap
    lenya/trunk/src/modules/usecase/resources/
    lenya/trunk/src/modules/usecase/resources/schemas/
    lenya/trunk/src/modules/usecase/resources/schemas/usecase.rng
    lenya/trunk/src/modules/usecase/samples/
    lenya/trunk/src/modules/usecase/samples/usecase.xml
    lenya/trunk/src/modules/usecase/sitemap.xmap
    lenya/trunk/src/modules/usecase/usecases/
    lenya/trunk/src/modules/usecase/usecases/contactForm.jx
    lenya/trunk/src/modules/usecase/usecases/createUsecaseDocument.jx

Added: lenya/trunk/src/modules/usecase/config/cocoon-xconf/modules.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/config/cocoon-xconf/modules.xconf?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/config/cocoon-xconf/modules.xconf (added)
+++ lenya/trunk/src/modules/usecase/config/cocoon-xconf/modules.xconf Tue Jun 13 06:46:54 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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.
+-->
+
+<!-- $Id: doctypes.xconf 164635 2005-04-25 20:01:43Z tschlabach $ -->
+
+<xconf xpath="/cocoon/input-modules" unless="/cocoon/input-modules/component-instance[@name = 'usecase-document']">
+
+  <component-instance logger="core.modules.input.usecase-document" name="usecase-document"
+    class="org.apache.lenya.cms.cocoon.components.modules.input.UsecaseDocumentModule"/>
+  
+</xconf>

Added: lenya/trunk/src/modules/usecase/config/cocoon-xconf/resource-type-usecase.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/config/cocoon-xconf/resource-type-usecase.xconf?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/config/cocoon-xconf/resource-type-usecase.xconf (added)
+++ lenya/trunk/src/modules/usecase/config/cocoon-xconf/resource-type-usecase.xconf Tue Jun 13 06:46:54 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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.
+-->
+
+<!-- $Id: doctypes.xconf 164635 2005-04-25 20:01:43Z tschlabach $ -->
+
+<xconf xpath="/cocoon/resource-types" unless="/cocoon/resource-types/component-instance[@name = 'usecase']">
+  
+  <component-instance name="usecase"
+    logger="lenya.resourcetypes.usecase"
+    class="org.apache.lenya.cms.publication.ResourceTypeImpl">
+    <schema language="http://relaxng.org/ns/structure/0.9"
+      src="fallback://lenya/modules/usecase/resources/schemas/usecase.rng"/>
+    
+    <sample-name>fallback://lenya/modules/usecase/samples/usecase.xml</sample-name>
+    
+    <format name="xhtml" uri="cocoon://modules/usecase/usecase.xml"/>
+  </component-instance>
+  
+</xconf>

Added: lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-contactForm.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-contactForm.xconf?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-contactForm.xconf (added)
+++ lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-contactForm.xconf Tue Jun 13 06:46:54 2006
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<!-- $Id: usecases-workflow-deactivate.xconf 348547 2005-11-23 20:13:01Z chestnut $ -->
+<!--
+    This file defines the publication specific use-cases
+-->
+
+  <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'usecase.contactForm']">
+
+    <component-instance name="usecase.contactForm" logger="lenya.usecase"
+      class="org.apache.lenya.cms.usecase.DummyUsecase">
+      <view template="modules/usecase/usecases/contactForm.jx"/>
+    </component-instance>
+    
+  </xconf>

Added: lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-createUsecaseDocument.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-createUsecaseDocument.xconf?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-createUsecaseDocument.xconf (added)
+++ lenya/trunk/src/modules/usecase/config/cocoon-xconf/usecase-createUsecaseDocument.xconf Tue Jun 13 06:46:54 2006
@@ -0,0 +1,27 @@
+<?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.
+-->
+
+<!-- $Id: usecases-workflow-deactivate.xconf 348547 2005-11-23 20:13:01Z chestnut $ -->
+<!--
+    This file defines the publication specific use-cases
+-->
+
+  <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'usecase.createUsecaseDocument']">
+    <component-instance name="usecase.createUsecaseDocument" logger="lenya.site" class="org.apache.lenya.cms.site.usecases.CreateUsecaseDocument">
+      <view template="modules/usecase/usecases/createUsecaseDocument.jx"/>
+    </component-instance>
+  </xconf>

Added: lenya/trunk/src/modules/usecase/config/menu.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/config/menu.xsp?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/config/menu.xsp (added)
+++ lenya/trunk/src/modules/usecase/config/menu.xsp Tue Jun 13 06:46:54 2006
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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.
+-->
+
+<!-- $Id: generic.xsp 155806 2005-03-01 17:55:42Z andreas $ -->
+
+<xsp:page 
+    language="java" 
+    xmlns:xsp="http://apache.org/xsp"
+    xmlns:xsp-request="http://apache.org/xsp/request/2.0"
+    xmlns:input="http://apache.org/cocoon/xsp/input/1.0"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
+    xmlns:wf="http://apache.org/cocoon/lenya/workflow/1.0"
+    xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
+    xmlns="http://apache.org/cocoon/lenya/menubar/1.0"
+>
+
+  <xsp:structure>
+    <xsp:include>org.apache.lenya.cms.publication.Document</xsp:include>
+    <xsp:include>org.apache.lenya.cms.publication.Publication</xsp:include>
+  </xsp:structure>
+  
+  <menu>
+
+    <menus>
+      <menu i18n:attr="name" name="File">
+        <block admin="false">
+          <item uc:usecase="usecase.createUsecaseDocument" href="?usecase=usecase.contactForm"><i18n:text>New Usecase Document</i18n:text></item>
+        </block>
+      </menu>
+    </menus>
+    
+  </menu>
+</xsp:page>

Added: lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java (added)
+++ lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UsecaseDocumentModule.java Tue Jun 13 06:46:54 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright  1999-2004 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.lenya.cms.cocoon.components.modules.input;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.components.modules.input.AbstractInputModule;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.site.usecases.CreateUsecaseDocument;
+
+/**
+ * Module to retrieve information from a usecase resource type document.
+ */
+public class UsecaseDocumentModule extends AbstractInputModule implements Serviceable {
+
+    protected static final String USECASE = "usecase";
+
+    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
+            throws ConfigurationException {
+
+        Object value = null;
+        try {
+            if (name.equals(USECASE)) {
+                Request request = ObjectModelHelper.getRequest(objectModel);
+                Document doc = DocumentUtil.getCurrentDocument(this.manager, request);
+                org.w3c.dom.Document xmlDoc = SourceUtil.readDOM(doc.getSourceURI(), this.manager);
+                String usecaseName = xmlDoc.getDocumentElement().getAttribute(CreateUsecaseDocument.ATTRIBUTE_NAME);
+                value = usecaseName;
+            }
+        } catch (Exception e) {
+            throw new ConfigurationException("Could not obtain value: ", e);
+        }
+        return value;
+    }
+
+    protected ServiceManager manager;
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+
+}

Added: lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java (added)
+++ lenya/trunk/src/modules/usecase/java/src/org/apache/lenya/cms/site/usecases/CreateUsecaseDocument.java Tue Jun 13 06:46:54 2006
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ *
+ */
+package org.apache.lenya.cms.site.usecases;
+
+import java.util.Arrays;
+
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.usecase.UsecaseResolver;
+import org.apache.lenya.xml.NamespaceHelper;
+import org.w3c.dom.Element;
+
+/**
+ * <p>
+ * Create a usecase document. The document content looks like this:
+ * </p>
+ * 
+ * <pre>
+ *   &lt;usecase name=&quot;...&quot;/&gt;
+ * </pre>
+ */
+public class CreateUsecaseDocument extends CreateDocument {
+
+    protected static final String USECASE = "usecase";
+    protected static final String RESOURCE_TYPE_USECASE = "usecase";
+
+    /**
+     * The namespace for usecase document content.
+     */
+    public static final String NAMESPACE = "http://apache.org/lenya/usecase/1.0";
+
+    /**
+     * The local name of the usecase XML element.
+     */
+    public static final String ELEMENT_USECASE = "usecase";
+
+    /**
+     * The local name of the name attribute.
+     */
+    public static final String ATTRIBUTE_NAME = "name";
+    
+    protected void initParameters() {
+        super.initParameters();
+        setParameter(DOCUMENT_TYPE, RESOURCE_TYPE_USECASE);
+        setParameter(RESOURCE_TYPES, Arrays.asList(new String[0]));
+    }
+
+    protected void doCheckExecutionConditions() throws Exception {
+        super.doCheckExecutionConditions();
+
+        String usecaseName = getParameterAsString(USECASE);
+        if (usecaseName.equals("")) {
+            addErrorMessage("Please enter a usecase name.");
+        } else {
+            UsecaseResolver resolver = null;
+            try {
+                resolver = (UsecaseResolver) this.manager.lookup(UsecaseResolver.ROLE);
+                if (!resolver.isRegistered(getSourceURL(), usecaseName)) {
+                    addErrorMessage("The usecase '" + usecaseName + "' is not registered.");
+                }
+            } finally {
+                if (resolver != null) {
+                    this.manager.release(resolver);
+                }
+            }
+        }
+    }
+
+    protected void doExecute() throws Exception {
+        super.doExecute();
+
+        NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", ELEMENT_USECASE);
+        Element usecaseElement = helper.getDocument().getDocumentElement();
+        usecaseElement.setAttribute(ATTRIBUTE_NAME, getParameterAsString(USECASE));
+        SourceUtil.writeDOM(helper.getDocument(), getNewDocument().getSourceURI(), this.manager);
+
+    }
+
+}

Added: lenya/trunk/src/modules/usecase/menus.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/menus.xmap?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/menus.xmap (added)
+++ lenya/trunk/src/modules/usecase/menus.xmap Tue Jun 13 06:46:54 2006
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 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.
+-->
+
+<!-- $Id: menus.xmap 178738 2005-05-27 03:42:09Z gregor $ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:pipelines>
+
+    <map:pipeline>
+    	
+      <map:match pattern="**">
+        <map:generate type="serverpages" src="fallback://lenya/modules/usecase/config/menu.xsp"/>
+        <map:serialize type="xml"/>
+      </map:match>
+      
+    </map:pipeline>
+    
+  </map:pipelines>
+</map:sitemap>

Added: lenya/trunk/src/modules/usecase/resources/schemas/usecase.rng
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/resources/schemas/usecase.rng?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/resources/schemas/usecase.rng (added)
+++ lenya/trunk/src/modules/usecase/resources/schemas/usecase.rng Tue Jun 13 06:46:54 2006
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<element name="usecase" ns="http://apache.org/lenya/usecase/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
+
+  <attribute name="name">
+    <text/>
+  </attribute>
+
+</element>

Added: lenya/trunk/src/modules/usecase/samples/usecase.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/samples/usecase.xml?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/samples/usecase.xml (added)
+++ lenya/trunk/src/modules/usecase/samples/usecase.xml Tue Jun 13 06:46:54 2006
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<usecase xmlns="http://apache.org/lenya/usecase/1.0" name="usecase.contactForm"/>

Added: lenya/trunk/src/modules/usecase/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/sitemap.xmap?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/sitemap.xmap (added)
+++ lenya/trunk/src/modules/usecase/sitemap.xmap Tue Jun 13 06:46:54 2006
@@ -0,0 +1,99 @@
+<?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.
+-->
+
+<!-- $Id: usecase.xmap 407452 2006-05-18 04:14:16Z chestnut $ -->
+<!--
+    This sitemap handles calls to usecases which are registered in the
+    usecase framework.
+-->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:components>
+    <map:transformers default="xslt">    
+      <map:transformer name="browser-update" src="org.apache.cocoon.ajax.BrowserUpdateTransformer"/>
+    </map:transformers>
+    <map:selectors>
+      <map:selector name="ajax-request" src="org.apache.cocoon.ajax.AjaxRequestSelector"/>
+    </map:selectors>
+  </map:components>
+  
+  <!-- =========================== FlowScript =============================== -->
+
+  <map:flow language="javascript">
+    <map:script src="fallback://lenya/usecases/usecases.js"/>
+  </map:flow>
+  
+  <!-- =========================== Pipelines ================================ -->
+
+  <map:pipelines>
+    
+    <map:pipeline type="noncaching">
+      <map:match pattern="redirect">
+        <map:generate src="context://lenya/content/admin/common/redirect.xsp" type="serverpages"/>
+        <map:transform src="context://lenya/xslt/admin/common/redirect.xsl"/>
+        <map:serialize/>
+      </map:match>
+      
+      <!-- 
+        This internal sitemap fragment renders the usecase, once the
+        executeUsecase() flowscript has completed and issued a redirect,
+        which is matched here.
+        -->
+      <map:match pattern="view/*/**" internal-only="true">
+        
+        <map:generate type="jx" src="fallback://lenya/{2}"/>
+        <map:transform type="browser-update"/>
+        <map:transform type="cinclude"/>
+        <map:transform type="forms" />
+        <map:transform type="i18n">
+          <map:parameter name="locale" value="{request:locale}"/>
+        </map:transform>
+        
+        <!-- Strip xhtml namespace from <head> and <body> element -->
+        <map:transform src="fallback://lenya/xslt/cforms/strip-xhtml-namespace.xsl"/>
+        <map:transform src="fallback://lenya/xslt/cforms/forms-samples-styling.xsl">
+          <map:parameter name="resources-uri" value="{page-envelope:context-prefix}/cforms"/>
+        </map:transform>
+        <map:transform src="fallback://lenya/xslt/cforms/add-xhtml-namespace.xsl"/>
+        
+        <map:transform src="fallback://lenya/modules/xhtml/xslt/xhtml2xhtml.xsl">
+          <map:parameter name="rendertype" value="{request-param:rendertype}"/>
+          <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
+          <map:parameter name="language" value="{page-envelope:document-language}"/>
+        </map:transform>
+        
+        <map:serialize type="xml"/>
+
+     </map:match>
+      
+    </map:pipeline>
+
+    <map:pipeline>
+      <map:match type="request-parameter" pattern="lenya.continuation">
+        <map:call continuation="{1}"/>
+      </map:match>
+      <map:match pattern="usecase.xml">
+        <map:call function="executeUsecase">
+          <map:parameter name="usecaseName" value="{usecase-document:usecase}"/>
+        </map:call>
+      </map:match>
+    </map:pipeline>
+    
+  </map:pipelines>
+	
+</map:sitemap>

Added: lenya/trunk/src/modules/usecase/usecases/contactForm.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/usecases/contactForm.jx?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/usecases/contactForm.jx (added)
+++ lenya/trunk/src/modules/usecase/usecases/contactForm.jx Tue Jun 13 06:46:54 2006
@@ -0,0 +1,77 @@
+<!--
+  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.
+-->
+<!-- $Id: changePassword.jx 412987 2006-06-09 09:01:58Z andreas $ -->
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+  
+  <body>
+    
+    <h2><i18n:text>Contact</i18n:text></h2>
+    
+    <jx:choose>
+      <jx:when test="${usecase.getParameter('sent').equals('true')}">
+        <p>
+          Sorry - your message was not sent because this is just a sample usecase.
+        </p>
+        <p>
+          <form id="form-contact">
+            <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+            <input type="submit" name="submit" value="Try again"/>
+          </form>
+        </p>
+      </jx:when>
+      <jx:otherwise>
+
+        <form id="form-contact">
+          <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+          <input type="hidden" name="sent" value="true"/>
+          
+          <table style="font-size: small">
+            <tr>
+              <td colspan="2">
+                <jx:import uri="fallback://lenya/usecases/templates/messages.jx"/>
+              </td>
+            </tr>
+            
+            <tr>
+              <td><label for="name"><i18n:text>Your Name</i18n:text> *</label></td>
+              <td><input type="text" name="password" value="${usecase.getParameter('name')}"/></td>
+            </tr>
+            <tr>
+              <td><label for="email"><i18n:text>Your E-Mail Address</i18n:text> *</label></td>
+              <td><input type="text" name="email" value="${usecase.getParameter('email')}"/></td>
+            </tr>
+            <tr>
+              <td><label for="message"><i18n:text>Your Message</i18n:text> *</label></td>
+              <td><textarea name="message"><jx:out value="${usecase.getParameter('message')}"/></textarea></td>
+            </tr>
+            
+            <tr>
+              <td/>
+              <td>
+                <input i18n:attr="value" type="submit" value="Submit"/>
+              </td>
+            </tr>
+          </table>
+        </form>
+        
+      </jx:otherwise>
+    </jx:choose>
+    
+  </body>
+</html>
\ No newline at end of file

Added: lenya/trunk/src/modules/usecase/usecases/createUsecaseDocument.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/usecase/usecases/createUsecaseDocument.jx?rev=413894&view=auto
==============================================================================
--- lenya/trunk/src/modules/usecase/usecases/createUsecaseDocument.jx (added)
+++ lenya/trunk/src/modules/usecase/usecases/createUsecaseDocument.jx Tue Jun 13 06:46:54 2006
@@ -0,0 +1,243 @@
+<?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.
+-->
+
+<!-- $Id: create.jx 376630 2006-02-10 10:58:23Z thorsten $ -->
+
+<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" 
+  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0" 
+  xmlns="http://www.w3.org/1999/xhtml" 
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
+  
+  <page:title><i18n:text>New Usecase Document</i18n:text></page:title>
+  <page:body>
+    <div class="lenya-box">
+      <div class="lenya-box-title">
+        <i18n:text>New Usecase Document</i18n:text>
+      </div>
+      
+      <jx:import uri="fallback://lenya/usecases/templates/messages.jx"/>
+      
+      <div class="lenya-box-body">
+        <form id="form-create">
+          <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+          <input type="hidden" name="lenya.usecase" value="${request.getParameter('lenya.usecase')}"/>
+          <table class="lenya-table-noborder">
+            <jx:if test="${!usecase.getParameter('documentIdProvided')}">
+              <tr>
+                <td class="lenya-entry-caption">
+                  <i18n:text>Parent ID</i18n:text>:</td>
+                <td>
+                  <jx:out value="${usecase.getParameter('parentId')}"/>
+                </td>
+              </tr>
+            </jx:if>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="documentId"><i18n:text>Document ID</i18n:text>*: </label></td>
+              <td>
+                <jx:choose>
+                  <jx:when test="${usecase.getParameter('documentIdProvided')}">
+                    <jx:out value="${usecase.getParameter('documentId')}"/>
+                  </jx:when>
+                  <jx:otherwise>
+                    <input class="lenya-form-element" type="text" name="documentId" value="${usecase.getParameter('documentId')}"/>
+                    <br/> (<i18n:text>No whitespace, no special characters</i18n:text>)
+                  </jx:otherwise>
+                </jx:choose>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="title"><i18n:text>Navigation Title</i18n:text>*: </label></td>
+              <td>
+                <input class="lenya-form-element" type="text" name="title" value="${usecase.getParameter('title')}"/>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="visibleinnav"><i18n:text>Document visible in Navigation</i18n:text>*: </label></td>
+              <jx:set var="visible" value="yes"/>
+              <jx:if test="${usecase.getParameter('visibleInNav').equals('false')}">
+                <jx:set var="visible" value="no"/>
+              </jx:if> 
+              <td>
+                <select class="lenya-form-element" name="visibleInNav">
+                  <jx:choose>
+                    <jx:when test="${visible.equals('yes')}">
+                      <option value="true" selected="selected"><i18n:text>yes</i18n:text></option>
+                      <option value="false"><i18n:text>no</i18n:text></option>
+                    </jx:when>
+                    <jx:otherwise>
+                      <option value="true"><i18n:text>yes</i18n:text></option>
+                      <option value="false" selected="selected"><i18n:text>no</i18n:text></option>
+                    </jx:otherwise>
+                  </jx:choose>
+                </select>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="usecase"><i18n:text>Usecase</i18n:text>*: </label></td>
+              <td>
+                <input class="lenya-form-element" type="text" name="usecase" value="${usecase.getParameter('usecase')}"/>
+              </td>
+            </tr>
+            <jx:if test="${!usecase.getParameter('documentIdProvided')}">
+              <tr>
+                <td class="lenya-entry-caption">
+                  <label for="relation"><i18n:text>Relation</i18n:text>*: </label>
+                </td>
+                <td>
+                  <jx:forEach var="relation" items="${usecase.getParameter('relations')}">
+                    <jx:choose>
+                      <jx:when test="${relation.equals(usecase.getParameter('relation'))}">
+                        <input type="radio" name="relation" value="${relation}" checked="checked"/><i18n:text>${relation}</i18n:text>
+                      </jx:when>
+                      <jx:otherwise>
+                        <input type="radio" name="relation" value="${relation}"/><i18n:text>${relation}</i18n:text>
+                      </jx:otherwise>
+                    </jx:choose>
+                  </jx:forEach>
+                </td>
+              </tr>
+            </jx:if>
+            <jx:set var="languages" value="${usecase.getParameter('languages')}"/>
+            <jx:choose>
+              <jx:when test="${languages.size() &gt; 1}">            
+                <tr>
+                  <td class="lenya-entry-caption">
+                    <label for="language"><i18n:text>Language</i18n:text>*: </label></td>
+                  <td>
+                    <select class="lenya-form-element" name="language">
+                      <jx:forEach var="language" items="${usecase.getParameter('languages')}">
+                        <option value="${language}">${language}</option>
+                       </jx:forEach>
+                    </select>
+                  </td>
+                </tr>
+              </jx:when>
+              <jx:otherwise>
+                <tr>
+                  <td colspan="2">
+                    <jx:set var="language" value="${languages[0]}"/>
+                    <input type="hidden" name="language" value="${language}"/>
+                  </td>
+                </tr>
+              </jx:otherwise>
+            </jx:choose>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="creator"><i18n:text>Creator</i18n:text>:</label></td>
+              <td>
+                <input class="lenya-form-element" type="text" name="creator" value="${usecase.getParameter('creator')}"/>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="subject"><i18n:text>Subject</i18n:text>:</label></td>
+              <td>
+                <input class="lenya-form-element" type="text" name="subject" value="${usecase.getParameter('subject')}"/>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="publisher"><i18n:text>Publisher</i18n:text>:</label></td>
+              <td>
+                <input class="lenya-form-element" type="text" name="publisher" value="${usecase.getParameter('publisher')}"/>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption">
+                <i18n:text>Date</i18n:text>:</td>
+              <td>
+                <jx:out value="${usecase.getParameter('date')}"/>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption">
+                <label for="rights"><i18n:text>Rights</i18n:text>:</label></td>
+              <td>
+                <input class="lenya-form-element" type="text" name="rights" value="${usecase.getParameter('rights')}"/>
+              </td>
+            </tr>
+            <tr>
+              <td class="lenya-entry-caption"><label for="myMeta"><i18n:text>My
+                custom metadata</i18n:text>:</label></td>
+              <td>
+                <input type="text" id="myMeta" name="meta.custom.myMeta"
+                  class="lenya-form-element"
+                  value="${usecase.getParameter('meta.custom.myMeta')}"/>
+              </td>
+            </tr>
+            <jx:set var="resourceTypes" value="${usecase.getParameter('resourceTypes')}"/>
+            <jx:if test="${resourceTypes.size()  &gt; 0}">
+              <tr>
+                <td class="lenya-entry-caption">
+                  <label for="sample"><i18n:text>Resource Type</i18n:text>:</label></td>
+                <td>
+                  <select name="doctype">
+                    <jx:forEach var="item" items="${resourceTypes}">
+                      <jx:choose>
+                        <jx:when test="${usecase.getParameter('doctype').equals(item)}">
+                          <option value="${item}" selected="selected">${item}</option>
+                        </jx:when>
+                        <jx:otherwise>
+                          <option value="${item}">${item}</option>
+                        </jx:otherwise>
+                      </jx:choose>
+                    </jx:forEach>
+                  </select>
+                </td>
+              </tr>
+            </jx:if>
+            <jx:set var="samples" value="${usecase.getParameter('samples')}"/>
+            <jx:if test="${samples.size() &gt; 0}">
+              <tr>
+                <td class="lenya-entry-caption">
+                  <label for="sample"><i18n:text>Page Layout</i18n:text>:</label></td>
+                <td>
+                  <jx:forEach var="item" items="${samples}">
+                    <jx:choose>
+                      <jx:when test="${usecase.getParameter('sample').equals(item)}">
+                        <input type="radio" name="sample" value="${item}" checked="checked"/>${item}<br />
+                      </jx:when>
+                      <jx:otherwise>
+                        <input type="radio" name="sample" value="${item}"/>${item}<br />
+                      </jx:otherwise>
+                    </jx:choose>
+                  </jx:forEach>
+                </td>
+              </tr>
+            </jx:if>  
+            <tr>
+              <td class="lenya-entry-caption">* <i18n:text>required fields</i18n:text>
+              </td>
+            </tr>
+            <tr>
+              <td/>
+              <td>
+                <input i18n:attr="value" type="submit" name="submit" value="Create"/>
+                &#160;
+                <input i18n:attr="value" type="submit" name="cancel" value="Cancel"/>
+              </td>
+            </tr>
+          </table>
+        </form>
+      </div>
+    </div>
+  </page:body>
+</page:page>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org


Re: usecase-as-document module

Posted by Andreas Hartmann <an...@apache.org>.
Jörn Nettingsmeier wrote:
> andreas@apache.org wrote:
>> Author: andreas
>> Date: Tue Jun 13 06:46:54 2006
>> New Revision: 413894
>>
>> URL: http://svn.apache.org/viewvc?rev=413894&view=rev
>> Log:
>> Added usecase resource type module - this allows to execute usecases 
>> as documents.
> 
> that'a a neat feature. however, i tried creating a usecase page for the 
> admin.users usecase, and it displays only a blank page. i noticed this:

[...]

> iiuc, that means that only usecases which produce a html page work 
> (which only your example usecase currently does afaik).
 >
> 
> is that correct?

Absolutely :)

I didn't find a neat solution yet, so a usecase view can either support
the full-screen or the document mode.

> if so, how about making the <page:page> wrapper and friends the default 
> for all document types and changing the sitemaps accordingly?

That would be an option.
Or maybe we need something entirely new? The <page:page> was specifically
designed for form-based, full-screen pages.

> in 
> addition to making this module work for arbitrary usecases it would 
> enable modules to emit header tags in a clean way and not just a div#body.

Sounds reasonable. What do the others think?

-- Andreas

-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


usecase-as-document module

Posted by Jörn Nettingsmeier <po...@uni-duisburg.de>.
andreas@apache.org wrote:
> Author: andreas
> Date: Tue Jun 13 06:46:54 2006
> New Revision: 413894
> 
> URL: http://svn.apache.org/viewvc?rev=413894&view=rev
> Log:
> Added usecase resource type module - this allows to execute usecases as documents.

that'a a neat feature. however, i tried creating a usecase page for the 
admin.users usecase, and it displays only a blank page. i noticed this:


> --- lenya/trunk/src/modules/usecase/usecases/contactForm.jx (added)
> +++ lenya/trunk/src/modules/usecase/usecases/contactForm.jx Tue Jun 13 06:46:54 2006
...
> +<html xmlns="http://www.w3.org/1999/xhtml"
> +  xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
> +  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
> +  
> +  <body>
...
> +  </body>
> +</html>

as opposed to this:

> --- lenya/trunk/src/modules/usecase/usecases/createUsecaseDocument.jx (added)
> +++ lenya/trunk/src/modules/usecase/usecases/createUsecaseDocument.jx Tue Jun 13 06:46:54 2006
> +<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" 
> +  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0" 
> +  xmlns="http://www.w3.org/1999/xhtml" 
> +  xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
> +  
> +  <page:title><i18n:text>New Usecase Document</i18n:text></page:title>
> +  <page:body>
...
> +  </page:body>
> +</page:page>

iiuc, that means that only usecases which produce a html page work 
(which only your example usecase currently does afaik).

is that correct?

if so, how about making the <page:page> wrapper and friends the default 
for all document types and changing the sitemaps accordingly? in 
addition to making this module work for arbitrary usecases it would 
enable modules to emit header tags in a clean way and not just a div#body.
-- 
"Open source takes the bullshit out of software."
	- Charles Ferguson on TechnologyReview.com

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org