You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/07/09 07:54:14 UTC

svn commit: r962419 - in /click/trunk/click/examples: src/org/apache/click/examples/page/ajax/ src/org/apache/click/examples/page/ajax/accordion/ src/org/apache/click/examples/page/ajax/compare/ src/org/apache/click/examples/page/ajax/form/ src/org/apa...

Author: sabob
Date: Fri Jul  9 05:53:56 2010
New Revision: 962419

URL: http://svn.apache.org/viewvc?rev=962419&view=rev
Log:
reshuffled ajax examples and added a few new ones. Still a work in progress

Added:
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxDemoPage.java
      - copied, changed from r953978, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/BasicAjaxDemoPage.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/accordion/
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/accordion/AjaxAccordion.java
      - copied, changed from r947955, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxAccordion.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JavascriptAjaxDemoPage.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JqueryAjaxDemoPage.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/PrototypeAjaxDemoPage.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/form/
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/form/FormAjaxDemoPage.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/scroller/
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/scroller/AjaxLiveScroller.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxCustomer.java
      - copied, changed from r947955, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxCustomer.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxSelect.java
      - copied, changed from r947955, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxSelect.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/table/
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/table/TableAjaxDemoPage.java
    click/trunk/click/examples/webapp/ajax/accordion/
    click/trunk/click/examples/webapp/ajax/accordion/ajax-accordion.htm
      - copied unchanged from r943406, click/trunk/click/examples/webapp/ajax/ajax-accordion.htm
    click/trunk/click/examples/webapp/ajax/accordion/ajax-accordion.js
      - copied unchanged from r943406, click/trunk/click/examples/webapp/ajax/ajax-accordion.js
    click/trunk/click/examples/webapp/ajax/ajax-demo.htm
    click/trunk/click/examples/webapp/ajax/compare/
    click/trunk/click/examples/webapp/ajax/compare/javascript-ajax-demo.htm
    click/trunk/click/examples/webapp/ajax/compare/jquery-ajax-demo.htm
    click/trunk/click/examples/webapp/ajax/compare/prototype-ajax-demo.htm
    click/trunk/click/examples/webapp/ajax/form/
    click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.htm
    click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.js
    click/trunk/click/examples/webapp/ajax/scroller/
    click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.htm
      - copied, changed from r943406, click/trunk/click/examples/webapp/ajax/ajax-live-scroller.htm
    click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.js
      - copied, changed from r943406, click/trunk/click/examples/webapp/ajax/ajax-live-scroller.js
    click/trunk/click/examples/webapp/ajax/scroller/customers.htm
    click/trunk/click/examples/webapp/ajax/select/
    click/trunk/click/examples/webapp/ajax/select/ajax-customer.htm
      - copied unchanged from r943406, click/trunk/click/examples/webapp/ajax/ajax-customer.htm
    click/trunk/click/examples/webapp/ajax/select/ajax-select.htm
      - copied unchanged from r943406, click/trunk/click/examples/webapp/ajax/ajax-select.htm
    click/trunk/click/examples/webapp/ajax/select/ajax-select.js
      - copied, changed from r943406, click/trunk/click/examples/webapp/ajax/ajax-select.js
    click/trunk/click/examples/webapp/ajax/table/
    click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.htm
    click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.js
Removed:
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxAccordion.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxCustomer.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxLiveScroller.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxSelect.java
    click/trunk/click/examples/src/org/apache/click/examples/page/ajax/BasicAjaxDemoPage.java
    click/trunk/click/examples/webapp/ajax/ajax-accordion.htm
    click/trunk/click/examples/webapp/ajax/ajax-accordion.js
    click/trunk/click/examples/webapp/ajax/ajax-customer.htm
    click/trunk/click/examples/webapp/ajax/ajax-live-scroller.htm
    click/trunk/click/examples/webapp/ajax/ajax-live-scroller.js
    click/trunk/click/examples/webapp/ajax/ajax-select.htm
    click/trunk/click/examples/webapp/ajax/ajax-select.js
    click/trunk/click/examples/webapp/ajax/basic-ajax-demo.htm
Modified:
    click/trunk/click/examples/src/org/apache/click/examples/page/pageflow/StartPage.java
    click/trunk/click/examples/webapp/WEB-INF/menu.xml

Copied: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxDemoPage.java (from r953978, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/BasicAjaxDemoPage.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxDemoPage.java?p2=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxDemoPage.java&p1=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/BasicAjaxDemoPage.java&r1=953978&r2=962419&rev=962419&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/BasicAjaxDemoPage.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxDemoPage.java Fri Jul  9 05:53:56 2010
@@ -18,8 +18,6 @@
  */
 package org.apache.click.examples.page.ajax;
 
-import java.util.HashMap;
-import java.util.Map;
 import org.apache.click.Control;
 import org.apache.click.Partial;
 import org.apache.click.ajax.AjaxBehavior;
@@ -29,13 +27,13 @@ import org.apache.click.examples.page.Bo
 /**
  * Basic BasicAjaxDemoPage example using the jQuery JavaScript library.
  */
-public class BasicAjaxDemoPage extends BorderPage {
+public class AjaxDemoPage extends BorderPage {
 
     private static final long serialVersionUID = 1L;
 
     private ActionLink link = new ActionLink("link", "here");
 
-    public BasicAjaxDemoPage() {
+    public AjaxDemoPage() {
         link.setId("link-id");
 
         addControl(link);
@@ -49,8 +47,9 @@ public class BasicAjaxDemoPage extends B
                 // Formatted date instance that will be added to the
                 String now = format.currentDate("MMM, yyyy dd HH:MM:ss");
 
-                // Return a partial containing the formatted date
-                return new Partial(now, Partial.HTML);
+                String msg = "AjaxBehavior <tt>onAction()</tt> method invoked at: " + now;
+                // Return a partial containing the message
+                return new Partial(msg, Partial.HTML);
             }
         });
     }

Copied: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/accordion/AjaxAccordion.java (from r947955, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxAccordion.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/accordion/AjaxAccordion.java?p2=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/accordion/AjaxAccordion.java&p1=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxAccordion.java&r1=947955&r2=962419&rev=962419&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxAccordion.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/accordion/AjaxAccordion.java Fri Jul  9 05:53:56 2010
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.click.examples.page.ajax;
+package org.apache.click.examples.page.ajax.accordion;
 
 import java.util.HashMap;
 import java.util.List;
@@ -47,11 +47,12 @@ public class AjaxAccordion extends Borde
 
             // Note the actual JavaScript necessary to setup the accordion is
             // specified in the Page JavaScript template -> ajax-accordion.js.
-            headElements.add(new JsScript("/ajax/ajax-accordion.js", new HashMap()));
+            headElements.add(new JsScript("/ajax/accordion/ajax-accordion.js", new HashMap()));
 
             // Alternatively, the JsScript below could be used to add
             // the necessary JavaScript to setup the accordion, for example:
-            /* String content =
+            /*
+            String content =
                 "$(document).ready(function() {"
               + "  $('#accordion').tabs('#accordion div', {"
               + "    tabs: 'h2',"

Added: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JavascriptAjaxDemoPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JavascriptAjaxDemoPage.java?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JavascriptAjaxDemoPage.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JavascriptAjaxDemoPage.java Fri Jul  9 05:53:56 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.click.examples.page.ajax.compare;
+
+import org.apache.click.Control;
+import org.apache.click.Partial;
+import org.apache.click.ajax.AjaxBehavior;
+import org.apache.click.control.ActionLink;
+import org.apache.click.examples.page.BorderPage;
+
+/**
+ * An Ajax example using JavaScript instead of a library such as jQuery, Prototype etc.
+ */
+public class JavascriptAjaxDemoPage extends BorderPage {
+
+    private static final long serialVersionUID = 1L;
+
+    private ActionLink link = new ActionLink("link", "Make Ajax Request");
+
+    public JavascriptAjaxDemoPage() {
+        link.setId("link-id");
+
+        addControl(link);
+
+        // Add an Ajax behavior to the link. The behavior will be invoked when the
+        // link is clicked. See the basic-ajax-demo.htm template for the client-side
+        // Ajax code
+        link.addBehavior(new AjaxBehavior() {
+
+            public Partial onAction(Control source) {
+                // Formatted date instance that will be added to the
+                String now = format.currentDate("MMM, yyyy dd HH:MM:ss");
+
+                String msg = "Hello from JavaScript at: " + now;
+                // Return a partial containing the message
+                return new Partial(msg, Partial.HTML);
+            }
+        });
+    }
+}

Added: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JqueryAjaxDemoPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JqueryAjaxDemoPage.java?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JqueryAjaxDemoPage.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/JqueryAjaxDemoPage.java Fri Jul  9 05:53:56 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.click.examples.page.ajax.compare;
+
+import org.apache.click.Control;
+import org.apache.click.Partial;
+import org.apache.click.ajax.AjaxBehavior;
+import org.apache.click.control.ActionLink;
+import org.apache.click.examples.page.BorderPage;
+
+/**
+ * An Ajax example using jQuery library.
+ */
+public class JqueryAjaxDemoPage extends BorderPage {
+
+    private static final long serialVersionUID = 1L;
+
+    private ActionLink link = new ActionLink("link", "Make Ajax Request");
+
+    public JqueryAjaxDemoPage() {
+        link.setId("link-id");
+
+        addControl(link);
+
+        // Add an Ajax behavior to the link. The behavior will be invoked when the
+        // link is clicked. See the basic-ajax-demo.htm template for the client-side
+        // Ajax code
+        link.addBehavior(new AjaxBehavior() {
+
+            public Partial onAction(Control source) {
+                // Formatted date instance that will be added to the
+                String now = format.currentDate("MMM, yyyy dd HH:MM:ss");
+
+                String msg = "Hello from jQuery at: " + now;
+                // Return a partial containing the message
+                return new Partial(msg, Partial.HTML);
+            }
+        });
+    }
+}

Added: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/PrototypeAjaxDemoPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/PrototypeAjaxDemoPage.java?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/PrototypeAjaxDemoPage.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/compare/PrototypeAjaxDemoPage.java Fri Jul  9 05:53:56 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.click.examples.page.ajax.compare;
+
+import org.apache.click.Control;
+import org.apache.click.Partial;
+import org.apache.click.ajax.AjaxBehavior;
+import org.apache.click.control.ActionLink;
+import org.apache.click.examples.page.BorderPage;
+
+/**
+ * An Ajax example using Prototype library.
+ */
+public class PrototypeAjaxDemoPage extends BorderPage {
+
+    private static final long serialVersionUID = 1L;
+
+    private ActionLink link = new ActionLink("link", "Make Ajax Request");
+
+    public PrototypeAjaxDemoPage() {
+        link.setId("link-id");
+
+        addControl(link);
+
+        // Add an Ajax behavior to the link. The behavior will be invoked when the
+        // link is clicked. See the basic-ajax-demo.htm template for the client-side
+        // Ajax code
+        link.addBehavior(new AjaxBehavior() {
+
+            public Partial onAction(Control source) {
+                // Formatted date instance that will be added to the
+                String now = format.currentDate("MMM, yyyy dd HH:MM:ss");
+
+                String msg = "Hello from Prototype at: " + now;
+                // Return a partial containing the message
+                return new Partial(msg, Partial.HTML);
+            }
+        });
+    }
+}

Added: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/form/FormAjaxDemoPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/form/FormAjaxDemoPage.java?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/form/FormAjaxDemoPage.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/form/FormAjaxDemoPage.java Fri Jul  9 05:53:56 2010
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.click.examples.page.ajax.form;
+
+import java.util.HashMap;
+import java.util.List;
+import org.apache.click.Control;
+import org.apache.click.Partial;
+import org.apache.click.ajax.AjaxBehavior;
+import org.apache.click.control.Form;
+import org.apache.click.control.Submit;
+import org.apache.click.control.TextField;
+import org.apache.click.element.Element;
+import org.apache.click.element.JsImport;
+import org.apache.click.element.JsScript;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.extras.control.DateField;
+import org.apache.click.extras.control.IntegerField;
+
+/**
+ * Basic Form Ajax Demo example using the jQuery JavaScript library.
+ */
+public class FormAjaxDemoPage extends BorderPage {
+
+    private static final long serialVersionUID = 1L;
+
+    private Form form = new Form("form");
+
+    private TextField nameField = new TextField("name", true);
+    private IntegerField ageField = new IntegerField("age");
+    private DateField dateField = new DateField("date");
+
+    private Submit save = new Submit("save");
+    private Submit cancel = new Submit("cancel");
+
+    public FormAjaxDemoPage() {
+        addControl(form);
+        form.add(nameField);
+        form.add(ageField);
+        form.add(dateField);
+        form.add(save);
+        form.add(cancel);
+
+        save.addBehavior(new AjaxBehavior() {
+
+            @Override
+            public Partial onAction(Control source) {
+                // Update the form which might contain errors
+                return new Partial(form.toString(), Partial.HTML);
+            }
+        });
+
+        cancel.addBehavior(new AjaxBehavior() {
+
+            @Override
+            public Partial onAction(Control source) {
+                // Update the form and ensure errors and values have been cleared
+                form.clearValues();
+                form.clearErrors();
+                return new Partial(form.toString(), Partial.HTML);
+            }
+        });
+
+        // NOTE: we add a Behavior to Form so that Click registers the Form as an Ajax target
+        // ALSO NOTE: we don't implement the onAction method as the save and cancel Submits
+        // handles the Behavior action event
+        form.addBehavior(new AjaxBehavior());
+    }
+
+    @Override
+    public List<Element> getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+            headElements.add(new JsImport("/assets/js/jquery-1.3.2.js"));
+            headElements.add(new JsScript("/ajax/form/form-ajax-demo.js", new HashMap()));
+        }
+        return headElements;
+    }
+}

Added: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/scroller/AjaxLiveScroller.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/scroller/AjaxLiveScroller.java?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/scroller/AjaxLiveScroller.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/scroller/AjaxLiveScroller.java Fri Jul  9 05:53:56 2010
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.click.examples.page.ajax.scroller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Resource;
+import org.apache.click.Partial;
+
+import org.apache.click.element.Element;
+import org.apache.click.element.JsImport;
+import org.apache.click.element.JsScript;
+import org.apache.click.examples.domain.Customer;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.service.CustomerService;
+import org.apache.click.util.ClickUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.springframework.stereotype.Component;
+
+/**
+ * Demonstrates how to to dynamically load more customer while scrolling down
+ * the Page. An Ajax request is made to a pageAction that sends back the new
+ * customers to display.
+ */
+@Component
+public class AjaxLiveScroller extends BorderPage {
+
+    private static final long serialVersionUID = 1L;
+
+    @Resource(name="customerService")
+    private CustomerService customerService;
+
+    // Specifies the number of customers to retrieve at a time
+    private int pageSize = 10;
+
+    @Override
+    public void onInit() {
+        super.onInit();
+        int offset = 0;
+        List<Customer> customers = loadCustomers(offset, pageSize);
+        addModel("customers", customers);
+    }
+
+    /**
+     * A pageAction method that is called when the user scrolled to the bottom
+     * of the page and more data is needed.
+     */
+    public Partial onScroll() {
+        // Check if the offset parameter was received.
+        int offset = NumberUtils.toInt(getContext().getRequest().getParameter("offset"));
+
+        List<Customer> customers = loadCustomers(offset, pageSize);
+
+        // Return customers between the given offset and pageSize
+        Map partialModel = new HashMap();
+        partialModel.put("customers", customers);
+        partialModel.put("format", getFormat());
+
+        // Return a partial for the customers.htm template and customers
+        Partial partial = new Partial("/ajax/scroller/customers.htm", partialModel, Partial.HTML);
+        return partial;
+    }
+
+    @Override
+    public List<Element> getHeadElements() {
+        // Lazily load head elements and ensure they are only loaded once
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            // Add the jQuery library
+            headElements.add(new JsImport("/assets/js/jquery-1.3.2.js"));
+
+            // Create a default model and add the pageSize variable to pass to
+            // the JavaScript template: ajax-live-scroller.js
+            Map<String, Object> jsModel = ClickUtils.createTemplateModel(this, getContext());
+            jsModel.put("pageSize", pageSize);
+
+            // Note the actual JavaScript necessary to setup the dynamic scrolling
+            // is specified in the Page JavaScript template: ajax-live-scroller.js.
+            headElements.add(new JsScript("/ajax/scroller/ajax-live-scroller.js", jsModel));
+        }
+        return headElements;
+    }
+
+    private List<Customer> loadCustomers(int offset, int pageSize) {
+        return customerService.getTopCustomersForPage(offset, pageSize);
+    }
+}

Copied: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxCustomer.java (from r947955, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxCustomer.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxCustomer.java?p2=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxCustomer.java&p1=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxCustomer.java&r1=947955&r2=962419&rev=962419&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxCustomer.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxCustomer.java Fri Jul  9 05:53:56 2010
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.click.examples.page.ajax;
+package org.apache.click.examples.page.ajax.select;
 
 import javax.annotation.Resource;
 

Copied: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxSelect.java (from r947955, click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxSelect.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxSelect.java?p2=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxSelect.java&p1=click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxSelect.java&r1=947955&r2=962419&rev=962419&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/AjaxSelect.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/select/AjaxSelect.java Fri Jul  9 05:53:56 2010
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.click.examples.page.ajax;
+package org.apache.click.examples.page.ajax.select;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -25,12 +25,16 @@ import java.util.Map;
 import javax.annotation.Resource;
 
 import org.apache.click.Context;
+import org.apache.click.Control;
+import org.apache.click.Partial;
+import org.apache.click.ajax.AjaxBehavior;
 import org.apache.click.control.Option;
 import org.apache.click.control.Select;
 import org.apache.click.dataprovider.DataProvider;
 import org.apache.click.element.Element;
 import org.apache.click.element.JsImport;
 import org.apache.click.element.JsScript;
+import org.apache.click.examples.control.ajax.CustomerPanel;
 import org.apache.click.examples.domain.Customer;
 import org.apache.click.examples.page.BorderPage;
 import org.apache.click.examples.service.CustomerService;
@@ -53,6 +57,25 @@ public class AjaxSelect extends BorderPa
 
     // Event Handlers ---------------------------------------------------------
 
+    // A pageAction that handles Ajax requests for a particular customer
+    public Partial onChangeCustomer() {
+        Partial partial = new Partial();
+
+        // Lookup customer based on request parameter 'customerId'
+        String customerId = getContext().getRequest().getParameter("customerId");
+        Customer customer = customerService.findCustomerByID(customerId);
+
+        // CustomerPanel will render the customer as an HTML snippet
+        CustomerPanel customerPanel = new CustomerPanel(this, customer);
+        partial.setContent(customerPanel.toString());
+
+        // Set content type and character encoding
+        partial.setCharacterEncoding("UTF-8");
+        partial.setContentType(Partial.HTML);
+
+        return partial;
+    }
+
     @Override
     public void onInit() {
         super.onInit();
@@ -88,9 +111,6 @@ public class AjaxSelect extends BorderPa
             // $context, $path, $selector and $target
             Map<String, Object> model = ClickUtils.createTemplateModel(this, context);
 
-            // Set path to the AjaxCustomer Page path
-            model.put("path", context.getPagePath(AjaxCustomer.class));
-
             // Add a CSS selector, in this case the customerSelect ID attribute
             model.put("selector", customerSelect.getId());
 
@@ -99,7 +119,7 @@ public class AjaxSelect extends BorderPa
             model.put("target", "customerDetails");
 
             // Include the Page associated JavaScript template
-            headElements.add(new JsScript("/ajax/ajax-select.js", model));
+            headElements.add(new JsScript("/ajax/select/ajax-select.js", model));
         }
 
         return headElements;

Added: click/trunk/click/examples/src/org/apache/click/examples/page/ajax/table/TableAjaxDemoPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/ajax/table/TableAjaxDemoPage.java?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/ajax/table/TableAjaxDemoPage.java (added)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/ajax/table/TableAjaxDemoPage.java Fri Jul  9 05:53:56 2010
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.click.examples.page.ajax.table;
+
+import java.util.HashMap;
+import java.util.List;
+import javax.annotation.Resource;
+import org.apache.click.Control;
+import org.apache.click.Partial;
+import org.apache.click.ajax.AjaxBehavior;
+import org.apache.click.control.ActionLink;
+import org.apache.click.control.Column;
+import org.apache.click.control.Table;
+import org.apache.click.dataprovider.DataProvider;
+import org.apache.click.element.Element;
+import org.apache.click.element.JsImport;
+import org.apache.click.element.JsScript;
+import org.apache.click.examples.domain.Customer;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.service.CustomerService;
+import org.apache.click.extras.control.LinkDecorator;
+import org.springframework.stereotype.Component;
+
+/**
+ * Basic Table Ajax Demo example using the jQuery JavaScript library.
+ */
+@Component
+public class TableAjaxDemoPage extends BorderPage {
+
+    private static final long serialVersionUID = 1L;
+
+    private Table table = new Table("table");
+
+    private ActionLink editLink = new ActionLink("edit", "Edit", this, "onEditClick");
+    private ActionLink deleteLink = new ActionLink("delete", "Delete", this, "onDeleteClick");
+
+    @Resource(name="customerService")
+    private CustomerService customerService;
+
+    public TableAjaxDemoPage() {
+        addControl(editLink);
+        editLink.addBehavior(new AjaxBehavior() {
+
+            @Override
+            public Partial onAction(Control source) {
+                Customer customer = customerService.getCustomerForID(editLink.getValue());
+                return new Partial("Edit Clicked for customer: " + customer.getName(), Partial.TEXT);
+            }
+        });
+
+        addControl(deleteLink);
+        deleteLink.addBehavior(new AjaxBehavior() {
+
+            @Override
+            public Partial onAction(Control source) {
+                Customer customer = customerService.getCustomerForID(deleteLink.getValue());
+                return new Partial("Delete Clicked for customer: " + customer.getName(), Partial.TEXT);
+            }
+        });
+
+        addControl(table);
+
+        // Setup customers table
+        table.setClass(Table.CLASS_ISI);
+        table.setPageSize(4);
+        table.setShowBanner(true);
+        table.setSortable(true);
+
+        Column column = new Column("name");
+        column.setWidth("140px;");
+        table.addColumn(column);
+
+        column = new Column("email");
+        column.setAutolink(true);
+        column.setWidth("230px;");
+        table.addColumn(column);
+
+        column = new Column("age");
+        column.setTextAlign("center");
+        column.setWidth("40px;");
+        table.addColumn(column);
+
+        column = new Column("holdings");
+        column.setFormat("${0,number,#,##0.00}");
+        column.setTextAlign("right");
+        column.setWidth("100px;");
+        table.addColumn(column);
+
+        column = new Column("Action");
+        column.setSortable(false);
+        ActionLink[] links = new ActionLink[]{editLink, deleteLink};
+        column.setDecorator(new LinkDecorator(table, links, "id"));
+        table.addColumn(column);
+
+        table.setDataProvider(new DataProvider<Customer>() {
+            public List<Customer> getData() {
+                return customerService.getCustomers();
+            }
+        });
+    }
+
+    @Override
+    public List<Element> getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+            headElements.add(new JsImport("/assets/js/jquery-1.3.2.js"));
+            headElements.add(new JsScript("/ajax/table/table-ajax-demo.js", new HashMap()));
+        }
+        return headElements;
+    }
+}

Modified: click/trunk/click/examples/src/org/apache/click/examples/page/pageflow/StartPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/pageflow/StartPage.java?rev=962419&r1=962418&r2=962419&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/pageflow/StartPage.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/pageflow/StartPage.java Fri Jul  9 05:53:56 2010
@@ -1,201 +1,217 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.click.examples.page.pageflow;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-
-import org.apache.click.Context;
-import org.apache.click.control.Form;
-import org.apache.click.control.Option;
-import org.apache.click.control.Select;
-import org.apache.click.control.Submit;
-import org.apache.click.control.TextArea;
-import org.apache.click.dataprovider.DataProvider;
-import org.apache.click.element.Element;
-import org.apache.click.element.JsImport;
-import org.apache.click.element.JsScript;
-import org.apache.click.examples.control.InvestmentSelect;
-import org.apache.click.examples.domain.CourseBooking;
-import org.apache.click.examples.domain.Customer;
-import org.apache.click.examples.page.BorderPage;
-import org.apache.click.examples.page.HomePage;
-import org.apache.click.examples.page.ajax.AjaxCustomer;
-import org.apache.click.examples.service.CustomerService;
-import org.apache.click.extras.control.DateField;
-import org.apache.click.util.Bindable;
-import org.apache.click.util.ClickUtils;
-import org.springframework.stereotype.Component;
-
-/**
- * Provides the start page of a multi page work flow.
- */
-@Component
-public class StartPage extends BorderPage {
-
-    private static final long serialVersionUID = 1L;
-
-    @Bindable protected Form form = new Form();
-
-    private Select customerSelect;
-    private DateField dateField;
-    private Select courseSelect;
-    private TextArea notesField;
-
-    private CourseBooking courseBooking;
-
-    @Resource(name="customerService")
-    private CustomerService customerService;
-
-    // Constructor ------------------------------------------------------------
-
-    public StartPage() {
-        form.setLabelsPosition("top");
-
-        customerSelect = new Select("Customer");
-        customerSelect.setRequired(true);
-        form.add(customerSelect);
-
-        customerSelect.setDefaultOption(Option.EMPTY_OPTION);
-        customerSelect.setDataProvider(new DataProvider() {
-
-            public List getData() {
-                List<Option> optionList = new ArrayList<Option>();
-                List<Customer> customerList = customerService.getCustomers();
-                for (Customer customer : customerList) {
-                    optionList.add(new Option(customer.getId(),
-                                                  customer.getName()));
-                }
-                return optionList;
-            }
-        });
-
-        dateField = new DateField("Booking Date");
-        dateField.setRequired(true);
-        form.add(dateField);
-
-        courseSelect = new InvestmentSelect("Course");
-        courseSelect.setRequired(true);
-        form.add(courseSelect);
-
-        notesField = new TextArea("Booking Notes");
-        notesField.setCols(25);
-        form.add(notesField);
-
-        form.add(new Submit(" < Back ", this, "onBackClick"));
-        form.add(new Submit(" Next > ", this, "onNextClick"));
-    }
-
-    // Event Handlers ---------------------------------------------------------
-
-    /**
-     * @see org.apache.click.Page#onSecurityCheck()
-     */
-    @Override
-    public boolean onSecurityCheck() {
-        return form.onSubmitCheck(this, "/pageflow/invalid-submit.html");
-    }
-
-    /**
-     * @see org.apache.click.Page#onInit()
-     */
-    @Override
-    public void onInit() {
-        super.onInit();
-
-        if (getContext().isForward() && courseBooking != null) {
-            customerSelect.setValueObject(courseBooking.getCustomerId());
-            dateField.setDate(courseBooking.getBookingDate());
-            courseSelect.setValue(courseBooking.getCourseType());
-            notesField.setValue(courseBooking.getBookingNotes());
-        }
-    }
-
-    public boolean onBackClick() {
-        setRedirect(HomePage.class);
-        return false;
-    }
-
-    public boolean onNextClick() {
-        if (form.isValid()) {
-            Integer customerId = new Integer(customerSelect.getValue());
-
-            CourseBooking courseBooking = new CourseBooking();
-            courseBooking.setCustomerId(customerId);
-            courseBooking.setBookingDate(dateField.getDate());
-            courseBooking.setCourseType(courseSelect.getValue());
-            courseBooking.setBookingNotes(notesField.getValue());
-
-            NextPage nextPage = getContext().createPage(NextPage.class);
-            nextPage.setCourseBooking(courseBooking);
-
-            setForward(nextPage);
-            return false;
-        }
-        return true;
-    }
-
-    // Public Methods ---------------------------------------------------------
-
-    /**
-     * Return the Page JavaScript resources.
-     *
-     * @see org.apache.click.Page#getHeadElements()
-     */
-    @Override
-    public List<Element> getHeadElements() {
-        if (headElements == null) {
-            headElements = super.getHeadElements();
-
-            // Include the prototype.js library which is made available under
-            // the web folder "/click/prototype/"
-            headElements.add(new JsImport("/click/prototype/prototype.js"));
-
-            Context context = getContext();
-
-            // Create a model to pass to the Page JavaScript template. The
-            // template recognizes the following Velocity variables:
-            // $context, $path, $selector and $target
-            Map<String, Object> model = ClickUtils.createTemplateModel(this, context);
-
-            // Set path to the AjaxCustomer Page path
-            model.put("path", context.getPagePath(AjaxCustomer.class));
-
-            // Add a CSS selector, in this case the customerSelect ID attribute
-            model.put("selector", customerSelect.getId());
-
-            // Add the ID of a target element in the Page template to replace
-            // with new data, in this example the target is 'customerDetails'
-            model.put("target", "customerDetails");
-
-            // Include the ajax-select.js template
-            headElements.add(new JsScript("/ajax/ajax-select.js", model));
-        }
-
-        return headElements;
-    }
-
-    public void setCourseBooking(CourseBooking courseBooking) {
-        this.courseBooking = courseBooking;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.click.examples.page.pageflow;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.apache.click.Context;
+import org.apache.click.Partial;
+import org.apache.click.control.Form;
+import org.apache.click.control.Option;
+import org.apache.click.control.Select;
+import org.apache.click.control.Submit;
+import org.apache.click.control.TextArea;
+import org.apache.click.dataprovider.DataProvider;
+import org.apache.click.element.Element;
+import org.apache.click.element.JsImport;
+import org.apache.click.element.JsScript;
+import org.apache.click.examples.control.InvestmentSelect;
+import org.apache.click.examples.control.ajax.CustomerPanel;
+import org.apache.click.examples.domain.CourseBooking;
+import org.apache.click.examples.domain.Customer;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.examples.page.HomePage;
+import org.apache.click.examples.service.CustomerService;
+import org.apache.click.extras.control.DateField;
+import org.apache.click.util.Bindable;
+import org.apache.click.util.ClickUtils;
+import org.springframework.stereotype.Component;
+
+/**
+ * Provides the start page of a multi page work flow.
+ */
+@Component
+public class StartPage extends BorderPage {
+
+    private static final long serialVersionUID = 1L;
+
+    @Bindable protected Form form = new Form();
+
+    private Select customerSelect;
+    private DateField dateField;
+    private Select courseSelect;
+    private TextArea notesField;
+
+    private CourseBooking courseBooking;
+
+    @Resource(name="customerService")
+    private CustomerService customerService;
+
+    // Constructor ------------------------------------------------------------
+
+    public StartPage() {
+        form.setLabelsPosition("top");
+
+        customerSelect = new Select("Customer");
+        customerSelect.setRequired(true);
+        form.add(customerSelect);
+
+        customerSelect.setDefaultOption(Option.EMPTY_OPTION);
+        customerSelect.setDataProvider(new DataProvider() {
+
+            public List getData() {
+                List<Option> optionList = new ArrayList<Option>();
+                List<Customer> customerList = customerService.getCustomers();
+                for (Customer customer : customerList) {
+                    optionList.add(new Option(customer.getId(), customer.getName()));
+                }
+                return optionList;
+            }
+        });
+
+        dateField = new DateField("Booking Date");
+        dateField.setRequired(true);
+        form.add(dateField);
+
+        courseSelect = new InvestmentSelect("Course");
+        courseSelect.setRequired(true);
+        form.add(courseSelect);
+
+        notesField = new TextArea("Booking Notes");
+        notesField.setCols(25);
+        form.add(notesField);
+
+        form.add(new Submit(" < Back ", this, "onBackClick"));
+        form.add(new Submit(" Next > ", this, "onNextClick"));
+    }
+
+    // Event Handlers ---------------------------------------------------------
+
+    /**
+     * @see org.apache.click.Page#onSecurityCheck()
+     */
+    @Override
+    public boolean onSecurityCheck() {
+        return form.onSubmitCheck(this, "/pageflow/invalid-submit.html");
+    }
+
+    // A pageAction that handles Ajax requests for a particular customer
+    public Partial onChangeCustomer() {
+        Partial partial = new Partial();
+
+        // Lookup customer based on request parameter 'customerId'
+        String customerId = getContext().getRequest().getParameter("customerId");
+        Customer customer = customerService.findCustomerByID(customerId);
+
+        // CustomerPanel will render the customer as an HTML snippet
+        CustomerPanel customerPanel = new CustomerPanel(this, customer);
+        partial.setContent(customerPanel.toString());
+
+        // Set content type and character encoding
+        partial.setCharacterEncoding("UTF-8");
+        partial.setContentType(Partial.HTML);
+
+        return partial;
+    }
+
+    /**
+     * @see org.apache.click.Page#onInit()
+     */
+    @Override
+    public void onInit() {
+        super.onInit();
+
+        if (getContext().isForward() && courseBooking != null) {
+            customerSelect.setValueObject(courseBooking.getCustomerId());
+            dateField.setDate(courseBooking.getBookingDate());
+            courseSelect.setValue(courseBooking.getCourseType());
+            notesField.setValue(courseBooking.getBookingNotes());
+        }
+    }
+
+    public boolean onBackClick() {
+        setRedirect(HomePage.class);
+        return false;
+    }
+
+    public boolean onNextClick() {
+        if (form.isValid()) {
+            Integer customerId = new Integer(customerSelect.getValue());
+
+            CourseBooking courseBooking = new CourseBooking();
+            courseBooking.setCustomerId(customerId);
+            courseBooking.setBookingDate(dateField.getDate());
+            courseBooking.setCourseType(courseSelect.getValue());
+            courseBooking.setBookingNotes(notesField.getValue());
+
+            NextPage nextPage = getContext().createPage(NextPage.class);
+            nextPage.setCourseBooking(courseBooking);
+
+            setForward(nextPage);
+            return false;
+        }
+        return true;
+    }
+
+    // Public Methods ---------------------------------------------------------
+
+    /**
+     * Return the Page JavaScript resources.
+     *
+     * @see org.apache.click.Page#getHeadElements()
+     */
+    @Override
+    public List<Element> getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            // Include the prototype.js library which is made available under
+            // the web folder "/click/prototype/"
+            headElements.add(new JsImport("/click/prototype/prototype.js"));
+
+            Context context = getContext();
+
+            // Create a model to pass to the Page JavaScript template. The
+            // template recognizes the following Velocity variables:
+            // $context, $path, $selector and $target
+            Map<String, Object> jsModel = ClickUtils.createTemplateModel(this, context);
+
+            // Add a CSS selector, in this case the customerSelect ID attribute
+            jsModel.put("selector", customerSelect.getId());
+
+            // Add the ID of a target element in the Page template to replace
+            // with new data, in this example the target is 'customerDetails'
+            jsModel.put("target", "customerDetails");
+
+            // Include the ajax-select.js template
+            headElements.add(new JsScript("/ajax/select/ajax-select.js", jsModel));
+        }
+
+        return headElements;
+    }
+
+    public void setCourseBooking(CourseBooking courseBooking) {
+        this.courseBooking = courseBooking;
+    }
+
+}

Modified: click/trunk/click/examples/webapp/WEB-INF/menu.xml
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/WEB-INF/menu.xml?rev=962419&r1=962418&r2=962419&view=diff
==============================================================================
--- click/trunk/click/examples/webapp/WEB-INF/menu.xml (original)
+++ click/trunk/click/examples/webapp/WEB-INF/menu.xml Fri Jul  9 05:53:56 2010
@@ -139,11 +139,20 @@
   </menu>
 
   <menu label="Ajax" path="#" imageSrc="/assets/images/lightning.png">
-    <menu label="Basic AJAX Demo" path="ajax/basic-ajax-demo.htm"/>
-    <menu label="AJAX Accordion" path="ajax/ajax-accordion.htm"/>
+    <menu label="AJAX Demo" path="ajax/ajax-demo.htm"/>
+    <menu separator="true"/>
+    <menu label="JavaScript AJAX Demo" path="ajax/compare/javascript-ajax-demo.htm"/>
+    <menu label="jQuery AJAX Demo" path="ajax/compare/jquery-ajax-demo.htm"/>
+    <menu label="Prototype AJAX Demo" path="ajax/compare/prototype-ajax-demo.htm"/>
+    <menu separator="true"/>
+    <menu label="Table AJAX Demo" path="ajax/table/table-ajax-demo.htm"/>
+    <menu separator="true"/>
+    <menu label="Form AJAX Demo" path="ajax/form/form-ajax-demo.htm"/>
+    <menu separator="true"/>
+    <menu label="AJAX Accordion" path="ajax/accordion/ajax-accordion.htm"/>
     <menu label="AJAX Auto Complete Field" path="ajax/auto-complete.htm"/>
-    <menu label="AJAX Live Scroller " path="ajax/ajax-live-scroller.htm"/>
-    <menu label="AJAX Select" path="ajax/ajax-select.htm"/>
+    <menu label="AJAX Live Scroller " path="ajax/scroller/ajax-live-scroller.htm"/>
+    <menu label="AJAX Select" path="ajax/select/ajax-select.htm"/>
   </menu>
 
   <menu label=" Integration" path="#" imageSrc="/assets/images/cayenne.png">

Added: click/trunk/click/examples/webapp/ajax/ajax-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/ajax-demo.htm?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/ajax-demo.htm (added)
+++ click/trunk/click/examples/webapp/ajax/ajax-demo.htm Fri Jul  9 05:53:56 2010
@@ -0,0 +1,40 @@
+<script type="text/javascript" src="$context/assets/js/jquery-1.3.2.js"></script>
+
+<script type="text/javascript">
+    // This example uses jQuery for making Ajax requests:
+    // http://api.jquery.com/jQuery.get/
+    // http://api.jquery.com/jQuery.ajax/
+
+    // Register a function that is invoked as soon as the DOM is loaded
+    jQuery(document).ready(function() {
+
+        // Register a 'click' handler that makes an Ajax request
+        jQuery("#link-id").click(function(event){
+            // Make ajax request
+            makeRequest();
+
+            // Prevent the default browser behavior of navigating to the link
+            event.preventDefault();
+        })
+    })
+
+    function makeRequest() {
+        var link = jQuery('#link-id');
+        var extraData = link.attr('id') + '=1';
+        var url = link.attr('href');
+        jQuery.get(url, extraData, function(data) {
+            // The data argument is the formatted date instance returned
+            // by the page Partial response.
+
+            // Here we select the div element with the ID 'result' and set its
+            // content to the server date
+            jQuery("#result").html("<p class='infoMsg'>" + data + "</p>");
+        });
+    }
+</script>
+
+Click $link to fetch the date using Ajax.
+
+<div id="result">
+    <!-- Ajax response will be set here -->
+</div>
\ No newline at end of file

Added: click/trunk/click/examples/webapp/ajax/compare/javascript-ajax-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/compare/javascript-ajax-demo.htm?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/compare/javascript-ajax-demo.htm (added)
+++ click/trunk/click/examples/webapp/ajax/compare/javascript-ajax-demo.htm Fri Jul  9 05:53:56 2010
@@ -0,0 +1,91 @@
+<p>
+    Demonstrates Click Ajax support using JavaScript. Compare this implementation
+    with the <a href="$context/ajax/compare/jquery-ajax-demo.htm">jQuery</a> and
+    <a href="$context/ajax/compare/prototype-ajax-demo.htm">Prototype</a> demos.
+</p>
+
+$link
+
+<div id="target">
+<!-- Ajax response will be set here -->
+</div>
+
+<script type="text/javascript">
+    // Find the link via its ID attribute
+    var el = document.getElementById("link-id");
+
+    // Register an onclick listener that will make an Ajax request
+    if (el.addEventListener) {
+        // Standard event listener
+        el.addEventListener ("click", makeAjaxRequest, false);
+    } else if (el.attachEvent) {
+        // IE event listener
+        el.attachEvent ("onclick", makeAjaxRequest);
+    } else {
+        // Fallback event listener
+        el.onclick = makeAjaxRequest;
+    }
+
+    // Function to make Ajax request
+    function makeAjaxRequest(event) {
+        if(!event)
+            // IE doesn't pass event, instead event is available from window
+            event = window.event;
+
+        // The URL to make the Ajax request on should include enough information
+        // for Click to identify the target Ajax control and how to process the control.
+        // Normally Click uses the Control ID to identify the Ajax target. Here the
+        // target Control is the ActionLink with ID: 'link-id'. The ID parameter is appended to
+        // the url with a value of 1. The value is actually ignored by Click so it is optional
+        // and can be left out.
+        //
+        // Once Click identifies the target control it invokes that Control onProcess method.
+        // Simply processing a control is normally not enough to fire registered AjaxBehaviors.
+        // For example ActionLinks fire off their Behaviors (or ActionListener for non Ajax requests)
+        // based the value of the predefined parameter: 'actionLink'. The 'actionLink' parameter
+        // value specifies the name of the ActionLink that was clicked. So we append
+        // the 'actionLink' parameter and set the value as the ActionLink name -> 'link'.
+        var url = "$context/ajax/compare/javascript-ajax-demo.htm?" + "link-id=1&actionLink=link";
+
+        // The above example is for demonstration purposes only. Normally you can generify the URL by using
+        // the link 'href' and 'id' attributes as the URL. The link href already contains the server URL,
+        // actionLink, value and extra link parameters.
+        // var url = el.getAttribute("href") + '&' + el.getAttribute("id") + '=1';
+
+        // Create hthe XMLHttpRequest object. Not all IE versions support XMLHttpRequest so check for ActiveXObject
+        var request = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
+        request.open("POST", url, true);
+
+        // Set content-type header
+        request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+
+        // Set the X-Requested-With header. This way Click knows its an Ajax request.
+        // This header is the de-facto standard; most Ajax libraries such as Prototype, JQuery, Mootools, YUI
+        // set this header
+        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+
+        request.onreadystatechange = function() {
+            // request.readystate of 4 means the Ajax request is complete and the response has been received
+            // request.status of 200 means the request was successful
+            if (request.readyState == 4 && request.status == 200) {
+                if (request.responseText) {
+                    updateLog(request.responseText);
+                }
+            }
+        };
+        request.send();
+
+        // Prevent the default link action and do nothing
+        if(event.preventDefault)
+            event.preventDefault();
+        else
+            // IE does not support preventDefault, instead set the returnValue to false
+            event.returnValue = false;
+    }
+
+    function updateLog(response) {
+        var div = document.getElementById("target");
+
+        div.innerHTML = "<p class='infoMsg'>" + response + "</p>";
+    }
+</script>

Added: click/trunk/click/examples/webapp/ajax/compare/jquery-ajax-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/compare/jquery-ajax-demo.htm?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/compare/jquery-ajax-demo.htm (added)
+++ click/trunk/click/examples/webapp/ajax/compare/jquery-ajax-demo.htm Fri Jul  9 05:53:56 2010
@@ -0,0 +1,69 @@
+<p>
+    Demonstrates Click Ajax support using <a target="_blank" href="http://www.jquery.com/">jQuery</a>.
+    Compare this implementation with the <a href="$context/ajax/compare/javascript-ajax-demo.htm">Javascript</a> and
+    <a href="$context/ajax/compare/prototype-ajax-demo.htm">Prototype</a> demos.
+</p>
+
+$link
+
+<div id="target">
+<!-- Ajax response will be set here -->
+</div>
+
+<script type="text/javascript" src="$context/assets/js/jquery-1.3.2.js"></script>
+
+<script type="text/javascript">
+    // This example uses jQuery for making Ajax requests:
+    // http://api.jquery.com/jQuery.get/
+    // http://api.jquery.com/jQuery.ajax/
+
+    // Register a function that is invoked as soon as the DOM is loaded
+    jQuery(document).ready(function() {
+
+        // Register a 'click' handler that makes an Ajax request
+        jQuery("#link-id").click(function(event){
+            // Make ajax request
+            makeRequest();
+
+            // Prevent the default browser behavior of navigating to the link
+            event.preventDefault();
+        })
+    })
+
+    function makeRequest() {
+        // The URL to make the Ajax request on should include enough information
+        // for Click to identify the target Ajax control and how to process the control.
+        // Normally Click uses the Control ID to identify the Ajax target. Here the
+        // target Control is the ActionLink with ID: 'link-id'. The ID parameter is appended to
+        // the url with a value of 1. The value is actually ignored by Click so it is optional
+        // and can be left out.
+        //
+        // Once Click identifies the target control it invokes that Control onProcess method.
+        // Simply processing a control is normally not enough to fire registered AjaxBehaviors.
+        // For example ActionLinks fire off their Behaviors (or ActionListener for non Ajax requests)
+        // based the value of the predefined parameter: 'actionLink'. The 'actionLink' parameter
+        // value specifies the name of the ActionLink that was clicked. So we append
+        // the 'actionLink' parameter and set the value as the ActionLink name -> 'link'.
+        var url = '$context/ajax/compare/javascript-ajax-demo.htm';
+        var extraData = 'link-id=1&actionLink=link';
+        jQuery.get(url, extraData, function(data) {
+            updateLog(data);
+        });
+
+        // The above example is for demonstration purposes only. Normally you can generify the URL by using
+        // the link 'href' and 'id' attributes as the URL. The link href already contains the server URL,
+        // actionLink, value and extra link parameters:
+        /*
+        var link = jQuery('#link-id');
+        var url = link.attr('href');
+        var extraData = link.attr('id') + '=1';
+        jQuery.get(url, extraData, function(data) {
+            updateLog(data);
+        });
+        */
+    }
+
+    function updateLog(data) {
+        jQuery("#target").html("<p class='infoMsg'>" + data + "</p>");
+    }
+</script>

Added: click/trunk/click/examples/webapp/ajax/compare/prototype-ajax-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/compare/prototype-ajax-demo.htm?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/compare/prototype-ajax-demo.htm (added)
+++ click/trunk/click/examples/webapp/ajax/compare/prototype-ajax-demo.htm Fri Jul  9 05:53:56 2010
@@ -0,0 +1,75 @@
+<p>
+    Demonstrates Click Ajax support using <a target="_blank" href="http://www.prototypejs.org/">Prototype</a>.
+    Compare this implementation with the <a href="$context/ajax/compare/javascript-ajax-demo.htm">Javascript</a> and
+    <a href="$context/ajax/compare/jquery-ajax-demo.htm">jQuery</a> demos.
+</p>
+
+$link
+
+<div id="target">
+<!-- Ajax response will be set here -->
+</div>
+
+<script type="text/javascript" src="$context/click/prototype/prototype.js"></script>
+
+<script type="text/javascript">
+    // This example uses Prototype for making Ajax requests:
+    // http://www.prototypejs.org/learn/introduction-to-ajax
+
+    // Register a function that is invoked as soon as the DOM is loaded
+    document.observe("dom:loaded", function() {
+
+        // Register a 'click' handler that makes an Ajax request
+        $('link-id').observe('click', function(event) {
+            // Make ajax request
+            makeRequest();
+
+            // Prevent the default browser behavior of navigating to the link
+            event.preventDefault();
+        })
+    })
+
+    function makeRequest() {
+        // The URL to make the Ajax request on should include enough information
+        // for Click to identify the target Ajax control and how to process the control.
+        // Normally Click uses the Control ID to identify the Ajax target. Here the
+        // target Control is the ActionLink with ID: 'link-id'. The ID parameter is appended to
+        // the url with a value of 1. The value is actually ignored by Click so it is optional
+        // and can be left out.
+        //
+        // Once Click identifies the target control it invokes that Control onProcess method.
+        // Simply processing a control is normally not enough to fire registered AjaxBehaviors.
+        // For example ActionLinks fire off their Behaviors (or ActionListener for non Ajax requests)
+        // based the value of the predefined parameter: 'actionLink'. The 'actionLink' parameter
+        // value specifies the name of the ActionLink that was clicked. So we append
+        // the 'actionLink' parameter and set the value as the ActionLink name -> 'link'.
+        var extraData = 'link-id=1&actionLink=link';
+        var url = '$context/ajax/compare/javascript-ajax-demo.htm';
+        new Ajax.Request(url, {
+            method:'get',
+            parameters: extraData,
+            onSuccess: function(transport){
+                updateLog(transport.responseText);
+            }
+        });
+
+        // The above example is for demonstration purposes only. Normally you can generify the URL by using
+        // the link 'href' and 'id' attributes as the URL. The link href already contains the server URL,
+        // actionLink, value and extra link parameters:
+        /*
+        var link = $('link-id');
+        var url = link.readAttribute('href');
+        var extraData = link.readAttribute('id') + '=1';
+        new Ajax.Request(url, {
+            method:'get',
+            parameters: extraData,
+            onSuccess: function(transport){
+                updateLog(transport.responseText);
+            }
+        });*/
+    }
+
+    function updateLog(data) {
+        $("target").update("<p class='infoMsg'>" + data + "</p>");
+    }
+</script>

Added: click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.htm?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.htm (added)
+++ click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.htm Fri Jul  9 05:53:56 2010
@@ -0,0 +1,3 @@
+<div id="target">
+$form
+</div>

Added: click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.js
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.js?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.js (added)
+++ click/trunk/click/examples/webapp/ajax/form/form-ajax-demo.js Fri Jul  9 05:53:56 2010
@@ -0,0 +1,61 @@
+// #*
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.
+// *#
+
+// This demo uses jQuery but also contains a DateField which depends on Prototype.
+// Below we use jQuery.noConflict() in order for jQuery and Prototype to work together:
+// http://docs.jquery.com/Using_jQuery_with_Other_Libraries
+jQuery.noConflict();
+
+// Generally it is not recommended to use two JavaScript libraries together. Instead
+// it is highly recommended to use the third-party Click Calendar instead of DateField
+// when using jQuery or another JS library besides Prototype. See http://code.google.com/p/click-calendar/
+
+// Register a function that is invoked as soon as the DOM is loaded
+jQuery(document).ready(function() {
+
+    // Register a 'click' handler on the submit button
+    jQuery("#form_save, #form_cancel").live('click', function(event){
+        // Prevent the default browser behavior of navigating to the link
+        event.preventDefault();
+
+        // Post form
+        postForm(event);
+    })
+})
+
+function postForm(event) {
+    var form = jQuery("#form");
+    var submit = jQuery(event.target);
+    
+    var url = form.attr('action');
+    var formData = form.serialize();
+    formData+='&'+form.attr('id')+'=1';
+    formData+='&'+submit.attr('name')+'='+submit.attr('value');
+
+    jQuery.post(url, formData, function(data) {
+        form.replaceWith(data);
+
+        // Replacing the Form with the Form from the Ajax response, means all
+        // event bindings are lost. For example the DateField button won't show
+        // the Calendar. Here we find the DateField setup script, and evaluate it
+        // again
+        var dateSetupScript = jQuery('#form_date-js-setup').html();
+        eval(dateSetupScript);
+    });
+}

Copied: click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.htm (from r943406, click/trunk/click/examples/webapp/ajax/ajax-live-scroller.htm)
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.htm?p2=click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.htm&p1=click/trunk/click/examples/webapp/ajax/ajax-live-scroller.htm&r1=943406&r2=962419&rev=962419&view=diff
==============================================================================
--- click/trunk/click/examples/webapp/ajax/ajax-live-scroller.htm (original)
+++ click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.htm Fri Jul  9 05:53:56 2010
@@ -16,45 +16,13 @@
    specific language governing permissions and limitations
    under the License.*#
 -->
-#if ($customers.size() == 0)
-  LAST_RECORD
 
-#else
-  #if ($msg)
-    Demonstration using <a target="_blank" class="external" href="http://en.wikipedia.org/wiki/AJAX">AJAX</a>
-    to dynamically load content while scrolling. This example uses the
-    <a target="_blank" class="external" href="http://jquery.com/">jQuery</a> JavaScript library.
-    <h3>$msg</h3>
-  #end
-  
-  #foreach ($customer in $customers)
-  <div id="customer-$customer.id" class="customer" style="border:1px solid black; background:#eeeeee; padding: 4px; margin-bottom: 20px;">
-      <table>
-          <tr>
-              <td><b>Name:</b></td>
-              <td><b>$customer.name</b></td>
-          </tr>
-          <tr>
-              <td><b>Email:</b></td>
-              <td>$format.email($customer.email)</td>
-          </tr>
-          <tr>
-              <td><b>Age:</b></td>
-              <td>$format.string($customer.age)</td>
-          </tr>
-          <tr>
-              <td><b>Holdings:</b></td>
-              <td>$format.currency($customer.holdings)</td>
-          </tr>
-          <tr>
-              <td><b>Investments:</b></td>
-              <td>$format.string($customer.investments)</td>
-          </tr>
-          <tr>
-              <td><b>Join Date:</b></td>
-              <td>$format.date($customer.dateJoined)</td>
-          </tr>
-      </table>
-</div>
-  #end
-#end
+Demonstrates using <a target="_blank" class="external" href="http://en.wikipedia.org/wiki/AJAX">AJAX</a>
+to dynamically load more customers while scrolling down the page. The window 'scroll'
+event is monitored and detects when the scrollbar is near the bottom of the page. This example uses the
+<a target="_blank" class="external" href="http://jquery.com/">jQuery</a> JavaScript library.
+
+<h3>Top Customers</h3>
+
+<!-- Load initial list of customers in case JavaScript is disabled -->
+#parse("/ajax/scroller/customers.htm")
\ No newline at end of file

Copied: click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.js (from r943406, click/trunk/click/examples/webapp/ajax/ajax-live-scroller.js)
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.js?p2=click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.js&p1=click/trunk/click/examples/webapp/ajax/ajax-live-scroller.js&r1=943406&r2=962419&rev=962419&view=diff
==============================================================================
--- click/trunk/click/examples/webapp/ajax/ajax-live-scroller.js (original)
+++ click/trunk/click/examples/webapp/ajax/scroller/ajax-live-scroller.js Fri Jul  9 05:53:56 2010
@@ -36,35 +36,35 @@ $(document).ready(function(){
     var loading = false;
 
     function loadMoreData() {
-        // Increment offset with the specified number of pages
-        offset+=pageSize;
-
         // Toggle flag to indicate that loading started
         loading = true;
 
+        // Increment offset with the specified number of pages
+        offset+=pageSize;
+
         // Show the scroll indicator
         jQuery('#scroll-indicator').css("display", "block");
 
-        jQuery.get('${context}${path}?offset=' + offset, function(data){
-                // Toggle flag to indicate that loading is finished
-                loading = false;
-
-                // If the server returns the "LAST_RECORD" indicator, we
-                // can unbind the window scroll event as no further data
-                // will be returned
-                if (data.indexOf("LAST_RECORD") >= 0) {
-                    $(window).unbind('scroll');
-                } else {
-                    // Otherwise we add the new data after the last customer
-                    $(".customer:last").after(data);
-                }
-
-                jQuery('#scroll-indicator').css("display", "none");
-            });
+        // Perform Ajax GET request. Note pageAction parameter which specifies the onScroll page method
+        jQuery.get('${context}${path}?pageAction=onScroll&offset=' + offset, function(data){
+            // If the server response contains no div element, unbind the window scroll event as no further data
+            // will be returned
+            if (data.indexOf("<div") < 0) {
+                jQuery(window).unbind('scroll');
+            } else {
+                // Otherwise we add the new data after the last customer
+                jQuery(".customer:last").after(data);
+            }
+
+            jQuery('#scroll-indicator').css("display", "none");
+
+            // Toggle flag to indicate that loading is finished
+            loading = false;
+        });
     }
 
     // Bind a scroll event to the window to detect if more data needs to be loaded
-    $(window).bind('scroll', function() {
+    jQuery(window).bind('scroll', function() {
 
         // If we are currently retrieving data, don't load again
         if (loading) {
@@ -73,12 +73,19 @@ $(document).ready(function(){
 
         // When scrolling near the bottom of the page, load more data from server
         if (nearEndOfPage()) {
+            // Incase we scrolled to end of page, move scrollbar slightly back
+            jQuery(window).scrollTop(jQuery(window).scrollTop() - 1);
             loadMoreData();
         }
     });
 
     // Return true if scrolling is 85% at the end of the page
     function nearEndOfPage() {
-        return $(window).scrollTop() > (0.85 * $(document).height() - $(window).height());
+        return jQuery(window).scrollTop() > getFetchThreshold();
+    }
+
+    // Return the threshold when more data should be fetched, equates to 85% of the document height
+    function getFetchThreshold() {
+        return 0.85 * jQuery(document).height() - jQuery(window).height();
     }
 })

Added: click/trunk/click/examples/webapp/ajax/scroller/customers.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/scroller/customers.htm?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/scroller/customers.htm (added)
+++ click/trunk/click/examples/webapp/ajax/scroller/customers.htm Fri Jul  9 05:53:56 2010
@@ -0,0 +1,48 @@
+<!--
+#* Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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.*#
+-->
+#foreach ($customer in $customers)
+<div id="customer-$customer.id" class="customer">
+    <table>
+        <tr>
+            <td><b>Name:</b></td>
+            <td><b>$customer.name</b></td>
+        </tr>
+        <tr>
+            <td><b>Email:</b></td>
+            <td>$format.email($customer.email)</td>
+        </tr>
+        <tr>
+            <td><b>Age:</b></td>
+            <td>$format.string($customer.age)</td>
+        </tr>
+        <tr>
+            <td><b>Holdings:</b></td>
+            <td>$format.currency($customer.holdings)</td>
+        </tr>
+        <tr>
+            <td><b>Investments:</b></td>
+            <td>$format.string($customer.investments)</td>
+        </tr>
+        <tr>
+            <td><b>Join Date:</b></td>
+            <td>$format.date($customer.dateJoined)</td>
+        </tr>
+    </table>
+</div>
+#end

Copied: click/trunk/click/examples/webapp/ajax/select/ajax-select.js (from r943406, click/trunk/click/examples/webapp/ajax/ajax-select.js)
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/select/ajax-select.js?p2=click/trunk/click/examples/webapp/ajax/select/ajax-select.js&p1=click/trunk/click/examples/webapp/ajax/ajax-select.js&r1=943406&r2=962419&rev=962419&view=diff
==============================================================================
--- click/trunk/click/examples/webapp/ajax/ajax-select.js (original)
+++ click/trunk/click/examples/webapp/ajax/select/ajax-select.js Fri Jul  9 05:53:56 2010
@@ -35,7 +35,7 @@ document.observe("dom:loaded", function(
         // from the AjaxSelect.java Page
         new Ajax.Updater('$target', '$context$path', {
             method: 'get',
-            parameters: {customerId : select.value}
+            parameters: {'pageAction' : 'onChangeCustomer', 'customerId' : select.value}
         });
     });
 });

Added: click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.htm
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.htm?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.htm (added)
+++ click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.htm Fri Jul  9 05:53:56 2010
@@ -0,0 +1,5 @@
+$table
+
+<div id="result">
+    
+</div>
\ No newline at end of file

Added: click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.js
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.js?rev=962419&view=auto
==============================================================================
--- click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.js (added)
+++ click/trunk/click/examples/webapp/ajax/table/table-ajax-demo.js Fri Jul  9 05:53:56 2010
@@ -0,0 +1,47 @@
+// #*
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.
+// *#
+
+// Register a function that is invoked as soon as the DOM is loaded
+jQuery(document).ready(function() {
+
+    // Register a 'click' handler on every link inside the table
+    jQuery("#table a").click(function(event){
+        // Prevent the default browser behavior of navigating to the link
+        event.preventDefault();
+
+        var callServer = true;
+        if (jQuery(event.target).text()=="Delete") {
+            callServer = window.confirm('Please confirm delete');
+        }
+
+        if (callServer) {
+            // Make ajax request
+            makeRequest(event);
+        }
+    })
+})
+
+function makeRequest(event) {
+    var link = jQuery(event.target);
+    var url = link.attr('href');
+    jQuery.get(url, function(data) {
+        // Update the result div with the server response
+        jQuery("#result").html("<p class='infoMsg'>" + data + "</p>");
+    });
+}
\ No newline at end of file