cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r177978 - in /cocoon/blocks/core/forms/trunk: WEB-INF/xconf/ java/org/apache/cocoon/forms/formmodel/ java/org/apache/cocoon/forms/resources/js/ java/org/apache/cocoon/forms/util/ java/org/apache/cocoon/forms/validation/ samples/ samples/captcha/ samples/captcha/flow/ samples/captcha/forms/ samples/forms/ test/org/apache/cocoon/forms/formmodel/
Date Mon, 23 May 2005 13:27:52 GMT
Author: sylvain
Date: Mon May 23 06:27:51 2005
New Revision: 177978

URL: http://svn.apache.org/viewcvs?rev=177978&view=rev
Log:
Important optimization of AJAX refreshes. Previously, all fields were updated even if not
needed

Added:
    cocoon/blocks/core/forms/trunk/samples/captcha/
    cocoon/blocks/core/forms/trunk/samples/captcha/captcha-image.xml   (with props)
    cocoon/blocks/core/forms/trunk/samples/captcha/flow/
    cocoon/blocks/core/forms/trunk/samples/captcha/flow/captcha.js   (with props)
    cocoon/blocks/core/forms/trunk/samples/captcha/forms/
    cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.def.xml   (with props)
    cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.tpl.xml   (with props)
    cocoon/blocks/core/forms/trunk/samples/captcha/sitemap.xmap   (with props)
    cocoon/blocks/core/forms/trunk/samples/captcha/success.xml   (with props)
Modified:
    cocoon/blocks/core/forms/trunk/WEB-INF/xconf/cocoon-forms.xconf
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Action.java
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Field.java
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/resources/js/cforms.js
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/I18nMessage.java
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/StringMessage.java
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/validation/ValidationError.java
    cocoon/blocks/core/forms/trunk/samples/forms/carselector_form.xml
    cocoon/blocks/core/forms/trunk/samples/forms/carselector_template.xml
    cocoon/blocks/core/forms/trunk/samples/sitemap.xmap
    cocoon/blocks/core/forms/trunk/test/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml

Modified: cocoon/blocks/core/forms/trunk/WEB-INF/xconf/cocoon-forms.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/WEB-INF/xconf/cocoon-forms.xconf?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/WEB-INF/xconf/cocoon-forms.xconf (original)
+++ cocoon/blocks/core/forms/trunk/WEB-INF/xconf/cocoon-forms.xconf Mon May 23 06:27:51 2005
@@ -156,6 +156,7 @@
       <widget name="new" src="org.apache.cocoon.forms.formmodel.NewDefinitionBuilder"/>
       <widget name="struct" src="org.apache.cocoon.forms.formmodel.StructDefinitionBuilder"/>
       <widget name="union" src="org.apache.cocoon.forms.formmodel.UnionDefinitionBuilder"/>
+      <widget name="captcha" src="org.apache.cocoon.forms.formmodel.CaptchaDefinitionBuilder"/>
     </widgets>
   </forms-formmanager>
 
@@ -176,6 +177,7 @@
     <validator name="assert" class="org.apache.cocoon.forms.validation.impl.AssertValidatorBuilder"/>
     <validator name="mod10" class="org.apache.cocoon.forms.validation.impl.Mod10ValidatorBuilder"/>
     <validator name="regexp" class="org.apache.cocoon.forms.validation.impl.RegExpValidatorBuilder"/>
+    <validator name="captcha" class="org.apache.cocoon.forms.validation.impl.CaptchaValidatorBuilder"/>
   </forms-validators>
 
   <forms-widgetlisteners>

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Action.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Action.java?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Action.java (original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Action.java Mon
May 23 06:27:51 2005
@@ -55,7 +55,7 @@
         Request request = formContext.getRequest();
 
         String value = request.getParameter(fullId);
-        if (value != null && value.length() > 0) {
+        if (value != null) {
             form.setSubmitWidget(this);
 
         } else {

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Field.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Field.java?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Field.java (original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/formmodel/Field.java Mon May
23 06:27:51 2005
@@ -26,6 +26,7 @@
 import org.apache.cocoon.forms.validation.ValidationErrorAware;
 import org.apache.cocoon.xml.AttributesImpl;
 import org.apache.cocoon.xml.XMLUtils;
+import org.apache.commons.lang.ObjectUtils;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -145,6 +146,8 @@
             return this.value;
         }
 
+        ValidationError oldError = this.validationError;
+
         // Parse the value
         if (this.valueState == VALUE_UNPARSED) {
             doParse();
@@ -155,6 +158,12 @@
             doValidate();
         }
 
+        if (oldError != null && this.validationError == null) {
+            // The parsing process removed an existing validation error. This happens
+            // mainly when a required field is given a value.
+            getForm().addWidgetUpdate(this);
+        }
+
         return this.validationError == null ? this.value : null;
     }
 
@@ -237,6 +246,7 @@
             changed = !enteredValue.equals(newEnteredValue);
         }
         if (changed) {
+            ValidationError oldError = this.validationError;
             
             // If we have some value-changed listeners, we must make sure the current value
has been
             // parsed, to fill the event. Otherwise, we don't need to spend that extra CPU
time.
@@ -253,8 +263,12 @@
                 // will lazily compute the new value only if needed.
                 getForm().addWidgetEvent(new DeferredValueChangedEvent(this, oldValue));
             }
-            
-            getForm().addWidgetUpdate(this);
+
+            if (oldError != null) {
+                // There was a validation error, and the user entered a new value: refresh
+                // the widget, because the previous error was cleared
+                getForm().addWidgetUpdate(this);
+            }
         }
     }
 
@@ -274,7 +288,9 @@
         if (this.valueState == VALUE_PARSED) {
             doValidate();
             this.valueState = VALUE_DISPLAY_VALIDATION;
-            getForm().addWidgetUpdate(this);
+            if (this.validationError != null) {
+                getForm().addWidgetUpdate(this);
+            }
         } else if (this.valueState == VALUE_PARSE_ERROR) {
             this.valueState = VALUE_DISPLAY_PARSE_ERROR;
             getForm().addWidgetUpdate(this);
@@ -324,6 +340,7 @@
      * validation failed.
      */
     private void doValidate() {
+
         if (this.valueState != VALUE_PARSED) {
             throw new IllegalStateException("Field is not in PARSED state (" + this.valueState
+ ")");
         }
@@ -364,9 +381,11 @@
      * @param error the validation error
      */
     public void setValidationError(ValidationError error) {
-        this.validationError = error;
         this.valueState = VALUE_DISPLAY_VALIDATION;
-        getForm().addWidgetUpdate(this);
+        if (!ObjectUtils.equals(this.validationError, error)) {
+            this.validationError = error;
+            getForm().addWidgetUpdate(this);
+        }
     }
 
     public boolean isRequired() {

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/resources/js/cforms.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/resources/js/cforms.js?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/resources/js/cforms.js (original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/resources/js/cforms.js Mon
May 23 06:27:51 2005
@@ -129,7 +129,7 @@
             // Get the continuation-id, if any.
             var contParam = '?cocoon-ajax-continue=true';
             if (form.elements["continuation-id"]) {
-                contParam = "&continuation-id=" + form.elements["continuation-id"].value;
+                contParam += "&continuation-id=" + form.elements["continuation-id"].value;
             }
             window.location.href = form.action + contParam;
         } else {

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/I18nMessage.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/I18nMessage.java?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/I18nMessage.java (original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/I18nMessage.java Mon
May 23 06:27:51 2005
@@ -15,9 +15,12 @@
  */
 package org.apache.cocoon.forms.util;
 
+import java.util.Arrays;
+
 import org.apache.cocoon.transformation.I18nTransformer;
 import org.apache.cocoon.xml.AttributesImpl;
 import org.apache.cocoon.xml.XMLUtils;
+import org.apache.commons.lang.ObjectUtils;
 import org.apache.excalibur.xml.sax.XMLizable;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -130,5 +133,17 @@
             contentHandler.endElement(I18nTransformer.I18N_NAMESPACE_URI, I18nTransformer.I18N_TRANSLATE_ELEMENT,
"i18n:" + I18nTransformer.I18N_TRANSLATE_ELEMENT);
         }
         contentHandler.endPrefixMapping("i18n");
+    }
+    
+    public boolean equals(Object obj) {
+        if (obj instanceof I18nMessage) {
+            I18nMessage other = (I18nMessage)obj;
+            return ObjectUtils.equals(this.catalogue, other.catalogue) &&
+                   ObjectUtils.equals(this.key, other.key) &&
+                   Arrays.equals(this.keys, other.keys) &&
+                   Arrays.equals(this.parameters, other.parameters);
+        } else {
+            return false;
+        }
     }
 }

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/StringMessage.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/StringMessage.java?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/StringMessage.java (original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/util/StringMessage.java Mon
May 23 06:27:51 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.forms.util;
 
+import java.util.Arrays;
+
 import org.apache.excalibur.xml.sax.XMLizable;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -35,5 +37,14 @@
 
     public void toSAX(ContentHandler contentHandler) throws SAXException {
         contentHandler.characters(ch, 0, ch.length);
+    }
+    
+    public boolean equals(Object obj) {
+        if (obj instanceof StringMessage) {
+            // Compare char arrays
+            return Arrays.equals(this.ch, ((StringMessage)obj).ch);
+        } else {
+            return false;
+        }
     }
 }

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/validation/ValidationError.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/validation/ValidationError.java?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/validation/ValidationError.java
(original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/validation/ValidationError.java
Mon May 23 06:27:51 2005
@@ -19,6 +19,7 @@
 import org.xml.sax.SAXException;
 import org.apache.cocoon.forms.util.I18nMessage;
 import org.apache.cocoon.forms.util.StringMessage;
+import org.apache.commons.lang.ObjectUtils;
 import org.apache.excalibur.xml.sax.XMLizable;
 
 /**
@@ -82,6 +83,14 @@
     public void generateSaxFragment(ContentHandler contentHandler) throws SAXException {
         if (saxFragment != null) {
             saxFragment.toSAX(contentHandler);
+        }
+    }
+    
+    public boolean equals(Object obj) {
+        if (obj instanceof ValidationError) {
+            return ObjectUtils.equals(this.saxFragment, ((ValidationError)obj).saxFragment);
+        } else {
+            return false;
         }
     }
 }

Added: cocoon/blocks/core/forms/trunk/samples/captcha/captcha-image.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/captcha/captcha-image.xml?rev=177978&view=auto
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/captcha/captcha-image.xml (added)
+++ cocoon/blocks/core/forms/trunk/samples/captcha/captcha-image.xml Mon May 23 06:27:51 2005
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<svg width="210" height="75">
+    <defs>
+        <filter id="blur2">
+            <feGaussianBlur stdDeviation="2"/>
+        </filter>
+    </defs>
+     <g id="imagegroup">
+        <text style="fill:#0086B3;font-size:42;font-family:Courier;filter:url(#blur2);"
x="0" y="48">#{$cocoon/parameters/value}</text>
+     </g>
+</svg>

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/captcha-image.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/captcha-image.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/core/forms/trunk/samples/captcha/flow/captcha.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/captcha/flow/captcha.js?rev=177978&view=auto
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/captcha/flow/captcha.js (added)
+++ cocoon/blocks/core/forms/trunk/samples/captcha/flow/captcha.js Mon May 23 06:27:51 2005
@@ -0,0 +1,24 @@
+/*
+ * 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/forms/flow/javascript/Form.js");
+
+function captcha() {
+    var form = new Form("forms/captcha.def.xml");
+    form.showForm("captcha-display-pipeline");
+    cocoon.sendPage("success", {
+        value: form.lookupWidget("/f1").value,
+    });
+}

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/flow/captcha.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/flow/captcha.js
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.def.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.def.xml?rev=177978&view=auto
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.def.xml (added)
+++ cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.def.xml Mon May 23 06:27:51
2005
@@ -0,0 +1,37 @@
+<?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.
+-->
+
+<!--
+  @version $Id$
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+         xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+
+  <fd:widgets>
+  
+    <fd:captcha id="f1" required="true" length="8">
+      <fd:label>Copy the string shown on the right into the input field</fd:label>
+      <fd:datatype base="string"/>
+      <fd:validation>
+        <fd:captcha/>
+      </fd:validation>
+    </fd:captcha>
+
+  </fd:widgets>
+    
+</fd:form>

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.def.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.def.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.tpl.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.tpl.xml?rev=177978&view=auto
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.tpl.xml (added)
+++ cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.tpl.xml Mon May 23 06:27:51
2005
@@ -0,0 +1,35 @@
+<?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 xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+
+  <title>CAPTCHA validation sample form</title>
+  <content>
+    <p>This is a demonstration of <a href="http://www.captcha.net/">CAPTCHA</a>
+    validation.</p>
+    <ft:form-template action="#{$cocoon/continuation/id}.cont" method="POST">
+      <fi:group>
+        <fi:styling layout="columns"/>
+        <fi:items>
+          <ft:widget id="f1"/>
+        </fi:items>
+      </fi:group>
+    </ft:form-template>
+  </content>
+</page>
+

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.tpl.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/forms/captcha.tpl.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/core/forms/trunk/samples/captcha/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/captcha/sitemap.xmap?rev=177978&view=auto
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/captcha/sitemap.xmap (added)
+++ cocoon/blocks/core/forms/trunk/samples/captcha/sitemap.xmap Mon May 23 06:27:51 2005
@@ -0,0 +1,115 @@
+<?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.
+-->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+ 
+ <map:views>
+  <map:view name="content" from-label="content">
+   <map:serialize type="xml"/>
+  </map:view>
+  
+  <map:view name="content1" from-label="content1">
+   <map:serialize type="xml"/>
+  </map:view>  
+
+  <map:view from-label="content" name="pretty-content">
+   <map:transform src="context://stylesheets/system/xml2html.xslt"/>
+   <map:serialize type="html"/>
+  </map:view>
+
+  <map:view name="links" from-position="last">
+   <map:serialize type="links"/>
+  </map:view>
+ </map:views>
+ 
+ <map:resources>
+   <!-- this will later become a virtual transformer -->
+   <map:resource name="simple-page2html">
+     <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
+       <map:parameter name="contextPath" value="{request:contextPath}"/>
+       <map:parameter name="servletPath" value="{request:servletPath}"/>
+       <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
+       <map:parameter name="file" value="{file}"/>
+       <map:parameter name="remove" value="{../0}"/>
+     </map:transform> 
+   </map:resource>
+ </map:resources>
+
+  <!-- indicates what flowscript to attach to this sitemap -->
+  <map:flow language="javascript">
+    <map:script src="flow/captcha.js"/>
+  </map:flow>
+
+ <map:pipelines>
+   <map:pipeline>
+
+     <map:match pattern="">
+       <map:call function="captcha"/>
+     </map:match>
+
+     <map:match pattern="*.cont">
+       <map:call continuation="{1}"/>
+     </map:match>
+
+     <map:match pattern="success">
+       <map:generate type="jx" src="success.xml"/>
+       <map:call resource="simple-page2html">
+         <map:parameter name="file" value="success.xml"/>
+       </map:call>
+       <map:serialize/>
+     </map:match>
+
+     <!--
+        | Show a form, using the forms transformer
+        -->
+     <map:match pattern="*-display-pipeline">
+       <map:generate type="file" src="forms/{1}.tpl.xml"/>
+       <map:transform type="forms" label="content1"/>
+       <map:transform type="i18n">
+         <!--map:parameter name="locale" value="en-US"/-->
+       </map:transform>
+       <map:call resource="simple-page2html">
+         <map:parameter name="file" value="forms/{1}.tpl.xml"/>
+       </map:call>
+       <map:transform src="../resources/forms-samples-styling.xsl">
+         <map:parameter name="resources-uri" value="../resources"/>
+       </map:transform>
+       <map:serialize/>
+     </map:match>
+
+    <!--
+       | Generate the CAPTCHA image. Any type of generator can be used here,
+       | as long as it reads the string to display from the session
+       | attribute named "captcha-{1}".
+       | Using an SVG file as input requires that the Batik block be
+       | included in the build.
+       -->
+    <map:match pattern="captcha-*.jpg">
+      <map:generate type="jx" src="captcha-image.xml">
+        <map:parameter name="value" value="{session-attr:captcha-{1}}"/>
+      </map:generate>
+      <map:serialize type="svg2jpeg"/>
+    </map:match>
+    
+    <map:match pattern="*">
+      <map:redirect-to uri="{1}/"/>
+    </map:match>
+
+   </map:pipeline>
+ </map:pipelines>
+
+</map:sitemap>

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/sitemap.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/sitemap.xmap
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/core/forms/trunk/samples/captcha/success.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/captcha/success.xml?rev=177978&view=auto
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/captcha/success.xml (added)
+++ cocoon/blocks/core/forms/trunk/samples/captcha/success.xml Mon May 23 06:27:51 2005
@@ -0,0 +1,24 @@
+<!--
+  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 xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+
+  <title>CAPTCHA validation succeeded</title>
+  <content>
+    <p>You guessed ${value}. Correct!</p>
+  </content>
+</page>

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/success.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/core/forms/trunk/samples/captcha/success.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/core/forms/trunk/samples/forms/carselector_form.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/forms/carselector_form.xml?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/forms/carselector_form.xml (original)
+++ cocoon/blocks/core/forms/trunk/samples/forms/carselector_form.xml Mon May 23 06:27:51
2005
@@ -86,14 +86,16 @@
           modelwidget.setValue(null);
           
           // Fun with messages...
+          var msg = event.source.lookupWidget("../message");
           if (value != null) {
-            var msg = event.source.lookupWidget("../message");
             if (event.oldValue == null) {
               msg.value = "A " + makewidget.value + " " + value + " is a very good choice.";
             } else {
               msg.value = "So you prefer a " + value + " ?";
             }
-          }
+          } else {
+	      msg.value = "I see that you're undecided...";
+	  }
         </javascript>
       </fd:on-value-changed>
     </fd:field>
@@ -122,6 +124,10 @@
     <fd:output id="message">
       <fd:datatype base="string"/>
     </fd:output>
+
+    <fd:submit id="buy">
+      <fd:label>Buy it!</fd:label>
+    </fd:submit>
   
   </fd:widgets>
 

Modified: cocoon/blocks/core/forms/trunk/samples/forms/carselector_template.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/forms/carselector_template.xml?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/forms/carselector_template.xml (original)
+++ cocoon/blocks/core/forms/trunk/samples/forms/carselector_template.xml Mon May 23 06:27:51
2005
@@ -58,7 +58,7 @@
       <a id="blink" href="#" onclick="setEffect('blink')">Blink</a>
     </para>
       
-    <ft:form-template action="carselector" method="POST" ajax="true">
+    <ft:form-template action="continue" method="POST" ajax="true">
       <ft:continuation-id/>
       <fi:group>
         <fi:styling layout="columns"/>
@@ -73,7 +73,7 @@
             <fi:styling submit-on-change="true"/>
           </ft:widget>
           <ft:widget id="message"/>
-          <input type="submit" value="Buy it!"/>
+          <ft:widget id="buy"/>
         </fi:items>
       </fi:group>
     </ft:form-template>

Modified: cocoon/blocks/core/forms/trunk/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/sitemap.xmap?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/sitemap.xmap (original)
+++ cocoon/blocks/core/forms/trunk/samples/sitemap.xmap Mon May 23 06:27:51 2005
@@ -335,16 +335,9 @@
      </map:match>
 
      <map:match pattern="carselector">
-       <map:select type="request-method">
-         <map:when test="POST">
-           <map:call continuation="{request-param:continuation-id}"/>
-         </map:when>
-         <map:otherwise>
-           <map:call function="selectCar">
-             <map:parameter name="defaultMake" value="Maserati"/>
-           </map:call>
-         </map:otherwise>
-       </map:select>
+       <map:call function="selectCar">
+         <map:parameter name="defaultMake" value="Maserati"/>
+       </map:call>
      </map:match>
 
      <!--

Modified: cocoon/blocks/core/forms/trunk/test/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/test/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml?rev=177978&r1=177977&r2=177978&view=diff
==============================================================================
--- cocoon/blocks/core/forms/trunk/test/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml
(original)
+++ cocoon/blocks/core/forms/trunk/test/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml
Mon May 23 06:27:51 2005
@@ -1,3 +1,20 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2005 The Apache Software Foundation or its licensors,
+  as applicable.
+
+  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.
+-->
 <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
     <fd:widgets>
         <fd:field id="stringfield">



Mime
View raw message