click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r767237 - in /incubator/click/trunk/click/examples: src/org/apache/click/examples/page/control/SubmitLinkDemo.java webapp/WEB-INF/menu.xml webapp/control/submit-link-demo.htm
Date Tue, 21 Apr 2009 17:34:43 GMT
Author: sabob
Date: Tue Apr 21 17:34:42 2009
New Revision: 767237

URL: http://svn.apache.org/viewvc?rev=767237&view=rev
Log:
added a SubmitLink demo

Added:
    incubator/click/trunk/click/examples/src/org/apache/click/examples/page/control/SubmitLinkDemo.java
    incubator/click/trunk/click/examples/webapp/control/submit-link-demo.htm
Modified:
    incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml

Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/control/SubmitLinkDemo.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/control/SubmitLinkDemo.java?rev=767237&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/control/SubmitLinkDemo.java
(added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/control/SubmitLinkDemo.java
Tue Apr 21 17:34:42 2009
@@ -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.control;
+
+import java.util.Date;
+
+import org.apache.click.ActionListener;
+import org.apache.click.Control;
+import org.apache.click.control.FieldSet;
+import org.apache.click.control.Form;
+import org.apache.click.control.TextField;
+import org.apache.click.examples.page.BorderPage;
+import org.apache.click.extras.control.SubmitLink;
+
+/**
+ * This example demonstrates how to use a SubmitLink control together with the
+ * Form control.
+ *
+ * @author Bob Schellink
+ */
+public class SubmitLinkDemo extends BorderPage {
+
+    /** A submit link. */
+    private SubmitLink submitLink = new SubmitLink("submit");
+
+    /** A submit link which includes parameters. */
+    private SubmitLink paramLink = new SubmitLink("paramLink");
+
+    /** A submit link used outside of a Form control. */
+    private SubmitLink standaloneLink = new SubmitLink("standaloneLink");
+
+    public String demo1Msg;
+
+    public String demo2Msg;
+
+    public SubmitLinkDemo() {
+        Form form = new Form("form");
+        addControl(form);
+
+        FieldSet fieldSet = new FieldSet("fieldSet");
+        form.add(fieldSet);
+
+        fieldSet.add(new TextField("name"));
+
+        // Add the submit link to the fieldSet
+        fieldSet.add(submitLink);
+
+        // Add some parameters to the parameterized submit link
+        paramLink.setValue("myValue");
+        paramLink.setParameter("x", "100");
+
+        // Add the parameterized submit link to the FieldSet
+        fieldSet.add(paramLink);
+
+        // The SubmitLink action listener
+        submitLink.setActionListener(new ActionListener() {
+
+            public boolean onAction(Control source) {
+                demo1Msg = source.getName() + ".onAction invoked at " +
+                    (new Date());
+                return true;
+            }
+        });
+
+        // The Parameterized SubmitLink action listener
+        paramLink.setActionListener(new ActionListener() {
+
+            public boolean onAction(Control source) {
+                demo1Msg = source.getName() + ".onAction invoked at " +
+                    (new Date());
+                demo1Msg += "<br>Parameters:" + paramLink.getParameters();
+                return true;
+            }
+        });
+
+        // Add the Standalone SubmitLink to the Page
+        addControl(standaloneLink);
+
+        // The Standalone SubmitLink action listener
+        standaloneLink.setActionListener(new ActionListener() {
+
+            public boolean onAction(Control source) {
+                demo2Msg = source.getName() + ".onAction invoked at " +
+                    (new Date());
+                return true;
+            }
+        });
+    }
+}

Modified: incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml?rev=767237&r1=767236&r2=767237&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml (original)
+++ incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml Tue Apr 21 17:34:42 2009
@@ -78,6 +78,7 @@
     <menu label="FileField" path="control/file-upload.htm"/>
     <menu label="ImageSubmit" path="control/image-demo.htm"/>
     <menu label="Link Controls" path="control/link-demo.htm"/>
+    <menu label="SubmitLink Control" path="control/submit-link-demo.htm"/>
     <menu label="Select" path="control/select-demo.htm"/>
     <menu label="Populate on select" path="control/populate-on-select.htm"/>
     <menu separator="true"/>

Added: incubator/click/trunk/click/examples/webapp/control/submit-link-demo.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/control/submit-link-demo.htm?rev=767237&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/control/submit-link-demo.htm (added)
+++ incubator/click/trunk/click/examples/webapp/control/submit-link-demo.htm Tue Apr 21 17:34:42
2009
@@ -0,0 +1,46 @@
+<!--
+#* 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.*#
+-->
+
+<h3>Demo1</h3>
+
+In this first demo is shown how the Form is submitted when the SubmitLink is
+clicked. Note that the SubmitLink parameters will be sent as part of the Form
+submission.
+
+$form
+
+#if ($demo1Msg)
+<p class="infoMsg"> $demo1Msg</p>
+#end
+
+<h3>Demo2</h3>
+
+This demo shows how the SubmitLink can be used outside a Form. When a SubmitLink
+is not inside a Form it behaves like a normal ActionLink.
+
+<p/>
+
+Click <a href="$standaloneLink.href">here</a> to invoke the SubmitLink.
+
+#if ($demo2Msg)
+<p class="infoMsg"> $demo2Msg</p>
+#end
+
+
+$dForm
\ No newline at end of file



Mime
View raw message