You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2016/06/17 16:34:48 UTC

[13/21] wicket git commit: Stateless components

Stateless components


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/9221e61d
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/9221e61d
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/9221e61d

Branch: refs/heads/WICKET-6183
Commit: 9221e61d7d53135bdc0a822ee3912de6c5e69062
Parents: 7eced62
Author: Andrea Del Bene <ad...@apache.org>
Authored: Mon May 30 12:23:28 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Mon May 30 13:15:24 2016 +0200

----------------------------------------------------------------------
 .../ajax/markup/html/StatelessAjaxLink.java     | 40 +++++++++++++++
 .../markup/html/form/StatelessAjaxButton.java   | 51 ++++++++++++++++++++
 .../html/form/StatelessAjaxSubmitLink.java      | 40 +++++++++++++++
 .../bean/validation/BeanValidationPage.java     |  3 +-
 .../stateless/AjaxStatelessExample.java         | 10 +---
 .../src/docs/guide/ajax/ajax_7.gdoc             |  6 +--
 6 files changed, 138 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/9221e61d/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/StatelessAjaxLink.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/StatelessAjaxLink.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/StatelessAjaxLink.java
new file mode 100644
index 0000000..d083b23
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/StatelessAjaxLink.java
@@ -0,0 +1,40 @@
+/*
+ * 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.ajax.markup.html;
+
+import org.apache.wicket.model.IModel;
+
+public abstract class StatelessAjaxLink<T> extends AjaxLink<T>
+{
+	private static final long serialVersionUID = 5580337001313353237L;
+
+	public StatelessAjaxLink(String id, IModel<T> model)
+	{
+		super(id, model);
+	}
+
+	public StatelessAjaxLink(String id)
+	{
+		super(id);
+	}
+	
+	@Override
+	protected boolean getStatelessHint()
+	{
+		return true;
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/9221e61d/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxButton.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxButton.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxButton.java
new file mode 100644
index 0000000..7e3c4af
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxButton.java
@@ -0,0 +1,51 @@
+/*
+ * 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.ajax.markup.html.form;
+
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.model.IModel;
+
+public class StatelessAjaxButton extends AjaxButton
+{
+	private static final long serialVersionUID = -3625309953596700148L;
+
+	public StatelessAjaxButton(String id, Form<?> form)
+	{
+		super(id, form);
+	}
+
+	public StatelessAjaxButton(String id, IModel<String> model, Form<?> form)
+	{
+		super(id, model, form);
+	}
+
+	public StatelessAjaxButton(String id, IModel<String> model)
+	{
+		super(id, model);
+	}
+
+	public StatelessAjaxButton(String id)
+	{
+		super(id);
+	}
+	
+	@Override
+	protected boolean getStatelessHint()
+	{
+		return true;
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/9221e61d/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLink.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLink.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLink.java
new file mode 100644
index 0000000..bd710fb
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLink.java
@@ -0,0 +1,40 @@
+/*
+ * 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.ajax.markup.html.form;
+
+import org.apache.wicket.markup.html.form.Form;
+
+public class StatelessAjaxSubmitLink extends AjaxSubmitLink
+{
+	private static final long serialVersionUID = -3175689678864002395L;
+
+	public StatelessAjaxSubmitLink(String id, Form<?> form)
+	{
+		super(id, form);
+	}
+
+	public StatelessAjaxSubmitLink(String id)
+	{
+		super(id);
+	}
+
+	@Override
+	protected boolean getStatelessHint()
+	{
+		return true;
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/9221e61d/wicket-examples/src/main/java/org/apache/wicket/examples/bean/validation/BeanValidationPage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/bean/validation/BeanValidationPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/bean/validation/BeanValidationPage.java
index 33e3a04..684a45b 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/bean/validation/BeanValidationPage.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/bean/validation/BeanValidationPage.java
@@ -25,6 +25,7 @@ import org.apache.wicket.examples.WicketExamplePage;
 import org.apache.wicket.feedback.ExactLevelFeedbackMessageFilter;
 import org.apache.wicket.feedback.FeedbackMessage;
 import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.StatelessForm;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.markup.html.panel.FeedbackPanel;
 import org.apache.wicket.model.PropertyModel;
@@ -38,7 +39,7 @@ public class BeanValidationPage extends WicketExamplePage
 	{
 		add(new FeedbackPanel("feedbackErrors", new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR)));
 
-		Form<?> form = new Form<Void>("form") {
+		Form<?> form = new StatelessForm<Void>("form") {
 			@Override
 			protected void onSubmit()
 			{

http://git-wip-us.apache.org/repos/asf/wicket/blob/9221e61d/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.java b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.java
index 32c5e81..2a1bb6f 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.java
@@ -6,7 +6,7 @@ import org.apache.wicket.Component;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
 import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
-import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.ajax.markup.html.form.StatelessAjaxSubmitLink;
 import org.apache.wicket.examples.WicketExamplePage;
 import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
 import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxFallbackLink;
@@ -122,7 +122,7 @@ public class AjaxStatelessExample extends WicketExamplePage
 		form.add(feedback.setOutputMarkupId(true));
 		form.add(submittedValues.setOutputMarkupId(true));
 
-		form.add(new AjaxSubmitLink("submit")
+		form.add(new StatelessAjaxSubmitLink("submit")
 		{
 			@Override
 			protected void onError(AjaxRequestTarget target, Form<?> form)
@@ -139,12 +139,6 @@ public class AjaxStatelessExample extends WicketExamplePage
 				submittedValues.setDefaultModelObject(values);
 				target.add(feedback, submittedValues);
 			}
-			
-			@Override
-			protected boolean getStatelessHint()
-			{
-				return true;
-			}
 		});
 
 		add(form);

http://git-wip-us.apache.org/repos/asf/wicket/blob/9221e61d/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc b/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
index dd01c1f..e23f5c5 100644
--- a/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
@@ -33,12 +33,12 @@ Just like components also AJAX behaviors can be turned to stateless overriding @
 
 h3. Usage
 
-Stateless components and behaviors follows the same rules and conventions of their standard stateful version shipped with Wicket. Therefore you will find different handler methods like @onSubmit@ or @onClick@ that provide an instance of @AjaxRequestTarget@ to refresh components markup. Such components must have a markup id in order to be manipulated via JavaScript.
+Stateless components and behaviors follows the same rules and conventions of their standard stateful version, so they must have a markup id in order to be manipulated via JavaScript.
 However in this case calling @setOutputMarkupId@ on a component is not enough. Since we are working with a stateless page, the id of the component to refresh must be unique but also static, meaning that it should not depend on page instance. In other words, the id should be constant through different instances of the same page.
-By default Wicket generates markup ids using a session-level counter and this make them not static. Hence, to refresh component in a stateless page we must provide them with static ids, either setting them in Java code (with @Component.setMarkupId@) or simply writing them directly in the markup:
+By default calling @setOutputMarkupId@ we generate markup ids using a session-level counter and this make them not static. Hence, to refresh component in a stateless page we must provide them with static ids, either setting them in Java code (with @Component.setMarkupId@) or simply writing them directly in the markup:
 
 {code}
    <span id="staticIdToUSe" wicket:id="componentWicketId"></span>
 {code}
 
-See examples site for a full showcase of AJAX-stateless capabilities.
+[See examples site|http://examples7x.wicket.apache.org/stateless] for a full showcase of AJAX-stateless capabilities.