You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by mp...@apache.org on 2004/04/05 11:38:51 UTC
cvs commit: cocoon-2.1/src/blocks/forms/samples/flow bindings.js
mpo 2004/04/05 02:38:51
Modified: src/blocks/forms/samples/flow bindings.js
Log:
Code formatting. (tabs to spaces)
Revision Changes Path
1.3 +66 -66 cocoon-2.1/src/blocks/forms/samples/flow/bindings.js
Index: bindings.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/samples/flow/bindings.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bindings.js 11 Mar 2004 02:56:33 -0000 1.2
+++ bindings.js 5 Apr 2004 09:38:51 -0000 1.3
@@ -52,37 +52,37 @@
* 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"];
- }
+ // 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"];
+ }
- // all back-end models are bound to essentially the same form, using the same binding!
- var form = createFormForSample(sampleCode);
+ // 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"];
+ }
- // the beack-end model itself however depends on sample and type.
- var bean = createBeanForSample(backendType, sampleCode);
+ // 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);
+ // loads the backend-bean into the form
+ form.load(bean);
- // wait for user to submit the form correctly
- form.showForm("binding.form");
+ // 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;
+ // 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);
+ cocoon.sendPage("binding.done", bizData);
}
/**
@@ -90,33 +90,33 @@
* binding.
*/
function createFormForSample(sampleCode) {
- var form = new Form("forms/binding/" + sampleCode + "-def.xml");
- form.createBinding("forms/binding/" + sampleCode +"-bind.xml");
- return form;
+ 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();
- }
+ 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
+ // 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 uri = "forms/binding/" + sampleCode +"-data.xml";
+ print("Using the XML data file at " + uri);
var parser = null;
var source = null;
@@ -142,60 +142,60 @@
* 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;
+ 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.forms.samples.bindings.ValuesBean();
+ return new Packages.org.apache.cocoon.forms.samples.bindings.ValuesBean();
}
/**
* Creates the JS Bean for sample '02lenient'
*/
function createJSBeanFor02lenient() {
- var bean = new Object();
+ var bean = new Object();
var contexts = ["one","two","three"];
- for(var i=0; i<contexts.length; i++) {
- bean[contexts[i]] = new Object();
+ 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;
+ 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 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++) {
+ 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.forms.samples.bindings.LenientOKBean("init");
-// var subBean = new Packages.org.apache.cocoon.forms.samples.bindings.LenientNotOKBean("init");
+ var subBean = new Packages.org.apache.cocoon.forms.samples.bindings.LenientOKBean("init");
+// var subBean = new Packages.org.apache.cocoon.forms.samples.bindings.LenientNotOKBean("init");
- // the NotOkBean does not have a getBreakingField() required by the non-lenient binding
+ // the NotOkBean does not have a getBreakingField() required by the non-lenient binding
- bean.put(contexts[i], subBean);
+ bean.put(contexts[i], subBean);
}
- return bean;
+ return bean;
}
Re: cvs commit: cocoon-2.1/src/blocks/forms/samples/flow bindings.js
Posted by Marc Portier <mp...@outerthought.org>.
mpo@apache.org wrote:
> mpo 2004/04/05 02:38:51
>
> Modified: src/blocks/forms/samples/flow bindings.js
> Log:
> Code formatting. (tabs to spaces)
>
Anyone out there using a js editor that does it OOTB?
-marc=
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/mpo/
mpo@outerthought.org mpo@apache.org