You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by me...@apache.org on 2009/06/06 14:10:56 UTC
svn commit: r782240 - in /incubator/click/trunk/click/examples:
src/org/apache/click/examples/page/introduction/
src/org/apache/click/examples/page/tree/ webapp/WEB-INF/ webapp/introduction/
Author: medgar
Date: Sat Jun 6 12:10:56 2009
New Revision: 782240
URL: http://svn.apache.org/viewvc?rev=782240&view=rev
Log:
added new introduction control-listener example
Added:
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType1Page.java
- copied, changed from r781986, incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerPage.java
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType2Page.java
incubator/click/trunk/click/examples/webapp/introduction/control-listener-type-1.htm
- copied unchanged from r777063, incubator/click/trunk/click/examples/webapp/introduction/control-listener.htm
incubator/click/trunk/click/examples/webapp/introduction/control-listener-type-2.htm
Removed:
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerPage.java
incubator/click/trunk/click/examples/webapp/introduction/control-listener.htm
Modified:
incubator/click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java
incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml
Copied: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType1Page.java (from r781986, incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerPage.java)
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType1Page.java?p2=incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType1Page.java&p1=incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerPage.java&r1=781986&r2=782240&rev=782240&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerPage.java (original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType1Page.java Sat Jun 6 12:10:56 2009
@@ -22,35 +22,33 @@
import org.apache.click.examples.page.BorderPage;
/**
- * Provides a control listener example Page.
+ * Provides a control listener example Page using the runtime binding of the
+ * control listener.
+ * <p/>
+ * The advantage of this control listener binding style is
+ * that you write less lines of code, the disadvantage is that there is no
+ * compile time checking.
*
* @author Malcolm Edgar
*/
-public class ControlListenerPage extends BorderPage {
+public class ControlListenerType1Page extends BorderPage {
- /* Public scope controls are automatically added to the page. */
- public ActionLink myLink = new ActionLink();
+ /*
+ * Set the listener to this object's "onLinkClick" method.
+ */
+ public ActionLink myLink = new ActionLink(this, "onLinkClick");
/* Public scope variable are automatically added to the model. */
public String msg;
- // ----------------------------------------------------------- Constructors
-
- /**
- * Create a new Page instance.
- */
- public ControlListenerPage() {
- myLink.setListener(this, "onMyLinkClick");
- }
-
// --------------------------------------------------------- Event Handlers
/**
- * Handle the myLink control click event.
+ * Handle the ActionLink control click event.
*/
- public boolean onMyLinkClick() {
+ public boolean onLinkClick() {
msg = "ControlListenerPage#" + hashCode()
- + " object method <tt>onMyLinkClick()</tt> invoked.";
+ + " object method <tt>onLinkClick()</tt> invoked.";
return true;
}
Added: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType2Page.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType2Page.java?rev=782240&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType2Page.java (added)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/ControlListenerType2Page.java Sat Jun 6 12:10:56 2009
@@ -0,0 +1,60 @@
+/*
+ * 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.introduction;
+
+import org.apache.click.ActionListener;
+import org.apache.click.Control;
+import org.apache.click.control.ActionLink;
+import org.apache.click.examples.page.BorderPage;
+
+/**
+ * Provides a control listener example Page using the compile time binding of
+ * the control ActionListener.
+ * <p/>
+ * The advantage of this control listener binding style is you get compile
+ * time safety and compiler refactoring support, the disadvantage is that you
+ * have to write more lines of code.
+ *
+ * @author Malcolm Edgar
+ */
+public class ControlListenerType2Page extends BorderPage {
+
+ /* Public scope controls are automatically added to the page. */
+ public ActionLink myLink = new ActionLink();
+
+ /* Public scope variable are automatically added to the model. */
+ public String msg;
+
+ // ------------------------------------------------------------ Constructor
+
+ /**
+ * Create a new Page instance.
+ */
+ public ControlListenerType2Page() {
+ myLink.setActionListener(new ActionListener() {
+ public boolean onAction(Control control) {
+ msg = "ControlListenerPage#" + hashCode()
+ + " object method <tt>onAction()</tt> invoked.";
+
+ return true;
+ }
+ });
+ }
+
+}
Modified: incubator/click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java?rev=782240&r1=782239&r2=782240&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java (original)
+++ incubator/click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java Sat Jun 6 12:10:56 2009
@@ -22,14 +22,14 @@
import org.apache.click.control.PageLink;
import org.apache.click.examples.page.introduction.AdvancedForm;
import org.apache.click.examples.page.introduction.AdvancedTable;
-import org.apache.click.examples.page.introduction.ControlListenerPage;
+import org.apache.click.examples.page.introduction.ControlListenerType1Page;
+import org.apache.click.examples.page.introduction.ControlListenerType2Page;
import org.apache.click.examples.page.introduction.HelloWorld;
import org.apache.click.examples.page.introduction.SimpleForm;
import org.apache.click.examples.page.velocity.SimpleTable;
import org.apache.click.extras.tree.Tree;
import org.apache.click.extras.tree.TreeNode;
import org.apache.click.util.HtmlStringBuffer;
-
import org.apache.commons.lang.ClassUtils;
/**
@@ -93,7 +93,8 @@
boolean supportsChildNodes = false;
new TreeNode(HelloWorld.class, "1.1", general, supportsChildNodes);
- new TreeNode(ControlListenerPage.class, "1.2", general, supportsChildNodes);
+ new TreeNode(ControlListenerType1Page.class, "1.2", general, supportsChildNodes);
+ new TreeNode(ControlListenerType2Page.class, "1.3", general, supportsChildNodes);
TreeNode forms = new TreeNode("Forms", "2", root);
new TreeNode(SimpleForm.class, "2.1", forms, supportsChildNodes);
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=782240&r1=782239&r2=782240&view=diff
==============================================================================
--- incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml (original)
+++ incubator/click/trunk/click/examples/webapp/WEB-INF/menu.xml Sat Jun 6 12:10:56 2009
@@ -32,7 +32,8 @@
<menu label="Intro Examples" path="#" imageSrc="/assets/images/intro.png">
<menu label="Hello World" path="introduction/hello-world.htm"/>
- <menu label="Control Listener" path="introduction/control-listener.htm"/>
+ <menu label="Control Listener Type 1" path="introduction/control-listener-type-1.htm"/>
+ <menu label="Control Listener Type 2" path="introduction/control-listener-type-2.htm"/>
<menu separator="true"/>
<menu label="Simple Table" path="introduction/simple-table.htm"/>
<menu label="Advanced Table" path="introduction/advanced-table.htm"/>
Added: incubator/click/trunk/click/examples/webapp/introduction/control-listener-type-2.htm
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/examples/webapp/introduction/control-listener-type-2.htm?rev=782240&view=auto
==============================================================================
--- incubator/click/trunk/click/examples/webapp/introduction/control-listener-type-2.htm (added)
+++ incubator/click/trunk/click/examples/webapp/introduction/control-listener-type-2.htm Sat Jun 6 12:10:56 2009
@@ -0,0 +1,24 @@
+<!--
+#* 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.*#
+-->
+
+Click myLink control <a href="$myLink.href">here</a>.
+
+#if ($msg)
+ <p class="infoMsg"> $msg </p>
+#end
\ No newline at end of file