You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ja...@apache.org on 2007/05/08 20:25:51 UTC
svn commit: r536290 - in
/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin:
Index.html OnChangeAjaxBehaviorPage.html OnChangeAjaxBehaviorPage.java
Author: janne
Date: Tue May 8 11:25:50 2007
New Revision: 536290
URL: http://svn.apache.org/viewvc?view=rev&rev=536290
Log:
added example of OnChangeAjaxBehavior
Added:
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.html
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.java
Modified:
incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html
Modified: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html?view=diff&rev=536290&r1=536289&r2=536290
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html (original)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/Index.html Tue May 8 11:25:50 2007
@@ -25,6 +25,8 @@
<br/><br/>
<a href="AutoCompletePage.html">Auto-Complete TextField Example</a>: shows a textfield with auto complete drop down like google suggest
<br/><br/>
+<a href="OnChangeAjaxBehaviorPage.html">On Change Ajax Updater Example</a>: demonstrates updating page with ajax when text field value is changed
+<br/><br/>
<a href="RatingsPage.html">Ratings example</a>: shows a rating component.
<br/><br/>
<a href="tree/SimpleTreePage.html">Tree and TreeTable</a>: shows ajax tree and ajax tree table.
Added: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.html?view=auto&rev=536290
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.html (added)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.html Tue May 8 11:25:50 2007
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <wicket:extend>
+
+ <form wicket:id="form">
+ Field: <input type="text" wicket:id="field" size="50"/><br/>
+ Values:<span wicket:id="selectedValue"></span><br/>
+ </form>
+
+ </wicket:extend>
+ </body>
+</html>
\ No newline at end of file
Added: incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.java?view=auto&rev=536290
==============================================================================
--- incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.java (added)
+++ incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/OnChangeAjaxBehaviorPage.java Tue May 8 11:25:50 2007
@@ -0,0 +1,88 @@
+/*
+ * 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.wicket.examples.ajax.builtin;
+
+import java.util.Locale;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.util.string.Strings;
+
+/**
+ * @author Janne Hietamäki (janne)
+ */
+public class OnChangeAjaxBehaviorPage extends BasePage
+{
+
+ protected String getValue(String input)
+ {
+ if (Strings.isEmpty(input))
+ {
+ return "";
+ }
+
+ StringBuffer buffer = new StringBuffer();
+
+ Locale[] locales = Locale.getAvailableLocales();
+
+ for (int i = 0; i < locales.length; i++)
+ {
+ final Locale locale = locales[i];
+ final String country = locale.getDisplayCountry();
+
+ if (country.toUpperCase().startsWith(input.toUpperCase()))
+ {
+ buffer.append(country);
+ buffer.append(" ");
+ }
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * Constructor
+ */
+ public OnChangeAjaxBehaviorPage()
+ {
+ Form form = new Form("form");
+ add(form);
+
+ final TextField field = new TextField("field", new Model(""));
+ form.add(field);
+
+ final Label label = new Label("selectedValue", new Model(""));
+ label.setOutputMarkupId(true);
+ form.add(label);
+
+ OnChangeAjaxBehavior onChangeAjaxBehavior = new OnChangeAjaxBehavior()
+ {
+ @Override
+ protected void onUpdate(AjaxRequestTarget target)
+ {
+ label.setModelObject(getValue(field.getModelObjectAsString()));
+ target.addComponent(label);
+ }
+ };
+ field.add(onChangeAjaxBehavior);
+ }
+
+}