click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r1052886 - in /click/trunk/click/examples: src/org/apache/click/examples/page/form/TabbedFormDemo.java webapp/form/tabbed-form-demo.htm
Date Sun, 26 Dec 2010 13:42:21 GMT
Author: sabob
Date: Sun Dec 26 13:42:21 2010
New Revision: 1052886

URL: http://svn.apache.org/viewvc?rev=1052886&view=rev
Log:
started on CLK-735

Modified:
    click/trunk/click/examples/src/org/apache/click/examples/page/form/TabbedFormDemo.java
    click/trunk/click/examples/webapp/form/tabbed-form-demo.htm

Modified: click/trunk/click/examples/src/org/apache/click/examples/page/form/TabbedFormDemo.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/form/TabbedFormDemo.java?rev=1052886&r1=1052885&r2=1052886&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/form/TabbedFormDemo.java
(original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/form/TabbedFormDemo.java
Sun Dec 26 13:42:21 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.click.examples.page.form;
 
+import java.io.Serializable;
+
 import org.apache.click.control.Checkbox;
 import org.apache.click.control.Field;
 import org.apache.click.control.FieldSet;
@@ -31,6 +33,7 @@ import org.apache.click.examples.control
 import org.apache.click.examples.control.TitleSelect;
 import org.apache.click.examples.page.BorderPage;
 import org.apache.click.examples.page.HomePage;
+import org.apache.click.examples.util.ExampleUtils;
 import org.apache.click.extras.control.CreditCardField;
 import org.apache.click.extras.control.DateField;
 import org.apache.click.extras.control.EmailField;
@@ -55,6 +58,16 @@ public class TabbedFormDemo extends Bord
     private CreditCardField cardNumber = new CreditCardField("cardNumber");
     private IntegerField expiry = new IntegerField("expiry");
 
+
+    protected Form optionsForm = new Form("optionsForm");
+
+    /** Form options holder. */
+    public static class Options implements Serializable {
+        static final long serialVersionUID = 1L;
+        boolean javaScriptValidate = false;
+    }
+
+    private Checkbox jsValidate = new Checkbox("jsValidate", "JavaScript Validate");
     // Constructor ------------------------------------------------------------
 
     public TabbedFormDemo() {
@@ -121,10 +134,37 @@ public class TabbedFormDemo extends Bord
         form.add(new PageSubmit("cancel", HomePage.class));
 
         addControl(form);
+
+        // Settings Form
+        FieldSet fieldSet = new FieldSet("options", "Form Options");
+        jsValidate.setAttribute("onclick", "form.submit();");
+        fieldSet.add(jsValidate);
+        optionsForm.add(fieldSet);
+        optionsForm.setListener(this, "onOptionsSubmit");
+        addControl(optionsForm);
     }
 
     // Event Handlers ---------------------------------------------------------
 
+    /**
+     * @see org.apache.click.Page#onInit()
+     */
+    @Override
+    public void onInit() {
+        super.onInit();
+
+        applyOptions();
+    }
+
+    public boolean onOptionsSubmit() {
+        Options options = new Options();
+        options.javaScriptValidate = jsValidate.isChecked();
+        ExampleUtils.setSessionObject(options);
+        applyOptions();
+        return true;
+    }
+
+
     public boolean onOkClick() {
         if (isFormValid()) {
             processDelivery();
@@ -162,4 +202,11 @@ public class TabbedFormDemo extends Bord
             System.out.println(field.getName() + "=" + field.getValue());
         }
     }
+
+    private void applyOptions() {
+        Options options = (Options) ExampleUtils.getSessionObject(Options.class);
+
+        form.setJavaScriptValidation(options.javaScriptValidate);
+        jsValidate.setChecked(options.javaScriptValidate);
+    }
 }

Modified: click/trunk/click/examples/webapp/form/tabbed-form-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/form/tabbed-form-demo.htm?rev=1052886&r1=1052885&r2=1052886&view=diff
==============================================================================
--- click/trunk/click/examples/webapp/form/tabbed-form-demo.htm (original)
+++ click/trunk/click/examples/webapp/form/tabbed-form-demo.htm Sun Dec 26 13:42:21 2010
@@ -18,3 +18,7 @@
 -->
 
 $form
+
+<br/>
+
+$optionsForm
\ No newline at end of file



Mime
View raw message