You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2003/05/13 14:06:13 UTC
cvs commit: cocoon-2.1/src/blocks/xmlform/samples/calc NumberA.xml NumberB.xml Operator.xml Result.xml controller.xconf
stephan 2003/05/13 05:06:13
Modified: src/blocks/xmlform/conf xmlform.xsamples
src/blocks/xmlform/samples sitemap.xmap
Added: src/blocks/xmlform/java/org/apache/cocoon/acting
AbstractControllerAction.java
src/blocks/xmlform/java/org/apache/cocoon/samples/xmlform
CalculatorAction.java CalculatorBean.java
src/blocks/xmlform/samples samples.xml
src/blocks/xmlform/samples/calc NumberA.xml NumberB.xml
Operator.xml Result.xml controller.xconf
Removed: src/blocks/xmlform/samples overview.html
Log:
Redesign overview site.
Add a ControllerAction, which imitate a Struts like behaviour.
Revision Changes Path
1.3 +5 -16 cocoon-2.1/src/blocks/xmlform/conf/xmlform.xsamples
Index: xmlform.xsamples
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/xmlform/conf/xmlform.xsamples,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xmlform.xsamples 7 May 2003 19:16:38 -0000 1.2
+++ xmlform.xsamples 13 May 2003 12:06:12 -0000 1.3
@@ -1,21 +1,10 @@
<?xml version="1.0"?>
-<xsamples xpath="/samples" unless="group[@name='XMLForm: Form Handling and Web Services']">
+<xsamples xpath="/samples" unless="group[@name='XMLForm']">
- <group name="XMLForm: Form Handling and Web Services">
- <sample name="Documentation" href="xmlform/overview.html">
- Introduction to Cocoon's form handling framework,
- which provides W3C XForms based markup, Schematron instance validation,
- and automated binding to JavaBeans and DOM instances.
- Also shows that XMLForm based applications are readily available as Web Services (REST style).
- </sample>
- <sample name="Example" href="xmlform/wizard">
- Presents a sophisticated form handling demo ...
- multi-page wizard with two-way navigation.
- </sample>
- <sample name="WSDL" href="xmlform/UsageFeedbackService/WSDL">
- Example WSDL descriptor for the same application,
- exposed as a Web Service.
- </sample>
+ <group name="XMLForm">
+ <sample name="XMLForm" href="xmlform/">
+ Form Handling and Web Services
+ </sample>
</group>
</xsamples>
1.1 cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/acting/AbstractControllerAction.java
Index: AbstractControllerAction.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.acting;
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.components.validation.Schema;
import org.apache.cocoon.components.validation.SchemaFactory;
import org.apache.cocoon.components.validation.Validator;
import org.apache.cocoon.components.xmlform.Form;
import org.apache.cocoon.components.xmlform.FormListener;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.excalibur.source.Source;
import org.xml.sax.InputSource;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
/**
* This action extends the idea of the AbstractXMLFormAction. It
* uses a configuration file similar to Jakarta Struts, and uses
* the concept of the MultiAction.
*
* Warning! This classes is an experimental one.
*
* @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
* @version CVS $Id: AbstractControllerAction.java,v 1.1 2003/05/13 12:06:12 stephan Exp $
*/
public abstract class AbstractControllerAction
extends AbstractComplementaryConfigurableAction implements ThreadSafe {
private static final String ACTION_METHOD_PREFIX = "do";
private static final String ACTION_METHOD_PARAMETER = "method";
private HashMap methodIndex;
private static final String removePrefix(String name) {
int prefixLen = ACTION_METHOD_PREFIX.length();
return name.substring(prefixLen, prefixLen+1).toLowerCase()+
name.substring(prefixLen+1);
}
/**
* Configure the action.
*/
public void configure(Configuration conf) throws ConfigurationException {
super.configure(conf);
try {
Method[] methods = this.getClass().getMethods();
methodIndex = new HashMap();
for (int i = 0; i<methods.length; i++) {
String methodName = methods[i].getName();
if (methodName.startsWith(ACTION_METHOD_PREFIX)) {
String actionName = removePrefix(methodName);
methodIndex.put(actionName, methods[i]);
if (getLogger().isDebugEnabled()) {
getLogger().debug("registered method \""+methodName+
"\" as action \""+actionName+"\"");
}
}
}
} catch (Exception e) {
throw new ConfigurationException("cannot get methods by reflection",
e);
}
}
/**
* Perform the action.
*/
public Map act(Redirector redirector, SourceResolver resolver,
Map objectModel, String src,
Parameters params) throws Exception {
Request request = (Request) (objectModel.get(ObjectModelHelper.REQUEST_OBJECT));
// load controller configuration
Configuration config = getConfiguration(src, resolver, true);
// current path
String path = request.getSitemapURI();
String base = request.getRequestURI().substring(0,
request.getRequestURI().length()-path.length());
// ensure that there is a form available
// through the rest of the flow
Form form = getForm(config, path, objectModel);
if (form==null) {
throw new IllegalStateException("Action could not obtain the Form");
}
// populate form with request parameters
// population is automatically followed by validation by default.
// If this is not the desired behaviour, the Form class can be subclassed
form.populate(objectModel);
// If the currect form have incorrect values, then process the same page
if (form.getViolations()!=null) {
return EMPTY_MAP;
}
// find and save the action command
String command = getCommand(request);
if ((command==null) || (command.length()==0)) {
// if no command send, process current page
return EMPTY_MAP;
}
// find the action name for the method, which should be performed.
String action = getAction(config, path);
// perform action method
String forward = command;
if ((action!=null) && (action.length()>0)) {
Method method = (Method) methodIndex.get(action);
if (method!=null) {
forward = ((String) method.invoke(this, new Object[]{ command,
form }));
if (forward==null) {
forward = command;
}
}
}
if ((command==null) || (command.length()==0)) {
// if no command send, process current page
return EMPTY_MAP;
}
// if action returns violation, process current form
if ((forward==null) && (form.getViolations()!=null)) {
return EMPTY_MAP;
}
// process forward
String newpath = getForward(config, path, forward);
if (path.equals(newpath)) {
return EMPTY_MAP;
} else {
redirector.redirect(true, base+newpath);
return null;
}
}
/**
* Returns the entry for a given page.
*/
private int getActionEntry(Configuration config, String path) {
Configuration[] actions = config.getChild("action-mappings").getChildren("action");
int entry = -1;
for (int i = 0; i<actions.length; i++)
if ((entry<0) &&
(actions[i].getAttribute("path", null).equals(path))) {
entry = i;
}
if (entry<0) {
throw new RuntimeException("Could not find entry for '"+path+"'");
}
return entry;
}
/**
* Returns name of the action for a given page.
*/
private String getAction(Configuration config, String path) {
Configuration[] actions = config.getChild("action-mappings").getChildren("action");
String action = null;
for (int i = 0; i<actions.length; i++)
if (actions[i].getAttribute("path", null).equals(path)) {
action = actions[i].getAttribute("name", null);
}
return (action!=null) ? action.toLowerCase() : null;
}
/**
* Get the command which was submitted with the form.
* It is extracted from the standard cocoon-action-* request parameter
*/
private String getCommand(Request request) {
Enumeration enum = request.getParameterNames();
while (enum.hasMoreElements()) {
String paramName = (String) enum.nextElement();
// search for the command
if (paramName.startsWith(Constants.ACTION_PARAM_PREFIX)) {
return paramName.substring(Constants.ACTION_PARAM_PREFIX.length(),
paramName.length());
}
}
return null;
}
/**
* Return the page for a given forward.
*/
private String getForward(Configuration config, String path,
String name) {
Configuration[] actions = config.getChild("action-mappings").getChildren("action");
for (int i = 0; i<actions.length; i++)
if (actions[i].getAttribute("path", null).equals(path)) {
Configuration[] forwards = actions[i].getChildren("forward");
for (int j = 0; j<forwards.length; j++)
if (forwards[j].getAttribute("name", null).equals(name)) {
return forwards[j].getAttribute("path", null);
}
}
Configuration[] forwards = config.getChild("global-forwards").getChildren("forward");
for (int i = 0; i<forwards.length; i++)
if (forwards[i].getAttribute("name", null).equals(name)) {
return forwards[i].getAttribute("path", null);
}
return null;
}
/**
* Invoked during the form population process
*
* Provides default implementation, which
* can be extended or replaced by subclasses
*
* Implementations of this method are responsible
* for creating and
* returning the Form object which the action
* is working on.
*
* @return Form the form object this action works with
*/
private Form getForm(Configuration config, String path, Map objectModel) {
Form form = Form.lookup(objectModel, getFormId(config, path));
if (form!=null) {
return form;
} else {
// create new form
form = new Form(getFormId(config, path),
getFormModel(config, path));
Validator v = null; // getFormValidator();
form.setValidator(v);
form.save(objectModel, getFormScope(config, path));
return form;
}
}
/**
* Extract xmlform-model action parameter and
* instantiate a new form model it.
*
* Subclasses may override this method
* to use custom model instantiation technique
*
* @return Form model
*/
private Object getFormModel(Configuration config, String path) {
String formId = getFormId(config, path);
Configuration[] beans = config.getChild("form-beans").getChildren("form-bean");
String modelClassName = null;
for (int i = 0; i<beans.length; i++)
if (beans[i].getAttribute("name", null).equals(formId)) {
modelClassName = beans[i].getAttribute("type", null);
}
try {
Class modelClass = Class.forName(modelClassName);
Object o = modelClass.newInstance();
return o;
} catch (Exception e) {
throw new CascadingRuntimeException(" Failed instantiating form model ",
e);
}
}
/**
* Returns the form id for a given page.
*/
private String getFormId(Configuration config, String path) {
Configuration[] actions = config.getChild("action-mappings").getChildren("action");
String formId = null;
for (int i = 0; i<actions.length; i++)
if (actions[i].getAttribute("path", null).equals(path)) {
formId = actions[i].getAttribute("form", null);
}
if (formId==null) {
throw new RuntimeException(" xmlform-id not specified ");
} else {
return formId;
}
}
/**
* Returns the scope of the form for a given page.
*/
private String getFormScope(Configuration config, String path) {
Configuration[] actions = config.getChild("action-mappings").getChildren("action");
String formScope = null;
for (int i = 0; i<actions.length; i++)
if (actions[i].getAttribute("path", null).equals(path)) {
formScope = actions[i].getAttribute("scope", null);
}
if (formScope==null) {
// default to request scope
formScope = Form.SCOPE_REQUEST;
}
return formScope;
}
}
1.1 cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/samples/xmlform/CalculatorAction.java
Index: CalculatorAction.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.samples.xmlform;
import org.apache.cocoon.acting.AbstractControllerAction;
import org.apache.cocoon.components.validation.Violation;
import org.apache.cocoon.components.xmlform.Form;
import java.util.ArrayList;
/**
* Controller action for the calculator example.
*
* @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
* @version CVS $Id: CalculatorAction.java,v 1.1 2003/05/13 12:06:12 stephan Exp $
*/
public class CalculatorAction extends AbstractControllerAction {
public String doCalculate(String command, Form form) {
CalculatorBean bean = (CalculatorBean) form.getModel();
if (command.equals("next")) {
if ((bean.getOperator().equals("divide")) &&
(bean.getNumberB()==0)) {
ArrayList list = new ArrayList();
list.add(new Violation("operator", "Can not divide by zero"));
form.addViolations(list);
return null;
} else {
if (bean.getOperator().equals("plus")) {
bean.setResult(bean.getNumberA()+bean.getNumberB());
} else if (bean.getOperator().equals("minus")) {
bean.setResult(bean.getNumberA()-bean.getNumberB());
} else if (bean.getOperator().equals("multiply")) {
bean.setResult(bean.getNumberA()*bean.getNumberB());
} else if (bean.getOperator().equals("divide")) {
bean.setResult(bean.getNumberA()/bean.getNumberB());
}
}
return "next";
}
// execute default transition
return null;
}
public String doReset(String command, Form form) {
if (command.equals("next")) {
form.setModel(new CalculatorBean());
}
return command;
}
}
1.1 cocoon-2.1/src/blocks/xmlform/java/org/apache/cocoon/samples/xmlform/CalculatorBean.java
Index: CalculatorBean.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.samples.xmlform;
/**
* Bean to carry the information for the calculator example.
*
* @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
* @version CVS $Id: CalculatorBean.java,v 1.1 2003/05/13 12:06:12 stephan Exp $
*/
public class CalculatorBean {
private int numberA = 0;
private int numberB = 0;
private String operator = "plus";
private int result = 0;
public int getNumberA() {
return numberA;
}
public void setNumberA(int numberA) {
this.numberA = numberA;
}
public int getNumberB() {
return numberB;
}
public void setNumberB(int numberB) {
this.numberB = numberB;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public int getResult() {
return result;
}
public void setResult(int result) {
this.result = result;
}
}
1.3 +41 -3 cocoon-2.1/src/blocks/xmlform/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/xmlform/samples/sitemap.xmap,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sitemap.xmap 8 May 2003 09:44:54 -0000 1.2
+++ sitemap.xmap 13 May 2003 12:06:12 -0000 1.3
@@ -13,6 +13,8 @@
src="org.apache.cocoon.samples.xmlform.WizardAction"/>
<map:action name="UsageFeedbackAction" logger="xmlform.sitemap.action.UsageFeedback"
src="org.apache.cocoon.samples.xmlform.UsageFeedbackAction"/>
+ <map:action name="CalculatorAction" logger="xmlform.sitemap.action.Calculator"
+ src="org.apache.cocoon.samples.xmlform.CalculatorAction"/>
</map:actions>
<map:flow-interpreters default="JavaScript"/>
@@ -57,11 +59,15 @@
<map:pipeline>
<map:match pattern="">
- <map:redirect-to uri="overview.html"/>
+ <map:redirect-to uri="welcome"/>
</map:match>
- <map:match pattern="overview.html">
- <map:read src="overview.html"/>
+ <map:match pattern="welcome">
+ <map:generate src="samples.xml"/>
+ <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
+ <map:parameter name="contextPath" value="{request:contextPath}"/>
+ </map:transform>
+ <map:serialize/>
</map:match>
</map:pipeline>
@@ -168,6 +174,38 @@
<!-- sending the HTML back to the browser -->
<map:serialize type="html" label="debug"/>
</map:match>
+ </map:pipeline>
+
+
+ <map:pipeline>
+
+ <map:match pattern="calc">
+ <map:redirect-to uri="calc/NumberA"/>
+ </map:match>
+
+ <!-- A example for the AbstractControllerAction, which imitates Struts like behaviour -->
+ <map:match pattern="calc/*">
+ <map:act type="CalculatorAction" src="calc/controller.xconf">
+
+ <!-- original XMLForm document -->
+ <map:generate src="calc/{../1}.xml"/>
+
+ <!-- populating the document with model instance data -->
+ <map:transform type="xmlform" label="xml"/>
+
+ <!-- personalizing the look and feel of the form controls -->
+ <map:transform src="context://samples/common/style/xsl/html/complex-page2html.xsl">
+ <map:parameter name="contextPath" value="{request:contextPath}"/>
+ </map:transform>
+
+ <!-- Transforming the XMLForm controls to HTML controls -->
+ <map:transform src="context://stylesheets/system/xmlform2html.xslt" />
+
+ <!-- sending the HTML back to the browser -->
+ <map:serialize type="html" label="debug"/>
+
+ </map:act>
+ </map:match>
</map:pipeline>
</map:pipelines>
1.1 cocoon-2.1/src/blocks/xmlform/samples/samples.xml
Index: samples.xml
===================================================================
<samples xmlns:xlink="http://www.w3.org/1999/xlink">
<group name="Main examples page.">
<sample name="Back" href="..">to Cocoon examples main page</sample>
</group>
<group name="Documentation">
<sample name="How to" href="../../docs/howto/xmlform-wizard/howto-xmlform-wizard.html">
Cocoon XMLForm How-To
</sample>
<sample name="W3C XForms" href="http://www.w3.org/MarkUp/Forms/">
The Cocoon XMLForm handling framework use the W3C XForms based markup.
</sample>
<sample name="Schematron" href="http://www.ascc.net/xml/resource/schematron/schematron.html">
It uses also Schematron for instance validation.
</sample>
<sample name="REST" href="http://www.xfront.com/REST.html">
The framework allows an easy deployment of REST services.
</sample>
<sample name="Web Services" href="http://www.w3.org/2002/ws/">
And also allows an easy deployment of web services.
</sample>
</group>
<group name="Application">
<sample name="Action" href="wizard">
Presents a sophisticated form handling demo ... multi-page wizard with two-way navigation,
based on a Cocoon Action.
</sample>
<sample name="Flow" href="flow">
Flow-based XMLForm Cocoon Usage Feedback Wizard Demonstration
</sample>
<sample name="Controller" href="calc">
A more configurable action, which borrows some ideas from Jakarta Struts.
</sample>
</group>
<group name="Web service">
<sample name="WSDL descriptor" href="UsageFeedbackService/WSDL">Example WSDL descriptor
for the same application, exposed as a Web Service (REST style).
</sample>
<sample name="Valid sample request" href="UsageFeedbackService?firstName=good&publish=false">
An example for a valid request.
</sample>
<sample name="Valid sample request" href="UsageFeedbackService?firstName=bad&publish=false">
An example for a invalid request.
</sample>
</group>
</samples>
1.1 cocoon-2.1/src/blocks/xmlform/samples/calc/NumberA.xml
Index: NumberA.xml
===================================================================
<?xml version="1.0"?>
<document>
<header>
<title>XMLForm: Calculator</title>
<tab title="Back" href=".."/>
</header>
<body>
<section>
<title>Number A</title>
<xf:form id="calc" xmlns:xf="http://xml.apache.org/cocoon/xmlform/2002">
<p>
Enter value of <strong>a</strong><br/>
<xf:textbox ref="numberA"/>
</p>
<p>
<xf:submit id="next" class="button">
<xf:caption>Next</xf:caption>
</xf:submit>
</p>
</xf:form>
</section>
</body>
</document>
1.1 cocoon-2.1/src/blocks/xmlform/samples/calc/NumberB.xml
Index: NumberB.xml
===================================================================
<?xml version="1.0"?>
<document>
<header>
<title>XMLForm: Calculator</title>
<tab title="Back" href=".."/>
</header>
<body>
<section>
<title>Number B</title>
<xf:form id="calc" xmlns:xf="http://xml.apache.org/cocoon/xmlform/2002">
<p>
a = <xf:output ref="numberA"/>
</p>
<p>
Enter value of <strong>b</strong><br/>
<xf:textbox ref="numberB"/>
</p>
<p>
<xf:submit id="prev" class="button">
<xf:caption>Prev</xf:caption>
</xf:submit>
<xf:submit id="next" class="button">
<xf:caption>Next</xf:caption>
</xf:submit>
</p>
</xf:form>
</section>
</body>
</document>
1.1 cocoon-2.1/src/blocks/xmlform/samples/calc/Operator.xml
Index: Operator.xml
===================================================================
<?xml version="1.0"?>
<document>
<header>
<title>XMLForm: Calculator</title>
<tab title="Back" href=".."/>
</header>
<body>
<section>
<title>Operator</title>
<xf:form id="calc" xmlns:xf="http://xml.apache.org/cocoon/xmlform/2002">
<p>
a = <xf:output ref="numberA"/>
</p>
<p>
b = <xf:output ref="numberB"/>
</p>
<p>
Enter operator<br/>
<xf:selectOne ref="operator" selectUIType="radio">
<xf:item id="plus">
<xf:caption>Plus</xf:caption>
<xf:value>plus</xf:value>
</xf:item>
<xf:item id="minus">
<xf:caption>Minus</xf:caption>
<xf:value>minus</xf:value>
</xf:item>
<xf:item id="multiply">
<xf:caption>Multiply</xf:caption>
<xf:value>multiply</xf:value>
</xf:item>
<xf:item id="divide">
<xf:caption>Divide</xf:caption>
<xf:value>divide</xf:value>
</xf:item>
</xf:selectOne>
</p>
<p>
<xf:submit id="prev" class="button">
<xf:caption>Prev</xf:caption>
</xf:submit>
<xf:submit id="next" class="button">
<xf:caption>Next</xf:caption>
</xf:submit>
</p>
</xf:form>
</section>
</body>
</document>
1.1 cocoon-2.1/src/blocks/xmlform/samples/calc/Result.xml
Index: Result.xml
===================================================================
<?xml version="1.0"?>
<document>
<header>
<title>XMLForm: Calculator</title>
<tab title="Back" href=".."/>
</header>
<body>
<section>
<title>Result</title>
<xf:form id="calc" xmlns:xf="http://xml.apache.org/cocoon/xmlform/2002">
<p>
a = <xf:output ref="numberA"/>
</p>
<p>
b = <xf:output ref="numberB"/>
</p>
<p>
operator = <xf:output ref="operator"/>
</p>
<p>
result = <xf:output ref="result"/>
</p>
<p>
<xf:submit id="prev" class="button">
<xf:caption>Prev</xf:caption>
</xf:submit>
<xf:submit id="next" class="button">
<xf:caption>Next</xf:caption>
</xf:submit>
</p>
</xf:form>
</section>
</body>
</document>
1.1 cocoon-2.1/src/blocks/xmlform/samples/calc/controller.xconf
Index: controller.xconf
===================================================================
<?xml version="1.0"?>
<controller>
<!-- ========== Form Bean Definitions =================================== -->
<form-beans>
<!-- Registration form bean -->
<form-bean name="calc"
type="org.apache.cocoon.samples.xmlform.CalculatorBean"/>
</form-beans>
<!-- ========== Global Forward Definitions ============================== -->
<global-forwards>
<forward name="start" path="calc/NumberA"/>
</global-forwards>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<action path="calc/NumberA" form="calc" scope="session">
<forward name="next" path="/calc/NumberB"/>
</action>
<action path="calc/NumberB" form="calc" scope="session">
<forward name="prev" path="calc/NumberA"/>
<forward name="next" path="calc/Operator"/>
</action>
<action path="calc/Operator" name="calculate" form="calc" scope="session">
<forward name="prev" path="calc/NumberB"/>
<forward name="next" path="calc/Result"/>
</action>
<action path="calc/Result" name="reset" form="calc" scope="session">
<forward name="prev" path="calc/Operator"/>
<forward name="next" path="calc/NumberA"/>
</action>
</action-mappings>
</controller>