joerg 2004/05/11 15:25:32
Modified: src/blocks/woody/samples/forms form1_success.xsp
countryselector_success.xsp carselector_success.xsp
htmlarea_success.jx form_model_gui_success.xsp
src/blocks/woody/samples/flow registration.js bindings.js
binding_example.js customvalidationdemo.js
form_model_gui.js upload_example.js htmlarea.js
woody_flow_example.js
src/blocks/woody/samples/aggregate example.js
Log:
*** keyword substitution change ***
Revision Changes Path
1.6 +45 -45
cocoon-2.1/src/blocks/woody/samples/forms/form1_success.xsp
Index: form1_success.xsp
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form1_success.xsp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- form1_success.xsp 9 Mar 2004 13:53:51 -0000 1.5
+++ form1_success.xsp 11 May 2004 22:25:31 -0000 1.6
@@ -1,45 +1,45 @@
-<?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.
--->
-<xsp:page language="java"
- xmlns:xsp="http://apache.org/xsp">
-
- <xsp:structure>
- <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
- </xsp:structure>
-
- <page>
- <title>Sample form result</title>
- <content>
- <xsp:logic>
- // get reference to form and some of the widgets on it
- Form form = (Form)request.getAttribute("form1");
- Field field = (Field)form.getWidget("email");
- BooleanField booleanField = (BooleanField)form.getWidget("somebool");
- Field field2 =
(Field)((Repeater)form.getWidget("contacts")).getWidget(1, "firstname");
- </xsp:logic>
-
- email has the following value:
- <xsp:expr>field.getValue()</xsp:expr>
- <br/>
- Second person has this firstname:
- <xsp:expr>field2.getValue()</xsp:expr>
- <br/>
- The value of the checkbox is:
- <xsp:expr>booleanField.getValue()</xsp:expr>
- </content>
- </page>
-</xsp:page>
+<?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.
+-->
+<xsp:page language="java"
+ xmlns:xsp="http://apache.org/xsp">
+
+ <xsp:structure>
+ <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
+ </xsp:structure>
+
+ <page>
+ <title>Sample form result</title>
+ <content>
+ <xsp:logic>
+ // get reference to form and some of the widgets on it
+ Form form = (Form)request.getAttribute("form1");
+ Field field = (Field)form.getWidget("email");
+ BooleanField booleanField = (BooleanField)form.getWidget("somebool");
+ Field field2 =
(Field)((Repeater)form.getWidget("contacts")).getWidget(1, "firstname");
+ </xsp:logic>
+
+ email has the following value:
+ <xsp:expr>field.getValue()</xsp:expr>
+ <br/>
+ Second person has this firstname:
+ <xsp:expr>field2.getValue()</xsp:expr>
+ <br/>
+ The value of the checkbox is:
+ <xsp:expr>booleanField.getValue()</xsp:expr>
+ </content>
+ </page>
+</xsp:page>
1.5 +38 -38
cocoon-2.1/src/blocks/woody/samples/forms/countryselector_success.xsp
Index: countryselector_success.xsp
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/countryselector_success.xsp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- countryselector_success.xsp 9 Mar 2004 13:53:50 -0000 1.4
+++ countryselector_success.xsp 11 May 2004 22:25:31 -0000 1.5
@@ -1,38 +1,38 @@
-<?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.
--->
-<xsp:page language="java"
- xmlns:xsp="http://apache.org/xsp">
-
- <xsp:structure>
- <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
- </xsp:structure>
-
- <page>
- <title>Country selector result</title>
- <content>
- <xsp:logic>
- // get reference to form and some of the widgets on it
- Form form = (Form)request.getAttribute("countryselectorform");
- Field usnonus = (Field)form.getWidget("us-nonus");
- Field country = (Field)form.getWidget("country");
- </xsp:logic>
-
- You selected: <xsp:expr>usnonus.getValue()</xsp:expr>,
- country/state <xsp:expr>country.getValue()</xsp:expr>
- </content>
- </page>
-</xsp:page>
+<?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.
+-->
+<xsp:page language="java"
+ xmlns:xsp="http://apache.org/xsp">
+
+ <xsp:structure>
+ <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
+ </xsp:structure>
+
+ <page>
+ <title>Country selector result</title>
+ <content>
+ <xsp:logic>
+ // get reference to form and some of the widgets on it
+ Form form = (Form)request.getAttribute("countryselectorform");
+ Field usnonus = (Field)form.getWidget("us-nonus");
+ Field country = (Field)form.getWidget("country");
+ </xsp:logic>
+
+ You selected: <xsp:expr>usnonus.getValue()</xsp:expr>,
+ country/state <xsp:expr>country.getValue()</xsp:expr>
+ </content>
+ </page>
+</xsp:page>
1.6 +40 -40
cocoon-2.1/src/blocks/woody/samples/forms/carselector_success.xsp
Index: carselector_success.xsp
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/carselector_success.xsp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- carselector_success.xsp 9 Mar 2004 13:53:51 -0000 1.5
+++ carselector_success.xsp 11 May 2004 22:25:31 -0000 1.6
@@ -1,40 +1,40 @@
-<?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.
--->
-<xsp:page language="java"
- xmlns:xsp="http://apache.org/xsp">
-
- <xsp:structure>
- <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
- </xsp:structure>
-
- <page>
- <title>Car selector result</title>
- <content>
- <xsp:logic>
- // get reference to form and some of the widgets on it
- Form form = (Form)request.getAttribute("carselectorform");
- Field make = (Field)form.getWidget("make");
- Field type = (Field)form.getWidget("type");
- Field model = (Field)form.getWidget("model");
- </xsp:logic>
-
- You selected: maker <xsp:expr>make.getValue()</xsp:expr>,
- type <xsp:expr>type.getValue()</xsp:expr>,
- model <xsp:expr>model.getValue()</xsp:expr>
- </content>
- </page>
-</xsp:page>
+<?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.
+-->
+<xsp:page language="java"
+ xmlns:xsp="http://apache.org/xsp">
+
+ <xsp:structure>
+ <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
+ </xsp:structure>
+
+ <page>
+ <title>Car selector result</title>
+ <content>
+ <xsp:logic>
+ // get reference to form and some of the widgets on it
+ Form form = (Form)request.getAttribute("carselectorform");
+ Field make = (Field)form.getWidget("make");
+ Field type = (Field)form.getWidget("type");
+ Field model = (Field)form.getWidget("model");
+ </xsp:logic>
+
+ You selected: maker <xsp:expr>make.getValue()</xsp:expr>,
+ type <xsp:expr>type.getValue()</xsp:expr>,
+ model <xsp:expr>model.getValue()</xsp:expr>
+ </content>
+ </page>
+</xsp:page>
1.7 +24 -24
cocoon-2.1/src/blocks/woody/samples/forms/htmlarea_success.jx
Index: htmlarea_success.jx
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/htmlarea_success.jx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- htmlarea_success.jx 5 Apr 2004 12:25:33 -0000 1.6
+++ htmlarea_success.jx 11 May 2004 22:25:31 -0000 1.7
@@ -1,24 +1,24 @@
-<?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.
--->
-<page>
- <title>Editing successful</title>
- <content>
- Editing was successful:<br/>
- <br/>
- ${data}
- </content>
-</page>
+<?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.
+-->
+<page>
+ <title>Editing successful</title>
+ <content>
+ Editing was successful:<br/>
+ <br/>
+ ${data}
+ </content>
+</page>
1.5 +41 -41
cocoon-2.1/src/blocks/woody/samples/forms/form_model_gui_success.xsp
Index: form_model_gui_success.xsp
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form_model_gui_success.xsp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- form_model_gui_success.xsp 9 Mar 2004 13:53:51 -0000 1.4
+++ form_model_gui_success.xsp 11 May 2004 22:25:31 -0000 1.5
@@ -1,41 +1,41 @@
-<?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.
--->
-<xsp:page language="java"
- xmlns:xsp="http://apache.org/xsp">
-
- <!--
- CVS $Id$
- Author: Timothy Larson
- -->
-
- <xsp:structure>
- <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
- </xsp:structure>
-
- <page>
- <title>Sample form result</title>
- <content>
- <xsp:logic>
- // get reference to form and some of the widgets on it
- Form form = (Form)request.getAttribute("form_model_gui");
- Repeater repeater = (Repeater)form.getWidget("widgets");
- </xsp:logic>
-
- Repeater has <xsp:expr>repeater.getSize()</xsp:expr> row(s).
- </content>
- </page>
-</xsp:page>
+<?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.
+-->
+<xsp:page language="java"
+ xmlns:xsp="http://apache.org/xsp">
+
+ <!--
+ CVS $Id$
+ Author: Timothy Larson
+ -->
+
+ <xsp:structure>
+ <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
+ </xsp:structure>
+
+ <page>
+ <title>Sample form result</title>
+ <content>
+ <xsp:logic>
+ // get reference to form and some of the widgets on it
+ Form form = (Form)request.getAttribute("form_model_gui");
+ Repeater repeater = (Repeater)form.getWidget("widgets");
+ </xsp:logic>
+
+ Repeater has <xsp:expr>repeater.getSize()</xsp:expr> row(s).
+ </content>
+ </page>
+</xsp:page>
1.7 +28 -28 cocoon-2.1/src/blocks/woody/samples/flow/registration.js
Index: registration.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/registration.js,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- registration.js 9 Mar 2004 13:54:01 -0000 1.6
+++ registration.js 11 May 2004 22:25:31 -0000 1.7
@@ -1,28 +1,28 @@
-/*
-* 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.
-*/
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-function registration() {
- var form = new Form("forms/registration.xml");
-
- // The showForm function will keep redisplaying the form until
- // everything is valid
- form.showForm("registration-display-pipeline");
-
- var model = form.getModel();
- var bizdata = { "username" : model.name }
- cocoon.sendPage("registration-success-pipeline.jx", bizdata);
-}
+/*
+* 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.
+*/
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+function registration() {
+ var form = new Form("forms/registration.xml");
+
+ // The showForm function will keep redisplaying the form until
+ // everything is valid
+ form.showForm("registration-display-pipeline");
+
+ var model = form.getModel();
+ var bizdata = { "username" : model.name }
+ cocoon.sendPage("registration-success-pipeline.jx", bizdata);
+}
1.7 +200 -200 cocoon-2.1/src/blocks/woody/samples/flow/bindings.js
Index: bindings.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/bindings.js,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- bindings.js 9 Mar 2004 13:54:00 -0000 1.6
+++ bindings.js 11 May 2004 22:25:31 -0000 1.7
@@ -1,201 +1,201 @@
-/*
- * 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.
- */
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-/**
- * Disclaimer:
- * To make this flowscript quite generic we've applied some typical
javascript
- * hacks here and there. Don't let them overwhelm you, the purpose of this
tutorial
- * is _not_ to get into the depths of woody and flowscript. Instead you
should
- * focus on the effects of the applied definitions in the binding files:
- * see ../forms/bindings/*-bind.xml. And how to shape your backend-models:
- * - for JS see here: createJSBeanfor*() functions
- * - for Java see the org.apache.cocoon.woody.samples.bindings.* classes
- * - for XML see ../forms/bindings/*-data.xml.
- *
- * In the same area of genericity we are not using the
WoodyTemplateTransformer
- * since that would require to provide an extra template file to every
sample.
- *
- * To add more binding-tutorial-samples follow these steps:
- * - decide on a sample-code (e.g. '01value')
- * - provide a woody formDefinition ../forms/bindings/{sampleCode}-def.xml
- * - provide a woody formBinding ../forms/bindings/{sampleCode}-bind.xml
- * - provide the 3 types of backend-models:
- * - for JS (javascript) you add here a function
createJSBeanFor{sampleCode}()
- * and let it return the js object to bind to
- * - for Java you create an actual Java class that gets instantiated and
returned
- * by a function createJavaBeanFor{sampleCode}() over here
- * - for XML you create a simple XML file over at
- * ../forms/bindings/{sampleCode}-data.xml
- * - finally you add a link into the ../welcome.xml page to link to your
new sample
- */
-
-
-
-
-/**
- * Generic entry-function for all binding samples. This uses the
- * 'sample-code' and the 'backend-type' to effectively select the form
- * and specific backend-model to use.
- */
-function bindingSample(sampleCode, backendType) {
- // sample-code holds the number-and-name of this binding sample in the
tutorial
- if (cocoon.parameters["sample-code"] != undefined) {
- sampleCode = cocoon.parameters["sample-code"];
- }
-
- // backend-type holds one of 'JS', 'Java' or 'XML' to indicate
- // the type of backend to use.
- if (cocoon.parameters["backend-type"] != undefined) {
- backendType = cocoon.parameters["backend-type"];
- }
-
- // all back-end models are bound to essentially the same form, using
the same binding!
- var form = createFormForSample(sampleCode);
-
- // the beack-end model itself however depends on sample and type.
- var bean = createBeanForSample(backendType, sampleCode);
-
- // loads the backend-bean into the form
- form.load(bean);
-
- // wait for user to submit the form correctly
- form.showForm("binding.form");
-
- // saves the form into the backend-bean
- form.save(bean);
- var bizData = new Object();
- bizData["bean"] = bean;
- bizData["backendType"] = backendType;
- bizData["sampleCode"] = sampleCode;
-
- cocoon.sendPage("binding.done", bizData);
-}
-
-/**
- * Creates the form for this sample. And automatically creates the
accompanied
- * binding.
- */
-function createFormForSample(sampleCode) {
- var form = new Form("forms/binding/" + sampleCode + "-def.xml");
- form.createBinding("forms/binding/" + sampleCode +"-bind.xml");
- return form;
-}
-
-/**
- * Creates the Bean of the desired type for this sample.
- */
-function createBeanForSample(backendType, sampleCode) {
- if (backendType.equals("XML")) {
- return createXMLBean(sampleCode);
- } else {
- var factoryFunction = "create" + backendType + "BeanFor" + sampleCode;
- print("Using the bean returned by function " + factoryFunction +
"()");
- return this[factoryFunction].apply();
- }
-}
-
-/**
- * Finds the sample specific XML file to bind to and parses it into a DOM
Document.
- */
-function createXMLBean(sampleCode) {
- // note if you want to toss around with the XML model (e.g. sample
02lenient)
- // then you should do that by editing the files:
../forms/binding/*-data.xml
-
- var uri = "forms/binding/" + sampleCode +"-data.xml";
- print("Using the XML data file at " + uri);
-
- var parser = null;
- var source = null;
- var resolver = null;
- try {
- parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
- resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
- source = resolver.resolveURI(uri);
- var is = new
Packages.org.xml.sax.InputSource(source.getInputStream());
- is.setSystemId(source.getURI());
- //Note: we immediately narrow down to the root-element here to avoid
- // needing to wrap js and Java beans in a silly 'root'
- return parser.parseDocument(is).getDocumentElement();
- } finally {
- if (source != null)
- resolver.release(source);
- cocoon.releaseComponent(parser);
- cocoon.releaseComponent(resolver);
- }
-}
-
-/**
- * Creates the JS Bean for sample '01value'
- */
-function createJSBeanFor01value() {
- var bean;
- bean = new Object();
- bean.simple = "Simple";
- bean.readOnly = "Read-Only";
- bean.writeOnly = "Write-Only";
- bean.diffIn = "Diff-in/out";
- // diffOut doesn't need to exist, binding will create it.
- bean.onUpdate = "On Update";
- bean.updateCount = 0;
- bean.bool = true;
- bean.date = "19700605";
- bean.other = "This field is not involved in the form.";
- return bean;
-}
-
-/**
- * Creates the Java Bean for sample '01value'
- */
-function createJavaBeanFor01value() {
- return new
Packages.org.apache.cocoon.woody.samples.bindings.ValuesBean();
-}
-
-/**
- * Creates the JS Bean for sample '02lenient'
- */
-function createJSBeanFor02lenient() {
- var bean = new Object();
- var contexts = ["one","two","three"];
- for(var i=0; i<contexts.length; i++) {
- bean[contexts[i]] = new Object();
- // using javascript beans seem to survive even non lenient binding
- // so you can do here what you want, the bean itself seems to be
leninet?
- //bean[contexts[i]]["breakingField"] = "present";
- }
- return bean;
-}
-
-/**
- * Creates the Java Bean for sample '02lenient'
- */
-function createJavaBeanFor02lenient() {
- var bean = new Packages.java.util.HashMap();
- // to see the runtime effect of non-lenient binding
- // remove/replace the 'one' in the following list:
- var contexts = ["one","two","three"]; // only the 'one' context is
required by non-lenient binding
- for(var i=0; i<contexts.length; i++) {
- // to see the runtime effect of non-lenient binding
- // swap the following 2 lines from comment to code
- var subBean = new
Packages.org.apache.cocoon.woody.samples.bindings.LenientOKBean("init");
-// var subBean = new
Packages.org.apache.cocoon.woody.samples.bindings.LenientNotOKBean("init");
-
- // the NotOkBean does not have a getBreakingField() required by the
non-lenient binding
-
- bean.put(contexts[i], subBean);
- }
- return bean;
+/*
+ * 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.
+ */
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+/**
+ * Disclaimer:
+ * To make this flowscript quite generic we've applied some typical
javascript
+ * hacks here and there. Don't let them overwhelm you, the purpose of this
tutorial
+ * is _not_ to get into the depths of woody and flowscript. Instead you
should
+ * focus on the effects of the applied definitions in the binding files:
+ * see ../forms/bindings/*-bind.xml. And how to shape your backend-models:
+ * - for JS see here: createJSBeanfor*() functions
+ * - for Java see the org.apache.cocoon.woody.samples.bindings.* classes
+ * - for XML see ../forms/bindings/*-data.xml.
+ *
+ * In the same area of genericity we are not using the
WoodyTemplateTransformer
+ * since that would require to provide an extra template file to every
sample.
+ *
+ * To add more binding-tutorial-samples follow these steps:
+ * - decide on a sample-code (e.g. '01value')
+ * - provide a woody formDefinition ../forms/bindings/{sampleCode}-def.xml
+ * - provide a woody formBinding ../forms/bindings/{sampleCode}-bind.xml
+ * - provide the 3 types of backend-models:
+ * - for JS (javascript) you add here a function
createJSBeanFor{sampleCode}()
+ * and let it return the js object to bind to
+ * - for Java you create an actual Java class that gets instantiated and
returned
+ * by a function createJavaBeanFor{sampleCode}() over here
+ * - for XML you create a simple XML file over at
+ * ../forms/bindings/{sampleCode}-data.xml
+ * - finally you add a link into the ../welcome.xml page to link to your
new sample
+ */
+
+
+
+
+/**
+ * Generic entry-function for all binding samples. This uses the
+ * 'sample-code' and the 'backend-type' to effectively select the form
+ * and specific backend-model to use.
+ */
+function bindingSample(sampleCode, backendType) {
+ // sample-code holds the number-and-name of this binding sample in the
tutorial
+ if (cocoon.parameters["sample-code"] != undefined) {
+ sampleCode = cocoon.parameters["sample-code"];
+ }
+
+ // backend-type holds one of 'JS', 'Java' or 'XML' to indicate
+ // the type of backend to use.
+ if (cocoon.parameters["backend-type"] != undefined) {
+ backendType = cocoon.parameters["backend-type"];
+ }
+
+ // all back-end models are bound to essentially the same form, using
the same binding!
+ var form = createFormForSample(sampleCode);
+
+ // the beack-end model itself however depends on sample and type.
+ var bean = createBeanForSample(backendType, sampleCode);
+
+ // loads the backend-bean into the form
+ form.load(bean);
+
+ // wait for user to submit the form correctly
+ form.showForm("binding.form");
+
+ // saves the form into the backend-bean
+ form.save(bean);
+ var bizData = new Object();
+ bizData["bean"] = bean;
+ bizData["backendType"] = backendType;
+ bizData["sampleCode"] = sampleCode;
+
+ cocoon.sendPage("binding.done", bizData);
+}
+
+/**
+ * Creates the form for this sample. And automatically creates the
accompanied
+ * binding.
+ */
+function createFormForSample(sampleCode) {
+ var form = new Form("forms/binding/" + sampleCode + "-def.xml");
+ form.createBinding("forms/binding/" + sampleCode +"-bind.xml");
+ return form;
+}
+
+/**
+ * Creates the Bean of the desired type for this sample.
+ */
+function createBeanForSample(backendType, sampleCode) {
+ if (backendType.equals("XML")) {
+ return createXMLBean(sampleCode);
+ } else {
+ var factoryFunction = "create" + backendType + "BeanFor" + sampleCode;
+ print("Using the bean returned by function " + factoryFunction +
"()");
+ return this[factoryFunction].apply();
+ }
+}
+
+/**
+ * Finds the sample specific XML file to bind to and parses it into a DOM
Document.
+ */
+function createXMLBean(sampleCode) {
+ // note if you want to toss around with the XML model (e.g. sample
02lenient)
+ // then you should do that by editing the files:
../forms/binding/*-data.xml
+
+ var uri = "forms/binding/" + sampleCode +"-data.xml";
+ print("Using the XML data file at " + uri);
+
+ var parser = null;
+ var source = null;
+ var resolver = null;
+ try {
+ parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+ resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+ source = resolver.resolveURI(uri);
+ var is = new
Packages.org.xml.sax.InputSource(source.getInputStream());
+ is.setSystemId(source.getURI());
+ //Note: we immediately narrow down to the root-element here to avoid
+ // needing to wrap js and Java beans in a silly 'root'
+ return parser.parseDocument(is).getDocumentElement();
+ } finally {
+ if (source != null)
+ resolver.release(source);
+ cocoon.releaseComponent(parser);
+ cocoon.releaseComponent(resolver);
+ }
+}
+
+/**
+ * Creates the JS Bean for sample '01value'
+ */
+function createJSBeanFor01value() {
+ var bean;
+ bean = new Object();
+ bean.simple = "Simple";
+ bean.readOnly = "Read-Only";
+ bean.writeOnly = "Write-Only";
+ bean.diffIn = "Diff-in/out";
+ // diffOut doesn't need to exist, binding will create it.
+ bean.onUpdate = "On Update";
+ bean.updateCount = 0;
+ bean.bool = true;
+ bean.date = "19700605";
+ bean.other = "This field is not involved in the form.";
+ return bean;
+}
+
+/**
+ * Creates the Java Bean for sample '01value'
+ */
+function createJavaBeanFor01value() {
+ return new
Packages.org.apache.cocoon.woody.samples.bindings.ValuesBean();
+}
+
+/**
+ * Creates the JS Bean for sample '02lenient'
+ */
+function createJSBeanFor02lenient() {
+ var bean = new Object();
+ var contexts = ["one","two","three"];
+ for(var i=0; i<contexts.length; i++) {
+ bean[contexts[i]] = new Object();
+ // using javascript beans seem to survive even non lenient binding
+ // so you can do here what you want, the bean itself seems to be
leninet?
+ //bean[contexts[i]]["breakingField"] = "present";
+ }
+ return bean;
+}
+
+/**
+ * Creates the Java Bean for sample '02lenient'
+ */
+function createJavaBeanFor02lenient() {
+ var bean = new Packages.java.util.HashMap();
+ // to see the runtime effect of non-lenient binding
+ // remove/replace the 'one' in the following list:
+ var contexts = ["one","two","three"]; // only the 'one' context is
required by non-lenient binding
+ for(var i=0; i<contexts.length; i++) {
+ // to see the runtime effect of non-lenient binding
+ // swap the following 2 lines from comment to code
+ var subBean = new
Packages.org.apache.cocoon.woody.samples.bindings.LenientOKBean("init");
+// var subBean = new
Packages.org.apache.cocoon.woody.samples.bindings.LenientNotOKBean("init");
+
+ // the NotOkBean does not have a getBreakingField() required by the
non-lenient binding
+
+ bean.put(contexts[i], subBean);
+ }
+ return bean;
}
1.19 +143 -143
cocoon-2.1/src/blocks/woody/samples/flow/binding_example.js
Index: binding_example.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/binding_example.js,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- binding_example.js 9 Mar 2004 13:54:01 -0000 1.18
+++ binding_example.js 11 May 2004 22:25:31 -0000 1.19
@@ -1,143 +1,143 @@
-/*
- * 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.
- */
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-// The purpose of the form2 example is to edit the contents of an XML file
-// or a Java bean through a Woody form
-
-// the form2 function is not directly called by the sitemap but by
-// a generic "woody" function that instantiates the form based on
-// parameters passed from the sitemap (see above loaded woody2.js file)
-function form2xml(form) {
- // get the documentURI parameter from the sitemap which contains the
- // location of the file to be edited
- var documentURI = cocoon.parameters["documentURI"];
-
- // parse the document to a DOM-tree
- var document = loadDocument(documentURI);
-
- // bind the document data to the form
- form.load(document);
-
- // show the form to the user until it is validated successfully
- form.showForm("form2-display-pipeline");
-
- // bind the form's data back to the document
- form.save(document);
-
- // save the DOM-tree back to an XML file, the makeTargetURI
- // function makes a modified filename so that the
- // original document is not overwritten
- saveDocument(document, makeTargetURI(documentURI));
-
- cocoon.sendPage("form2-success-pipeline");
-}
-
-// bean variant of the binding sample
-function form2bean(form) {
- var bean = new Packages.org.apache.cocoon.woody.samples.Form2Bean();
-
- // fill bean with some data to avoid users having to type to much
- bean.setEmail("[EMAIL PROTECTED]");
- bean.setIpAddress("10.0.0.1");
- bean.setPhoneCountry("32");
- bean.setPhoneZone("2");
- bean.setPhoneNumber("123456");
- bean.setBirthday(new java.util.Date());
- bean.setSex(Packages.org.apache.cocoon.woody.samples.Sex.FEMALE);
- var contact = new Packages.org.apache.cocoon.woody.samples.Contact();
- contact.setId("1");
- contact.setFirstName("Herman");
- bean.addContact(contact);
-
- form.load(bean);
- form.showForm("form2-display-pipeline");
- form.save(bean);
-
- cocoon.sendPage("form2bean-success-pipeline", { "form2bean": bean });
-}
-
-/**
- * Translate source path into target path so we keep a clean source XML.
- */
-function makeTargetURI(path) {
- var sfx = ".xml";
- var newSfx = "-result.xml";
- var newPath = path;
- if (path.match(/^.*\.xml$/)) {
- newPath = path.substring(0, path.length - ".xml".length);
- }
- return newPath + newSfx;
-}
-
-function loadDocument(uri) {
- var parser = null;
- var source = null;
- var resolver = null;
- try {
- parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
- resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
- source = resolver.resolveURI(uri);
- var is = new
Packages.org.xml.sax.InputSource(source.getInputStream());
- is.setSystemId(source.getURI());
- return parser.parseDocument(is);
- } finally {
- if (source != null)
- resolver.release(source);
- cocoon.releaseComponent(parser);
- cocoon.releaseComponent(resolver);
- }
-}
-
-function saveDocument(document, uri) {
- var source = null;
- var resolver = null;
- var outputStream = null;
- try {
- resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
- source = resolver.resolveURI(uri);
-
- var tf =
Packages.javax.xml.transform.TransformerFactory.newInstance();
-
- if (source instanceof
Packages.org.apache.excalibur.source.ModifiableSource
- &&
tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
-
- outputStream = source.getOutputStream();
- var transformerHandler = tf.newTransformerHandler();
- var transformer = transformerHandler.getTransformer();
-
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT,
"true");
-
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD,
"xml");
- transformerHandler.setResult(new
Packages.javax.xml.transform.stream.StreamResult(outputStream));
-
- var streamer = new
Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
- streamer.stream(document);
- } else {
- throw new Packages.org.apache.cocoon.ProcessingException("Cannot
write to source " + uri);
- }
- } finally {
- if (source != null)
- resolver.release(source);
- cocoon.releaseComponent(resolver);
- if (outputStream != null) {
- try {
- outputStream.flush();
- outputStream.close();
- } catch (error) {
- cocoon.log.error("Could not flush/close outputstream: " +
error);
- }
- }
- }
-}
+/*
+ * 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.
+ */
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+// The purpose of the form2 example is to edit the contents of an XML file
+// or a Java bean through a Woody form
+
+// the form2 function is not directly called by the sitemap but by
+// a generic "woody" function that instantiates the form based on
+// parameters passed from the sitemap (see above loaded woody2.js file)
+function form2xml(form) {
+ // get the documentURI parameter from the sitemap which contains the
+ // location of the file to be edited
+ var documentURI = cocoon.parameters["documentURI"];
+
+ // parse the document to a DOM-tree
+ var document = loadDocument(documentURI);
+
+ // bind the document data to the form
+ form.load(document);
+
+ // show the form to the user until it is validated successfully
+ form.showForm("form2-display-pipeline");
+
+ // bind the form's data back to the document
+ form.save(document);
+
+ // save the DOM-tree back to an XML file, the makeTargetURI
+ // function makes a modified filename so that the
+ // original document is not overwritten
+ saveDocument(document, makeTargetURI(documentURI));
+
+ cocoon.sendPage("form2-success-pipeline");
+}
+
+// bean variant of the binding sample
+function form2bean(form) {
+ var bean = new Packages.org.apache.cocoon.woody.samples.Form2Bean();
+
+ // fill bean with some data to avoid users having to type to much
+ bean.setEmail("[EMAIL PROTECTED]");
+ bean.setIpAddress("10.0.0.1");
+ bean.setPhoneCountry("32");
+ bean.setPhoneZone("2");
+ bean.setPhoneNumber("123456");
+ bean.setBirthday(new java.util.Date());
+ bean.setSex(Packages.org.apache.cocoon.woody.samples.Sex.FEMALE);
+ var contact = new Packages.org.apache.cocoon.woody.samples.Contact();
+ contact.setId("1");
+ contact.setFirstName("Herman");
+ bean.addContact(contact);
+
+ form.load(bean);
+ form.showForm("form2-display-pipeline");
+ form.save(bean);
+
+ cocoon.sendPage("form2bean-success-pipeline", { "form2bean": bean });
+}
+
+/**
+ * Translate source path into target path so we keep a clean source XML.
+ */
+function makeTargetURI(path) {
+ var sfx = ".xml";
+ var newSfx = "-result.xml";
+ var newPath = path;
+ if (path.match(/^.*\.xml$/)) {
+ newPath = path.substring(0, path.length - ".xml".length);
+ }
+ return newPath + newSfx;
+}
+
+function loadDocument(uri) {
+ var parser = null;
+ var source = null;
+ var resolver = null;
+ try {
+ parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+ resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+ source = resolver.resolveURI(uri);
+ var is = new
Packages.org.xml.sax.InputSource(source.getInputStream());
+ is.setSystemId(source.getURI());
+ return parser.parseDocument(is);
+ } finally {
+ if (source != null)
+ resolver.release(source);
+ cocoon.releaseComponent(parser);
+ cocoon.releaseComponent(resolver);
+ }
+}
+
+function saveDocument(document, uri) {
+ var source = null;
+ var resolver = null;
+ var outputStream = null;
+ try {
+ resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+ source = resolver.resolveURI(uri);
+
+ var tf =
Packages.javax.xml.transform.TransformerFactory.newInstance();
+
+ if (source instanceof
Packages.org.apache.excalibur.source.ModifiableSource
+ &&
tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
+
+ outputStream = source.getOutputStream();
+ var transformerHandler = tf.newTransformerHandler();
+ var transformer = transformerHandler.getTransformer();
+
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT,
"true");
+
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD,
"xml");
+ transformerHandler.setResult(new
Packages.javax.xml.transform.stream.StreamResult(outputStream));
+
+ var streamer = new
Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
+ streamer.stream(document);
+ } else {
+ throw new Packages.org.apache.cocoon.ProcessingException("Cannot
write to source " + uri);
+ }
+ } finally {
+ if (source != null)
+ resolver.release(source);
+ cocoon.releaseComponent(resolver);
+ if (outputStream != null) {
+ try {
+ outputStream.flush();
+ outputStream.close();
+ } catch (error) {
+ cocoon.log.error("Could not flush/close outputstream: " +
error);
+ }
+ }
+ }
+}
1.5 +49 -49
cocoon-2.1/src/blocks/woody/samples/flow/customvalidationdemo.js
Index: customvalidationdemo.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/customvalidationdemo.js,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- customvalidationdemo.js 9 Mar 2004 13:54:01 -0000 1.4
+++ customvalidationdemo.js 11 May 2004 22:25:31 -0000 1.5
@@ -1,49 +1,49 @@
-/*
-* 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.
-*/
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-function customValidationDemo() {
- var form = new Form("forms/customvalidationdemo_form.xml");
-
- // the line below is the crucial piece for this demo: assigning
- // a function to do extra validation
- form.validator = myValidator;
-
- form.showForm("customvalidationdemo-display-pipeline");
-}
-
-function myValidator(form) {
- // Add an error message to specific widgets as follows:
- var validationError = new
Packages.org.apache.cocoon.woody.datatype.ValidationError("This is so wrong.");
- form.getWidget("number1").setValidationError(validationError);
- form.getWidget("number2").setValidationError(validationError);
-
- // Add some other messages to the 'messages' widget
- form.getWidget("messages").addMessage("You'll never be able to enter
valid data!");
- form.getWidget("messages").addMessage("Ha ha ha!");
-
- // to add i18n messages, do something like:
- // var i18nMessage = new
Packages.org.apache.cocoon.woody.util.I18nMessage("key");
- // form.getWidget("messages").addMessage(i18nMessage);
- // The I18nMessage class supports a variety of other constructors to do
more
- // powerful things, be sure to check them out.
-
- // Note that instead of doing all the above here in Javascript,
- // you can also delegate this work to a Java class (or Avalon component).
-
- // always return false, so that the form will never be valid
- return false;
-}
+/*
+* 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.
+*/
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+function customValidationDemo() {
+ var form = new Form("forms/customvalidationdemo_form.xml");
+
+ // the line below is the crucial piece for this demo: assigning
+ // a function to do extra validation
+ form.validator = myValidator;
+
+ form.showForm("customvalidationdemo-display-pipeline");
+}
+
+function myValidator(form) {
+ // Add an error message to specific widgets as follows:
+ var validationError = new
Packages.org.apache.cocoon.woody.datatype.ValidationError("This is so wrong.");
+ form.getWidget("number1").setValidationError(validationError);
+ form.getWidget("number2").setValidationError(validationError);
+
+ // Add some other messages to the 'messages' widget
+ form.getWidget("messages").addMessage("You'll never be able to enter
valid data!");
+ form.getWidget("messages").addMessage("Ha ha ha!");
+
+ // to add i18n messages, do something like:
+ // var i18nMessage = new
Packages.org.apache.cocoon.woody.util.I18nMessage("key");
+ // form.getWidget("messages").addMessage(i18nMessage);
+ // The I18nMessage class supports a variety of other constructors to do
more
+ // powerful things, be sure to check them out.
+
+ // Note that instead of doing all the above here in Javascript,
+ // you can also delegate this work to a Java class (or Avalon component).
+
+ // always return false, so that the form will never be valid
+ return false;
+}
1.5 +137 -137
cocoon-2.1/src/blocks/woody/samples/flow/form_model_gui.js
Index: form_model_gui.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/form_model_gui.js,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- form_model_gui.js 9 Mar 2004 13:54:00 -0000 1.4
+++ form_model_gui.js 11 May 2004 22:25:31 -0000 1.5
@@ -1,137 +1,137 @@
-/*
-* 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.
-*/
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-// CVS $Id$
-// Author: Timothy Larson
-
-function form_model_gui(form) {
-
- var locale = determineLocale();
- var model = form.getModel();
- form.locale = locale;
-
- // get the documentURI parameter from the sitemap which
- // contains the location of the file to be edited
- var documentURI = cocoon.parameters["documentURI"];
-
- // parse the document to a DOM-tree
- var document = loadDocument(documentURI);
-
- // bind the document data to the form
- form.load(document);
-
- // show the form
- form.showForm("form_model_gui-display-pipeline");
- print("submitId = " + form.submitId);
- if (form.isValid) {
- print("Form is valid");
- } else {
- print("Form is not valid");
- }
-
- // bind the form's data back to the document
- form.save(document);
-
- // save the DOM-tree back to an XML file, the makeTargetURI
- // function makes a modified filename so that the
- // original document is not overwritten
- saveDocument(document, makeTargetURI(documentURI));
-
- // also store the form as a request attribute as the XSP isn't flow-aware
- cocoon.request.setAttribute("form_model_gui", form.getWidget());
- cocoon.sendPage("form_model_gui-success-pipeline.xsp");
-}
-
-function determineLocale() {
- var localeParam = cocoon.request.get("locale");
- if (localeParam != null && localeParam.length > 0) {
- return
Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
- }
- return null;
-}
-
-/**
- * Translate source path into target path so we keep a clean source XML.
- */
-function makeTargetURI(path) {
- var sfx = ".xml";
- var newSfx = "-result.xml";
- var newPath = path;
- if (path.match(/^.*\.xml$/)) {
- newPath = path.substring(0, path.length - ".xml".length);
- }
- return newPath + newSfx;
-}
-
-function loadDocument(uri) {
- var parser = null;
- var source = null;
- var resolver = null;
- try {
- parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
- resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
- source = resolver.resolveURI(uri);
- var is = new
Packages.org.xml.sax.InputSource(source.getInputStream());
- is.setSystemId(source.getURI());
- return parser.parseDocument(is);
- } finally {
- if (source != null)
- resolver.release(source);
- cocoon.releaseComponent(parser);
- cocoon.releaseComponent(resolver);
- }
-}
-
-function saveDocument(document, uri) {
- var source = null;
- var resolver = null;
- var outputStream = null;
- try {
- resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
- source = resolver.resolveURI(uri);
-
- var tf =
Packages.javax.xml.transform.TransformerFactory.newInstance();
-
- if (source instanceof
Packages.org.apache.excalibur.source.ModifiableSource
- &&
tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
-
- outputStream = source.getOutputStream();
- var transformerHandler = tf.newTransformerHandler();
- var transformer = transformerHandler.getTransformer();
-
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT,
"true");
-
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD,
"xml");
- transformerHandler.setResult(new
Packages.javax.xml.transform.stream.StreamResult(outputStream));
-
- var streamer = new
Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
- streamer.stream(document);
- } else {
- throw new Packages.org.apache.cocoon.ProcessingException("Cannot
write to source " + uri);
- }
- } finally {
- if (source != null)
- resolver.release(source);
- cocoon.releaseComponent(resolver);
- if (outputStream != null) {
- try {
- outputStream.flush();
- outputStream.close();
- } catch (error) {
- cocoon.log.error("Could not flush/close outputstream: " +
error);
- }
- }
- }
-}
+/*
+* 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.
+*/
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+// CVS $Id$
+// Author: Timothy Larson
+
+function form_model_gui(form) {
+
+ var locale = determineLocale();
+ var model = form.getModel();
+ form.locale = locale;
+
+ // get the documentURI parameter from the sitemap which
+ // contains the location of the file to be edited
+ var documentURI = cocoon.parameters["documentURI"];
+
+ // parse the document to a DOM-tree
+ var document = loadDocument(documentURI);
+
+ // bind the document data to the form
+ form.load(document);
+
+ // show the form
+ form.showForm("form_model_gui-display-pipeline");
+ print("submitId = " + form.submitId);
+ if (form.isValid) {
+ print("Form is valid");
+ } else {
+ print("Form is not valid");
+ }
+
+ // bind the form's data back to the document
+ form.save(document);
+
+ // save the DOM-tree back to an XML file, the makeTargetURI
+ // function makes a modified filename so that the
+ // original document is not overwritten
+ saveDocument(document, makeTargetURI(documentURI));
+
+ // also store the form as a request attribute as the XSP isn't flow-aware
+ cocoon.request.setAttribute("form_model_gui", form.getWidget());
+ cocoon.sendPage("form_model_gui-success-pipeline.xsp");
+}
+
+function determineLocale() {
+ var localeParam = cocoon.request.get("locale");
+ if (localeParam != null && localeParam.length > 0) {
+ return
Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
+ }
+ return null;
+}
+
+/**
+ * Translate source path into target path so we keep a clean source XML.
+ */
+function makeTargetURI(path) {
+ var sfx = ".xml";
+ var newSfx = "-result.xml";
+ var newPath = path;
+ if (path.match(/^.*\.xml$/)) {
+ newPath = path.substring(0, path.length - ".xml".length);
+ }
+ return newPath + newSfx;
+}
+
+function loadDocument(uri) {
+ var parser = null;
+ var source = null;
+ var resolver = null;
+ try {
+ parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+ resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+ source = resolver.resolveURI(uri);
+ var is = new
Packages.org.xml.sax.InputSource(source.getInputStream());
+ is.setSystemId(source.getURI());
+ return parser.parseDocument(is);
+ } finally {
+ if (source != null)
+ resolver.release(source);
+ cocoon.releaseComponent(parser);
+ cocoon.releaseComponent(resolver);
+ }
+}
+
+function saveDocument(document, uri) {
+ var source = null;
+ var resolver = null;
+ var outputStream = null;
+ try {
+ resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+ source = resolver.resolveURI(uri);
+
+ var tf =
Packages.javax.xml.transform.TransformerFactory.newInstance();
+
+ if (source instanceof
Packages.org.apache.excalibur.source.ModifiableSource
+ &&
tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
+
+ outputStream = source.getOutputStream();
+ var transformerHandler = tf.newTransformerHandler();
+ var transformer = transformerHandler.getTransformer();
+
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT,
"true");
+
transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD,
"xml");
+ transformerHandler.setResult(new
Packages.javax.xml.transform.stream.StreamResult(outputStream));
+
+ var streamer = new
Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
+ streamer.stream(document);
+ } else {
+ throw new Packages.org.apache.cocoon.ProcessingException("Cannot
write to source " + uri);
+ }
+ } finally {
+ if (source != null)
+ resolver.release(source);
+ cocoon.releaseComponent(resolver);
+ if (outputStream != null) {
+ try {
+ outputStream.flush();
+ outputStream.close();
+ } catch (error) {
+ cocoon.log.error("Could not flush/close outputstream: " +
error);
+ }
+ }
+ }
+}
1.6 +51 -51
cocoon-2.1/src/blocks/woody/samples/flow/upload_example.js
Index: upload_example.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/upload_example.js,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- upload_example.js 9 Mar 2004 13:54:01 -0000 1.5
+++ upload_example.js 11 May 2004 22:25:31 -0000 1.6
@@ -1,51 +1,51 @@
-/*
-* 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.
-*/
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-function upload() {
-
- var form = new Form("forms/upload_model.xml");
- var k = form.showForm("upload-display-pipeline");
-
- k.invalidate();
-
- cocoon.sendPage("upload-success-pipeline.jx",
- {
- uploadContent: handleUpload(form),
- username: form.getWidget("user").getValue(),
- filename:
form.getWidget("upload").getValue().getHeaders().get("filename")
- }
- );
-}
-
-function handleUpload(form) {
-
- var buf = new java.lang.StringBuffer();
-
- var uploadWidget = form.getWidget("upload");
- if (uploadWidget.getValue() != null) {
- var stream = uploadWidget.getValue().getInputStream();
- var reader = new java.io.BufferedReader(new
java.io.InputStreamReader(stream));
-
- var line;
- while ((line=reader.readLine())!=null)
- buf.append(line).append("\n");
-
- reader.close();
- }
-
- return buf.toString();
-}
+/*
+* 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.
+*/
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+function upload() {
+
+ var form = new Form("forms/upload_model.xml");
+ var k = form.showForm("upload-display-pipeline");
+
+ k.invalidate();
+
+ cocoon.sendPage("upload-success-pipeline.jx",
+ {
+ uploadContent: handleUpload(form),
+ username: form.getWidget("user").getValue(),
+ filename:
form.getWidget("upload").getValue().getHeaders().get("filename")
+ }
+ );
+}
+
+function handleUpload(form) {
+
+ var buf = new java.lang.StringBuffer();
+
+ var uploadWidget = form.getWidget("upload");
+ if (uploadWidget.getValue() != null) {
+ var stream = uploadWidget.getValue().getInputStream();
+ var reader = new java.io.BufferedReader(new
java.io.InputStreamReader(stream));
+
+ var line;
+ while ((line=reader.readLine())!=null)
+ buf.append(line).append("\n");
+
+ reader.close();
+ }
+
+ return buf.toString();
+}
1.5 +26 -26 cocoon-2.1/src/blocks/woody/samples/flow/htmlarea.js
Index: htmlarea.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/htmlarea.js,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- htmlarea.js 9 Mar 2004 13:54:00 -0000 1.4
+++ htmlarea.js 11 May 2004 22:25:31 -0000 1.5
@@ -1,26 +1,26 @@
-/*
-* 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.
-*/
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-function htmlarea() {
- var form = new Form("forms/htmlarea.xml");
-
- form.showForm("htmlarea-display-pipeline");
-
- var model = form.getModel();
- var htmldata = { "data" : model.data }
- cocoon.sendPage("htmlarea-success-pipeline", htmldata);
-}
+/*
+* 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.
+*/
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+function htmlarea() {
+ var form = new Form("forms/htmlarea.xml");
+
+ form.showForm("htmlarea-display-pipeline");
+
+ var model = form.getModel();
+ var htmldata = { "data" : model.data }
+ cocoon.sendPage("htmlarea-success-pipeline", htmldata);
+}
1.14 +80 -80
cocoon-2.1/src/blocks/woody/samples/flow/woody_flow_example.js
Index: woody_flow_example.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/flow/woody_flow_example.js,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- woody_flow_example.js 9 Mar 2004 13:54:00 -0000 1.13
+++ woody_flow_example.js 11 May 2004 22:25:31 -0000 1.14
@@ -1,80 +1,80 @@
-/*
-* 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.
-*/
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-function form1(form) {
- var locale = determineLocale();
- var model = form.getModel();
- model.email = "[EMAIL PROTECTED]";
- model.somebool = true;
- model.account = 2;
- model.cowheight = 4;
- model.number1 = 1;
- model.number2 = 3;
- model.birthdate = new java.util.Date();
-
- model.contacts[0].firstname = "Jules";
- model.contacts[1].firstname = "Lucien";
- model.contacts[2].firstname = "Chris";
- model.drinks = ["Jupiler", "Coca Cola"];
-
- form.locale = locale;
- form.showForm("form1-display-pipeline");
- print("submitId = " + form.submitId);
- if (form.isValid) {
- print("visa=" + model.visa);
- } else {
- print("Form is not valid");
- }
- // also store the form as a request attribute as the XSP isn't flow-aware
- cocoon.request.setAttribute("form1", form.getWidget());
- cocoon.sendPage("form1-success-pipeline.xsp");
-}
-
-function selectCar() {
- var form = new Form("forms/carselector_form.xml");
- form.getWidget("make").setValue(cocoon.parameters.defaultMake);
- form.showForm("carselector-display-pipeline");
- cocoon.request.setAttribute("carselectorform", form.getWidget());
- cocoon.sendPage("carselector-success-pipeline.xsp");
-}
-
-var states = [
- { key: "AL", value: "Alabama" },
- { key: "AK", value: "Alaska" },
- { key: "WY", value: "Wyoming" }
-];
-
-var countries = [
- { key: "ad", value: "Andorra, Principality of" },
- { key: "zw", value: "Zimbabwe" }
-];
-
-function selectCountry() {
- var form = new Form("forms/countryselector_form.xml");
- form.showForm("countryselector-display-pipeline");
- cocoon.request.setAttribute("countryselectorform", form.getWidget());
- cocoon.sendPage("countryselector-success-pipeline.xsp");
-}
-
-function determineLocale() {
- var localeParam = cocoon.request.get("locale");
- if (localeParam != null && localeParam.length > 0) {
- return
Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
- }
- return null;
-}
-
+/*
+* 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.
+*/
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+function form1(form) {
+ var locale = determineLocale();
+ var model = form.getModel();
+ model.email = "[EMAIL PROTECTED]";
+ model.somebool = true;
+ model.account = 2;
+ model.cowheight = 4;
+ model.number1 = 1;
+ model.number2 = 3;
+ model.birthdate = new java.util.Date();
+
+ model.contacts[0].firstname = "Jules";
+ model.contacts[1].firstname = "Lucien";
+ model.contacts[2].firstname = "Chris";
+ model.drinks = ["Jupiler", "Coca Cola"];
+
+ form.locale = locale;
+ form.showForm("form1-display-pipeline");
+ print("submitId = " + form.submitId);
+ if (form.isValid) {
+ print("visa=" + model.visa);
+ } else {
+ print("Form is not valid");
+ }
+ // also store the form as a request attribute as the XSP isn't flow-aware
+ cocoon.request.setAttribute("form1", form.getWidget());
+ cocoon.sendPage("form1-success-pipeline.xsp");
+}
+
+function selectCar() {
+ var form = new Form("forms/carselector_form.xml");
+ form.getWidget("make").setValue(cocoon.parameters.defaultMake);
+ form.showForm("carselector-display-pipeline");
+ cocoon.request.setAttribute("carselectorform", form.getWidget());
+ cocoon.sendPage("carselector-success-pipeline.xsp");
+}
+
+var states = [
+ { key: "AL", value: "Alabama" },
+ { key: "AK", value: "Alaska" },
+ { key: "WY", value: "Wyoming" }
+];
+
+var countries = [
+ { key: "ad", value: "Andorra, Principality of" },
+ { key: "zw", value: "Zimbabwe" }
+];
+
+function selectCountry() {
+ var form = new Form("forms/countryselector_form.xml");
+ form.showForm("countryselector-display-pipeline");
+ cocoon.request.setAttribute("countryselectorform", form.getWidget());
+ cocoon.sendPage("countryselector-success-pipeline.xsp");
+}
+
+function determineLocale() {
+ var localeParam = cocoon.request.get("locale");
+ if (localeParam != null && localeParam.length > 0) {
+ return
Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
+ }
+ return null;
+}
+
1.5 +50 -50 cocoon-2.1/src/blocks/woody/samples/aggregate/example.js
Index: example.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/aggregate/example.js,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- example.js 9 Mar 2004 13:54:23 -0000 1.4
+++ example.js 11 May 2004 22:25:32 -0000 1.5
@@ -1,50 +1,50 @@
-/*
- * 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.
- */
-
-cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
-
-Bean.prototype.date;
-Bean.prototype.phone;
-function Bean () {
-};
-
-function example() {
- var bean = new Bean();
- var form = new Form("form.xml");
- var template = "combine";
-
- while (true) {
- form.createBinding("binding-" + template + ".xml");
-
- // java.lang.System.out.println("Loading. Date: " + bean.date + ",
Day: " + bean.day + ", Month: " + bean.month + ", Year: " + bean.year);
- form.load(bean);
- form.showForm(template + "-display-pipeline", bean);
- form.save(bean);
- // java.lang.System.out.println("Saved. Date: " + bean.date + ",
Day: " + bean.day + ", Month: " + bean.month + ", Year: " + bean.year);
-
- if (form.submitId == "switch") {
- if (template == "combine") {
- template = "split";
- } else {
- template = "combine";
- }
-
- // Preserve values after switch
- form.createBinding("binding-" + template + ".xml");
- form.save(bean);
- }
- }
-}
+/*
+ * 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.
+ */
+
+cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
+
+Bean.prototype.date;
+Bean.prototype.phone;
+function Bean () {
+};
+
+function example() {
+ var bean = new Bean();
+ var form = new Form("form.xml");
+ var template = "combine";
+
+ while (true) {
+ form.createBinding("binding-" + template + ".xml");
+
+ // java.lang.System.out.println("Loading. Date: " + bean.date + ",
Day: " + bean.day + ", Month: " + bean.month + ", Year: " + bean.year);
+ form.load(bean);
+ form.showForm(template + "-display-pipeline", bean);
+ form.save(bean);
+ // java.lang.System.out.println("Saved. Date: " + bean.date + ",
Day: " + bean.day + ", Month: " + bean.month + ", Year: " + bean.year);
+
+ if (form.submitId == "switch") {
+ if (template == "combine") {
+ template = "split";
+ } else {
+ template = "combine";
+ }
+
+ // Preserve values after switch
+ form.createBinding("binding-" + template + ".xml");
+ form.save(bean);
+ }
+ }
+}