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:36 UTC

[01/21] wicket git commit: Porting of stateless AJAX components to the official project

Repository: wicket
Updated Branches:
  refs/heads/WICKET-6183 [created] b87b91b34


Porting of stateless AJAX components to the official project

Integrated examples and unit tests

Added javadoc

added chapter for stateless AJAX

Minor fix

Update ajax_7.gdoc

Started to reuse code from existing AJAX entities

Code cleaning

Code optimization.

Removed stateless entities.

Minor fix


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

Branch: refs/heads/WICKET-6183
Commit: 96ba48889fee11f5a1dd31dd4cb48998ed9cf2c6
Parents: 9ff894d
Author: Andrea Del Bene <an...@innoteam.it>
Authored: Tue Apr 5 18:43:38 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu May 26 23:22:11 2016 +0200

----------------------------------------------------------------------
 .../ajax/AbstractDefaultAjaxBehavior.java       |  10 +-
 .../ajax/form/AjaxFormSubmitBehavior.java       |   2 +-
 .../ajax/markup/html/AjaxFallbackLink.java      |   7 +
 .../ajax/markup/html/form/AjaxButton.java       |   7 +
 .../ajax/markup/html/form/AjaxSubmitLink.java   |   7 +
 .../org/apache/wicket/ajax/StatelessPage.html   |  40 ++++
 .../org/apache/wicket/ajax/StatelessPage.java   | 170 ++++++++++++++
 .../html/StatelessAjaxFallbackLinkTest.java     |  70 ++++++
 .../html/form/StatelessAjaxSubmitLinkTest.java  |  71 ++++++
 .../wicket/examples/ajax/builtin/BasePage.java  |  13 ++
 .../stateless/AjaxStatelessExample.html         |  72 ++++++
 .../stateless/AjaxStatelessExample.java         | 220 +++++++++++++++++++
 .../apache/wicket/examples/stateless/Index.html |   3 +
 .../apache/wicket/examples/stateless/Index.java |  13 ++
 .../src/docs/guide/ajax/ajax_7.gdoc             |  43 +++-
 .../src/docs/guide/ajax/ajax_8.gdoc             |   7 +
 wicket-user-guide/src/docs/guide/toc.yml        |   3 +-
 17 files changed, 752 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
index 43f031d..3766b98 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
@@ -81,7 +81,15 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior
 	@Override
 	protected void onBind()
 	{
-		getComponent().setOutputMarkupId(true);
+		final Component component = getComponent();
+		
+		component.setOutputMarkupId(true);
+		
+		if (getStatelessHint(component))
+		{
+			//generate behavior id
+	        component.getBehaviorId(this);
+		}
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
index c734e9b..69ff89a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
@@ -168,7 +168,7 @@ public abstract class AjaxFormSubmitBehavior extends AjaxEventBehavior
 	@Override
 	protected void onEvent(final AjaxRequestTarget target)
 	{
-		getForm().getRootForm().onFormSubmitted(new AjaxFormSubmitter(this, target));
+		getForm().getRootForm().onFormSubmitted(new AjaxFormSubmitBehavior.AjaxFormSubmitter(this, target));
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
index 18488da..6c5f348 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.ajax.markup.html;
 
+import org.apache.wicket.Component;
 import org.apache.wicket.ajax.AjaxEventBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
@@ -97,6 +98,12 @@ public abstract class AjaxFallbackLink<T> extends Link<T> implements IAjaxLink
 				attributes.setPreventDefault(true);
 				AjaxFallbackLink.this.updateAjaxAttributes(attributes);
 			}
+			
+			@Override
+			public boolean getStatelessHint(Component component)
+			{				
+				return AjaxFallbackLink.this.getStatelessHint();
+			}
 		};
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
index 8706414..83b5d8b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.ajax.markup.html.form;
 
+import org.apache.wicket.Component;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
 import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
@@ -140,6 +141,12 @@ public abstract class AjaxButton extends Button
 			{
 				return AjaxButton.this.getDefaultFormProcessing();
 			}
+			
+			@Override
+			public boolean getStatelessHint(Component component)
+			{
+				return AjaxButton.this.getStatelessHint();
+			}
 		};
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
index 619e289..b1bf987 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.ajax.markup.html.form;
 
+import org.apache.wicket.Component;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
 import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
@@ -115,6 +116,12 @@ public abstract class AjaxSubmitLink extends AbstractSubmitLink
 			{
 				AjaxSubmitLink.this.onAfterSubmit(target, getForm());
 			}
+			
+			@Override
+			public boolean getStatelessHint(Component component)
+			{
+				return AjaxSubmitLink.this.getStatelessHint();
+			}
 		};
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.html b/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.html
new file mode 100644
index 0000000..2ab9df2
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.html
@@ -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.
+
+-->
+<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" >
+    <head>  
+        <title>Wicket Quickstart Archetype Homepage</title>
+    </head>
+    <body>
+      <ul wicket:id="list">
+        <li wicket:id="item"><span wicket:id="value">Item 1</span></li>
+      </ul>
+      <div id="new"></div>
+      <a href="#" wicket:id="more">More Data</a>
+      <a href="#" wicket:id="home">Home</a>
+      
+      <form wicket:id="inputForm" >
+		<label for="name">Name:</label>
+		<input wicket:id="name" id="name" type="text" size="15"/><br/>
+		<label for="surname">Surname:</label>
+		<input wicket:id="surname" id="surname" type="text" size="15"/><br/>
+		<button id="submitButton" wicket:id="submit">Submit</button>
+		<div wicket:id="feedback" id="feedback"></div>
+	  </form>	
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.java b/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.java
new file mode 100644
index 0000000..7e324a4
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/StatelessPage.java
@@ -0,0 +1,170 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+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.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+
+/**
+ * Homepage
+ */
+public class StatelessPage extends WebPage
+{
+	public static final String AJAX_SUBMIT = "AJAX submit";
+
+	public static final String FORM_SUBMIT = "form submit";
+
+	static int itemCount = 0;
+
+	private static final long serialVersionUID = 1L;
+
+	static List<String> getList()
+	{
+		final ArrayList<String> list = new ArrayList<String>(itemCount);
+		final int count = ++itemCount;
+
+		for (int idx = 1; idx <= count; idx++)
+		{
+			list.add(Integer.toString(idx));
+		}
+
+		return list;
+	}
+
+	/**
+	 * Constructor that is invoked when page is invoked without a session.
+	 * 
+	 * @param parameters
+	 *            Page parameters
+	 */
+	public StatelessPage(final PageParameters parameters)
+	{
+		super(parameters);
+
+		final MarkupContainer list = new WebMarkupContainer("list");
+		final List<String> data = getList();
+		final ListView<String> listView = new ListView<String>("item", data)
+		{
+			private static final long serialVersionUID = 200478523599165606L;
+
+			@Override
+			protected void populateItem(final ListItem<String> item)
+			{
+				final String _item = item.getModelObject();
+
+				item.add(new Label("value", _item));
+			}
+		};
+		final Link<String[]> moreLink = new AjaxFallbackLink<String[]>("more")
+		{
+			private static final long serialVersionUID = -1023445535126577565L;
+
+			@Override
+			public void onClick(final AjaxRequestTarget target)
+			{
+				final List<String> _data = getList();
+
+				System.out.println(_data);
+
+				listView.setModelObject(_data);
+
+				if (target != null)
+				{
+					target.add(list, "new");
+				}
+			}
+			
+			@Override
+			protected boolean getStatelessHint()
+			{
+				return true;
+			}
+		};
+		final Link<String> homeLink = new BookmarkablePageLink<String>("home", StatelessPage.class);
+
+		add(homeLink);
+		list.add(listView);
+		add(list);
+		add(moreLink);
+
+		// add form
+		TextField<String> name = new TextField<String>("name", new Model<String>("name"));
+		TextField<String> surname = new TextField<String>("surname", new Model<String>("surname"));
+
+		Form<String> form = new StatelessForm<String>("inputForm")
+		{
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = -6554405700693024016L;
+
+			@Override
+			protected void onSubmit()
+			{
+				super.onSubmit();
+				info(FORM_SUBMIT);
+			}
+		};
+
+		form.add(name, surname);
+
+		final FeedbackPanel feedback;
+		form.add(feedback = new FeedbackPanel("feedback"));
+		feedback.setOutputMarkupId(true);
+
+		form.add(new AjaxSubmitLink("submit")
+		{
+			/**
+			 * 
+			 */
+			private static final long serialVersionUID = -7296676299335203926L;
+
+			@Override
+			protected void onSubmit(AjaxRequestTarget target, Form<?> form)
+			{
+				super.onSubmit(target, form);
+				info(AJAX_SUBMIT);
+				target.add(feedback);
+			}
+			
+			@Override
+			protected boolean getStatelessHint()
+			{
+				return true;
+			}
+		});
+		add(form);
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/StatelessAjaxFallbackLinkTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/StatelessAjaxFallbackLinkTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/StatelessAjaxFallbackLinkTest.java
new file mode 100644
index 0000000..5cf7ff2
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/StatelessAjaxFallbackLinkTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.ajax.AjaxEventBehavior;
+import org.apache.wicket.ajax.StatelessPage;
+import org.apache.wicket.behavior.Behavior;
+import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class StatelessAjaxFallbackLinkTest
+{
+	protected WicketTester tester;
+
+	@Before
+	public void setUp()
+	{
+		tester = new WicketTester(new MockApplication());
+	}
+
+	@After
+	public void teardown()
+	{
+		// things must stay stateless
+		assertTrue(Session.get().isTemporary());
+	}
+
+	@Test
+	@SuppressWarnings("unchecked")
+	public void testGetStatelessHint()
+	{
+		tester.startPage(StatelessPage.class);
+
+		final StatelessPage page = (StatelessPage)tester.getLastRenderedPage();
+		final AjaxFallbackLink<Void> link = (AjaxFallbackLink<Void>)page.get("more");
+
+		assertTrue(link.isStateless());
+
+		link.onClick();
+
+		final List<? extends Behavior> behaviors = link.getBehaviors();
+		final AjaxEventBehavior behavior = (AjaxEventBehavior)behaviors.get(0);
+
+		behavior.onRequest();
+		
+		assertTrue(link.isStateless());
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLinkTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLinkTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLinkTest.java
new file mode 100644
index 0000000..51f7840
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/form/StatelessAjaxSubmitLinkTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.ajax.StatelessPage;
+import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.page.XmlPartialPageUpdate;
+import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class StatelessAjaxSubmitLinkTest
+{
+	protected WicketTester tester;
+
+	@Before
+	public void setUp()
+	{
+		tester = new WicketTester(new MockApplication());
+	}
+
+	@After
+	public void teardown()
+	{
+		// things must stay stateless
+		assertTrue(Session.get().isTemporary());
+	}
+	
+	@Test
+	public void testSubmitForm() throws Exception 
+	{
+    	tester.startPage(StatelessPage.class);
+    	
+    	FormTester formTester = tester.newFormTester("inputForm");
+    	formTester.setValue("name", "myname");
+    	formTester.setValue("surname", "mysurname");
+    	
+    	tester.executeAjaxEvent("inputForm:submit", "click");
+    	
+    	String response = tester.getLastResponseAsString();
+    	
+    	boolean isAjaxResponse = response.contains(XmlPartialPageUpdate.START_ROOT_ELEMENT)
+    		&& response.contains(XmlPartialPageUpdate.END_ROOT_ELEMENT);
+    	
+    	assertTrue(isAjaxResponse);
+    	
+    	boolean formAjaxSubmit = response.contains(StatelessPage.FORM_SUBMIT) &&
+    		response.contains(StatelessPage.AJAX_SUBMIT);
+    	
+    	assertTrue(formAjaxSubmit);
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/BasePage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/BasePage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/BasePage.java
index bac53a3..b06bcd2 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/BasePage.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/BasePage.java
@@ -18,6 +18,7 @@ package org.apache.wicket.examples.ajax.builtin;
 
 import org.apache.wicket.examples.WicketExamplePage;
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
 
 
 /**
@@ -30,6 +31,18 @@ public class BasePage extends WicketExamplePage
 	 */
 	public BasePage()
 	{
+		
+	}
+	
+	public BasePage(PageParameters pageParameters)
+	{
+		super(pageParameters);
+	}
+	
+	@Override
+	protected void onInitialize()
+	{
+		super.onInitialize();
 		add(new BookmarkablePageLink<>("back", Index.class).setAutoEnable(true));
 	}
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.html b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.html
new file mode 100644
index 0000000..1f07813
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.html
@@ -0,0 +1,72 @@
+<!--
+
+     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.
+
+-->
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+	<head>
+	 <title>Stateless Wicket</title>
+	 <link rel="stylesheet" type="text/css" href="style.css"/>
+	</head>
+	<body>
+		<span wicket:id="mainNavigation"></span>
+		<span wicket:id="message" id="message">Message goes here</span>
+		<br />
+		<a wicket:id="indexLink" href="#">go to index</a>
+		<br />
+		<h2>Statless ajax fallback link</h2>
+		<div>This link uses ajax when it is available, and a regular
+			wicket roundtrip when ajax or javascript are not available and the
+			page should be stateless.</div>
+
+		<b>Counter: </b>
+		<span id="c2" wicket:id="incrementLabel"></span>
+		<a href="#" id="c2-link" wicket:id="incrementLink">increment</a>
+		<br />
+		<br />
+
+		<h2>Stateless form submit example</h2>
+		<p>Submit form via AJAX. Each field is required.</p>
+		<form wicket:id="inputForm">
+			<label for="name">Name:</label> <input wicket:id="name" id="name"
+				type="text" size="15" /><br /> <label for="surname">Surname:</label>
+			<input wicket:id="surname" id="surname" type="text" size="15" /><br />
+			<button id="submitButton" wicket:id="submit">Submit</button>
+
+			<div id="feedbackPanel" wicket:id="feedback"></div>
+			<br /> <span id="submittedValues" wicket:id="submittedValues"></span>
+
+		</form>
+		
+		<h2>Form component updating behavior example</h2>
+		<p>The select component submits its value via AJAX on 'change'
+			event.</p>
+		<select id="select" wicket:id="select"></select>
+		<span id="selectedValue" wicket:id="selectedValue"></span>
+		
+		<br />
+		<br />
+		<h2>AJAX indicator link example</h2>
+		<p>AJAX indicator link and button which show their indicator for
+			5 seconds.</p>
+		<a id="indicatingLink" wicket:id="indicatingLink">link</a>
+		<br />
+
+		<form wicket:id="indicatingForm"></form>
+		<button id="indicatingButton" wicket:id="indicatingButton">Button</button>
+	</body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/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
new file mode 100644
index 0000000..32c5e81
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/AjaxStatelessExample.java
@@ -0,0 +1,220 @@
+package org.apache.wicket.examples.stateless;
+
+import java.util.Arrays;
+
+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.examples.WicketExamplePage;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxFallbackLink;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+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.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.util.string.StringValue;
+
+
+public class AjaxStatelessExample extends WicketExamplePage
+{
+
+	private static final String COUNTER_PARAM = "counter";
+
+	/**
+	 * Constructor that is invoked when page is invoked without a session.
+	 *
+	 * @param parameters
+	 *            Page parameters
+	 */
+	public AjaxStatelessExample(final PageParameters parameters)
+	{
+		super(parameters);
+		setStatelessHint(true);
+		
+		add(new Label("message", new SessionModel()));
+		add(new BookmarkablePageLink<>("indexLink", Index.class));
+		
+		final Label incrementLabel = new Label("incrementLabel", new AbstractReadOnlyModel<Integer>()
+		{
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public Integer getObject()
+			{
+				final String counter = getParameter(parameters, COUNTER_PARAM);
+				return counter != null ? Integer.parseInt(counter) : 0;
+			}
+
+		});
+		final Link<?> incrementLink = new AjaxFallbackLink<Void>("incrementLink")
+		{
+
+			@Override
+			public void onClick(final AjaxRequestTarget target)
+			{				
+				Integer counter = (Integer)incrementLabel.getDefaultModelObject();
+				updateParams(getPageParameters(), counter);
+				
+				target.add(incrementLabel, this);
+			}
+			
+			@Override
+			protected boolean getStatelessHint()
+			{
+				return true;
+			}
+		};
+
+		add(incrementLink);
+		add(incrementLabel.setOutputMarkupId(true));
+
+		final TextField<String> nameField = new TextField<String>("name", new Model<String>(""));
+		final TextField<String> surnameField = new TextField<String>("surname", new Model<String>(""));
+
+		final Form<String> form = new StatelessForm<String>("inputForm")
+		{
+
+			@Override
+			protected void onSubmit()
+			{
+
+			}
+
+		};
+		final DropDownChoice<String> select = new DropDownChoice<String>("select",
+			new Model<String>("2"), Arrays.asList(new String[] { "1", "2", "3" }));
+		final Label selectedValue = new Label("selectedValue", "");
+		add(selectedValue.setOutputMarkupId(true));
+
+		select.add(new AjaxFormComponentUpdatingBehavior("change")
+		{
+
+			@Override
+			protected void onUpdate(final AjaxRequestTarget target)
+			{
+				final String value = select.getModelObject();
+				selectedValue.setDefaultModelObject("Selected value: " + value);
+				target.add(selectedValue);
+			}
+			
+			@Override
+			public boolean getStatelessHint(Component component)
+			{
+				return true;
+			}
+		});
+
+		form.add(nameField.setRequired(true));
+		form.add(surnameField.setRequired(true));
+
+		final Component feedback = new FeedbackPanel("feedback");
+		final Label submittedValues = new Label("submittedValues", "");
+
+		form.add(feedback.setOutputMarkupId(true));
+		form.add(submittedValues.setOutputMarkupId(true));
+
+		form.add(new AjaxSubmitLink("submit")
+		{
+			@Override
+			protected void onError(AjaxRequestTarget target, Form<?> form)
+			{
+				super.onError(target, form);
+				target.add(feedback);
+			}
+
+			@Override
+			protected void onSubmit(AjaxRequestTarget target, Form<?> form)
+			{
+				super.onSubmit(target, form);
+				String values = "Your name is: " + nameField.getModelObject() + " " + surnameField.getModelObject();
+				submittedValues.setDefaultModelObject(values);
+				target.add(feedback, submittedValues);
+			}
+			
+			@Override
+			protected boolean getStatelessHint()
+			{
+				return true;
+			}
+		});
+
+		add(form);
+
+		add(select);
+
+
+		add(new IndicatingAjaxFallbackLink("indicatingLink")
+		{
+			@Override
+			public void onClick(AjaxRequestTarget target)
+			{
+				try
+				{
+					Thread.sleep(5000); // 1000 milliseconds is one second.
+				}
+				catch (InterruptedException ex)
+				{
+					Thread.currentThread().interrupt();
+				}
+			}
+			
+			@Override
+			protected boolean getStatelessHint()
+			{
+				return true;
+			}
+		});
+
+		StatelessForm indicatingForm = new StatelessForm("indicatingForm");
+
+		add(indicatingForm);
+		add(new IndicatingAjaxButton("indicatingButton", indicatingForm)
+		{
+			@Override
+			protected void onSubmit(AjaxRequestTarget target, Form<?> form)
+			{
+				try
+				{
+					Thread.sleep(5000); // 1000 milliseconds is one second.
+				}
+				catch (InterruptedException ex)
+				{
+					Thread.currentThread().interrupt();
+				}
+			}
+			
+			@Override
+			protected boolean getStatelessHint()
+			{
+				return true;
+			}
+		});
+
+	}
+
+	private String getParameter(final PageParameters parameters, final String key)
+	{
+		final StringValue value = parameters.get(key);
+
+		if (value.isNull() || value.isEmpty())
+		{
+			return null;
+		}
+
+		return value.toString();
+	}
+
+	protected final void updateParams(final PageParameters pageParameters, final int counter)
+	{
+		pageParameters.set(COUNTER_PARAM, Integer.toString(counter + 1));
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.html b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.html
index 4c4a4fb..4239cc9 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.html
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.html
@@ -18,6 +18,9 @@
 		<br />
 		<a wicket:id="linkToStatefulPage" href="#">go to a stateful page (triggers session creation if not already done so)</a>
 		<br />
+		<a wicket:id="linkToAjaxExamples" href="#">Stateless AJAX Example</a>
+		<br/>
+		<br/>
 		<a wicket:id="invalidatesession" href="#">Invalidate the session</a>
 	</body>
 </html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.java b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.java
index 5b86437..95b7dea 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/stateless/Index.java
@@ -61,6 +61,19 @@ public class Index extends WicketExamplePage
 				setResponsePage(StatefulPage.class);
 			}
 		});
+		add(new StatelessLink<Void>("linkToAjaxExamples")
+		{
+			private static final long serialVersionUID = 1L;
+			
+			/**
+			 * @see org.apache.wicket.markup.html.link.Link#onClick()
+			 */
+			@Override
+			public void onClick()
+			{
+				setResponsePage(AjaxStatelessExample.class);
+			}
+		});
 		add(new StatelessLink<Void>("invalidatesession")
 		{
 			private static final long serialVersionUID = 1L;

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/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 83650d4..dd01c1f 100644
--- a/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
@@ -1,7 +1,44 @@
+Wicket makes working with AJAX easy and pleasant with its component-oriented abstraction. However as side effect, AJAX components and behaviors make their hosting page stateful. This can be quite annoying if we are working on a page that must be stateless (for example a login page).
+Starting from version 7.4.0 Wicket has made quite easy forcing existing AJAX components to be stateless. All we have to do is to override component's method @getStatelessHint@ returning true:
 
+{code}
+final Link<?> incrementLink = new AjaxFallbackLink<Void>("incrementLink")
+{
 
-AJAX is another example of how Wicket can simplify web technologies providing a good component and object oriented abstraction of them. 
+    ...
+    
+    @Override
+    protected boolean getStatelessHint()
+    {
+        return true;
+    }
+};
+{code}
 
-In this chapter we have seen how to take advantage of the AJAX support provided by Wicket to write AJAX-enhanced applications. Most of the chapter has been dedicated to the built-in components and behaviors that let us adopt AJAX without almost any effort. 
 
-In the final part of the chapter we have seen how Wicket physically implements an AJAX call on client side using AJAX request attributes. Then, we have learnt how to use call listeners to execute custom JavaScript during AJAX request lifecycle.
+Just like components also AJAX behaviors can be turned to stateless overriding @getStatelessHint(Component component)@
+
+{code}
+ final AjaxFormSubmitBehavior myBehavior = new AjaxFormSubmitBehavior(form, event)
+ {
+    ...
+    
+    @Override
+    protected boolean getStatelessHint(Component component)
+    {
+        return true;
+    }
+};
+{code}
+
+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.
+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:
+
+{code}
+   <span id="staticIdToUSe" wicket:id="componentWicketId"></span>
+{code}
+
+See examples site for a full showcase of AJAX-stateless capabilities.

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc b/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc
new file mode 100644
index 0000000..83650d4
--- /dev/null
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc
@@ -0,0 +1,7 @@
+
+
+AJAX is another example of how Wicket can simplify web technologies providing a good component and object oriented abstraction of them. 
+
+In this chapter we have seen how to take advantage of the AJAX support provided by Wicket to write AJAX-enhanced applications. Most of the chapter has been dedicated to the built-in components and behaviors that let us adopt AJAX without almost any effort. 
+
+In the final part of the chapter we have seen how Wicket physically implements an AJAX call on client side using AJAX request attributes. Then, we have learnt how to use call listeners to execute custom JavaScript during AJAX request lifecycle.

http://git-wip-us.apache.org/repos/asf/wicket/blob/96ba4888/wicket-user-guide/src/docs/guide/toc.yml
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/toc.yml b/wicket-user-guide/src/docs/guide/toc.yml
index b0e7631..537ae51 100644
--- a/wicket-user-guide/src/docs/guide/toc.yml
+++ b/wicket-user-guide/src/docs/guide/toc.yml
@@ -154,7 +154,8 @@ ajax:
   ajax_4: Using an activity indicator
   ajax_5: AJAX request attributes and call listeners
   ajax_6: Creating custom AJAX call listener
-  ajax_7: Summary
+  ajax_7: Stateless AJAX components/behaviors
+  ajax_8: Summary
 jee:
   title: Integration with enterprise containers
   jee_1: Integrating Wicket with EJB


[17/21] wicket git commit: WICKET-6174 guard against #javaEnabled() returning undefined

Posted by ad...@apache.org.
WICKET-6174 guard against #javaEnabled() returning undefined


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

Branch: refs/heads/WICKET-6183
Commit: db90877cca819c7675d88eae80aa3b4eb315fac2
Parents: e70e662
Author: Sven Meier <sv...@apache.org>
Authored: Wed Jun 1 21:16:22 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu Jun 9 11:17:06 2016 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/markup/html/pages/wicket-browser-info.js     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/db90877c/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
index 528ff44..0d524af 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/pages/wicket-browser-info.js
@@ -49,7 +49,7 @@
 					cookieEnabled = (document.cookie.indexOf("wickettestcookie") !== -1);
 				}
 				info.navigatorCookieEnabled = cookieEnabled;
-				info.navigatorJavaEnabled =  window.navigator.javaEnabled();
+				info.navigatorJavaEnabled = window.navigator.javaEnabled() || false;
 				info.navigatorLanguage = window.navigator.language ? window.navigator.language : window.navigator.userLanguage;
 				info.navigatorPlatform = window.navigator.platform;
 				info.navigatorUserAgent = window.navigator.userAgent;


[09/21] wicket git commit: WICKET-6155 escape JavaScript object values

Posted by ad...@apache.org.
WICKET-6155 escape JavaScript object values


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

Branch: refs/heads/WICKET-6183
Commit: be7cd7cf4201a01e860321fab813aeecbdc18eb9
Parents: 96ba488
Author: Sven Meier <sv...@apache.org>
Authored: Fri May 20 17:26:01 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../examples/ajax/builtin/modal/ModalWindowPage.java     |  2 +-
 .../extensions/ajax/markup/html/modal/ModalWindow.java   | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/be7cd7cf/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java
index ed40cb5..49b9440 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java
@@ -91,7 +91,7 @@ public class ModalWindowPage extends BasePage
 		add(modal2 = new ModalWindow("modal2"));
 
 		modal2.setContent(new ModalPanel1(modal2.getContentId()));
-		modal2.setTitle("This is modal window with panel content.");
+		modal2.setTitle("Modal window\n'panel\" content.");
 		modal2.setCookieName("modal-2");
 
 		modal2.setCloseButtonCallback(new ModalWindow.CloseButtonCallback()

http://git-wip-us.apache.org/repos/asf/wicket/blob/be7cd7cf/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
index bab4c36..f3ef575 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
@@ -42,6 +42,7 @@ import org.apache.wicket.resource.CoreLibrariesContributor;
 import org.apache.wicket.util.io.IClusterable;
 import org.apache.wicket.util.lang.EnumeratedType;
 import org.apache.wicket.util.string.AppendingStringBuffer;
+import org.apache.wicket.util.string.Strings;
 
 /**
  * Modal window component.
@@ -1163,10 +1164,16 @@ public class ModalWindow extends Panel
 	 * @param key
 	 * @param value
 	 */
-	private void appendAssignment(final AppendingStringBuffer buffer, final CharSequence key,
-		final CharSequence value)
+	private void appendAssignment(final AppendingStringBuffer buffer, final CharSequence key, CharSequence value)
 	{
 		buffer.append(key).append("=\"");
+		
+		if (value != null)
+		{
+			value = Strings.replaceAll(value, "\"", "\\\"");
+			value = Strings.replaceAll(value, "\n", "\\n");
+		}
+		
 		buffer.append(value);
 		buffer.append("\";\n");
 	}


[04/21] wicket git commit: Add "@throws IllegalStateException" javadoc to Component#setDefaultModelObject()

Posted by ad...@apache.org.
Add "@throws IllegalStateException" javadoc to Component#setDefaultModelObject()


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

Branch: refs/heads/WICKET-6183
Commit: da37b302a7bfd04dfd50ac2c0d9a6af025fd997d
Parents: 41705d8
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun May 22 08:11:22 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 wicket-core/src/main/java/org/apache/wicket/Component.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/da37b302/wicket-core/src/main/java/org/apache/wicket/Component.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 7d412d8..01d5e46 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -3056,6 +3056,8 @@ public abstract class Component
 	 * @param object
 	 *            The object to set
 	 * @return This
+	 * @throws IllegalStateException If the component has neither its own model nor any of its
+	 * parents uses {@link IComponentInheritedModel}
 	 */
 	@SuppressWarnings("unchecked")
 	public final Component setDefaultModelObject(final Object object)


[03/21] wicket git commit: WICKET-6154 move provider registration to factory, so the check for the cipher's availability is done once only

Posted by ad...@apache.org.
WICKET-6154 move provider registration to factory, so the check for the cipher's availability is done once only


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

Branch: refs/heads/WICKET-6183
Commit: c6f53a649575ff0944e32f6a45896fbaa80bbf80
Parents: da37b30
Author: Sven Meier <sv...@apache.org>
Authored: Mon May 2 23:12:05 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../crypt/KeyInSessionSunJceCryptFactory.java   | 27 +++++++++++++++++---
 .../apache/wicket/util/crypt/SunJceCrypt.java   | 18 -------------
 2 files changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/c6f53a64/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
index 5b3bae6..ceedcfc 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
@@ -16,6 +16,8 @@
  */
 package org.apache.wicket.core.util.crypt;
 
+import java.security.Provider;
+import java.security.Security;
 import java.util.UUID;
 
 import org.apache.wicket.MetaDataKey;
@@ -26,11 +28,11 @@ import org.apache.wicket.util.crypt.SunJceCrypt;
 import org.apache.wicket.util.lang.Args;
 
 /**
- * Crypt factory that produces {@link SunJceCrypt} instances based on http session-specific
- * encryption key. This allows each user to have their own encryption key, hardening against CSRF
+ * Crypt factory that produces {@link SunJceCrypt} instances based on session-specific
+ * encryption key. This allows each user to have his own encryption key, hardening against CSRF
  * attacks.
- *
- * Note that the use of this crypt factory will result in an immediate creation of a http session
+ * <br>
+ * Note that the use of this crypt factory will result in an immediate creation of a session.
  *
  * @author igor.vaynberg
  */
@@ -61,6 +63,23 @@ public class KeyInSessionSunJceCryptFactory implements ICryptFactory
 	public KeyInSessionSunJceCryptFactory(String cryptMethod)
 	{
 		this.cryptMethod = Args.notNull(cryptMethod, "Crypt method");
+
+
+		if (Security.getProviders("Cipher." + cryptMethod).length > 0)
+		{
+			return; // we are good to go!
+		}
+		try
+		{
+			// Initialize and add a security provider required for encryption
+			final Class<?> clazz = Class.forName("com.sun.crypto.provider.SunJCE");
+
+			Security.addProvider((Provider)clazz.newInstance());
+		}
+		catch (Exception ex)
+		{
+			throw new RuntimeException("Unable to load SunJCE service provider", ex);
+		}
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/wicket/blob/c6f53a64/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
index 934f586..778cfb0 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
@@ -18,8 +18,6 @@ package org.apache.wicket.util.crypt;
 
 import java.security.GeneralSecurityException;
 import java.security.NoSuchAlgorithmException;
-import java.security.Provider;
-import java.security.Security;
 import java.security.spec.AlgorithmParameterSpec;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.KeySpec;
@@ -77,22 +75,6 @@ public class SunJceCrypt extends AbstractCrypt
 	public SunJceCrypt(String cryptMethod)
 	{
 		this.cryptMethod = Args.notNull(cryptMethod, "Crypt method");
-
-		if (Security.getProviders("Cipher." + cryptMethod).length > 0)
-		{
-			return; // we are good to go!
-		}
-		try
-		{
-			// Initialize and add a security provider required for encryption
-			final Class<?> clazz = Class.forName("com.sun.crypto.provider.SunJCE");
-
-			Security.addProvider((Provider)clazz.newInstance());
-		}
-		catch (Exception ex)
-		{
-			throw new RuntimeException("Unable to load SunJCE service provider", ex);
-		}
 	}
 
 	/**


[20/21] wicket git commit: Merge branch 'wicket-7.x' into ajax-stateless

Posted by ad...@apache.org.
Merge branch 'wicket-7.x' into ajax-stateless


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

Branch: refs/heads/WICKET-6183
Commit: 186aac925985be2249c6bcc419df035f95ed91f7
Parents: d1b4ce5 e0bfaf7
Author: Andrea Del Bene <ad...@apache.org>
Authored: Fri Jun 17 16:09:20 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri Jun 17 16:09:20 2016 +0200

----------------------------------------------------------------------
 README                                          |  2 +-
 pom.xml                                         |  2 +-
 .../java/org/apache/wicket/jmx/Initializer.java | 18 +++++++
 wicket-user-guide/grails-app/conf/Config.groovy |  2 +
 wicket-user-guide/pom.xml                       | 13 +----
 wicket-user-guide/scripts/_Events.groovy        | 51 ++++++++++++++++++--
 .../src/docs/guide/ajax/ajax_2.gdoc             |  4 +-
 .../src/docs/guide/forms2/forms2_8.gdoc         |  2 +-
 .../src/docs/guide/howToSource.gdoc             |  2 +-
 .../src/docs/guide/introduction.gdoc            |  2 +-
 .../src/docs/guide/repeaters/repeaters_4.gdoc   |  2 +-
 .../guide/testingspring/testingspring_1.gdoc    |  8 +--
 12 files changed, 82 insertions(+), 26 deletions(-)
----------------------------------------------------------------------



[05/21] wicket git commit: WICKET-6154 Performance bottleneck when using KeyInSessionSunJceCryptFactory

Posted by ad...@apache.org.
WICKET-6154 Performance bottleneck when using KeyInSessionSunJceCryptFactory

Reduce the complexity of the method by removing a conditional branch that is not really needed.

Note: Security#getProviders() javadoc states that it may return null but the implementation (and the years in usage) show that it actually returns empty array


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

Branch: refs/heads/WICKET-6183
Commit: 77e1e856b024f79b6e30a4dcc94fc91bf49cb9c8
Parents: c6f53a6
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun May 22 10:44:49 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../crypt/KeyInSessionSunJceCryptFactory.java   | 25 ++++++++++----------
 1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/77e1e856/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
index ceedcfc..ce3037e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
@@ -64,21 +64,20 @@ public class KeyInSessionSunJceCryptFactory implements ICryptFactory
 	{
 		this.cryptMethod = Args.notNull(cryptMethod, "Crypt method");
 
-
-		if (Security.getProviders("Cipher." + cryptMethod).length > 0)
-		{
-			return; // we are good to go!
-		}
-		try
+		if (Security.getProviders("Cipher." + cryptMethod).length == 0)
 		{
-			// Initialize and add a security provider required for encryption
-			final Class<?> clazz = Class.forName("com.sun.crypto.provider.SunJCE");
+			try
+			{
+				// Initialize and add a security provider required for encryption
+				final Class<?> clazz = Class.forName("com.sun.crypto.provider.SunJCE");
 
-			Security.addProvider((Provider)clazz.newInstance());
-		}
-		catch (Exception ex)
-		{
-			throw new RuntimeException("Unable to load SunJCE service provider", ex);
+				final Provider provider = (Provider) clazz.newInstance();
+				Security.addProvider(provider);
+			}
+			catch (Exception ex)
+			{
+				throw new RuntimeException("Unable to load SunJCE service provider", ex);
+			}
 		}
 	}
 


[16/21] wicket git commit: WICKET-6173 WICKET-6172 makes TagTester.createTagsByAttribute stop working

Posted by ad...@apache.org.
WICKET-6173 WICKET-6172 makes TagTester.createTagsByAttribute stop
working

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

Branch: refs/heads/WICKET-6183
Commit: 86009a4436cf76b76a12e3c7f4dcb886c2041cf0
Parents: 37906ba
Author: Andrea Del Bene <ad...@apache.org>
Authored: Tue May 31 22:36:59 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu Jun 9 11:17:06 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/util/tester/TagTester.java |  3 ++-
 .../org/apache/wicket/util/tester/TagTesterTest.java  | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/86009a44/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
index e2cc83c..c6818f6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
@@ -24,6 +24,7 @@ import java.util.regex.Pattern;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.parser.XmlPullParser;
 import org.apache.wicket.markup.parser.XmlTag;
+import org.apache.wicket.markup.parser.filter.HtmlHandler;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.value.IValueMap;
@@ -671,7 +672,7 @@ public class TagTester
 						openTag = null;
 						closeTag = null;
 					}
-					else if (openTag != null)
+					else if (openTag != null && !HtmlHandler.requiresCloseTag(openTag.getName()))
 					{
 						TagTester tester = new TagTester(parser, openTag, openTag);
 						testers.add(tester);

http://git-wip-us.apache.org/repos/asf/wicket/blob/86009a44/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
index 9a60a88..e7863a8 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
@@ -21,11 +21,11 @@ import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 
+import java.util.List;
+
 import org.junit.Assert;
 import org.junit.Test;
 
-import java.util.List;
-
 /**
  * Test of TagTester
  */
@@ -330,4 +330,14 @@ public class TagTesterTest extends Assert
 		TagTester tagTester2 = TagTester.createTagByAttribute(MARKUP_1, "id", "test");
 		assertEquals(tagTester.getMarkup(), tagTester2.getValue());
 	}
+	
+	/**
+	 * https://issues.apache.org/jira/browse/WICKET-6173
+	 */
+	@Test
+	public void valueFromTagsByAttribute()
+	{
+		TagTester tagTester = TagTester.createTagsByAttribute(MARKUP_1, "id", "test2");
+		assertEquals("mock", tagTester.getValue());
+	}
 }


[13/21] wicket git commit: Stateless components

Posted by ad...@apache.org.
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.


[06/21] wicket git commit: WICKET-6169 NullPointerException accessing AbstractRequestLogger.getLiveSessions

Posted by ad...@apache.org.
WICKET-6169 NullPointerException accessing AbstractRequestLogger.getLiveSessions


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

Branch: refs/heads/WICKET-6183
Commit: 0a6a96bcbf42b7d4a31065c23fa36260b454f371
Parents: be7cd7c
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sat May 21 13:09:17 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../protocol/http/AbstractRequestLogger.java    |   3 +-
 .../http/RequestLoggerLiveSessionsTest.java     | 123 +++++++++++++++++++
 2 files changed, 124 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/0a6a96bc/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java
index 0c5d7d0..8cb8fcd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java
@@ -134,8 +134,7 @@ public abstract class AbstractRequestLogger implements IRequestLogger
 	@Override
 	public SessionData[] getLiveSessions()
 	{
-		final SessionData[] sessions = liveSessions.values().toArray(
-			new SessionData[liveSessions.values().size()]);
+		final SessionData[] sessions = liveSessions.values().toArray(new SessionData[0]);
 		Arrays.sort(sessions);
 		return sessions;
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/0a6a96bc/wicket-core/src/test/java/org/apache/wicket/protocol/http/RequestLoggerLiveSessionsTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/RequestLoggerLiveSessionsTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/RequestLoggerLiveSessionsTest.java
new file mode 100644
index 0000000..edbc552
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/RequestLoggerLiveSessionsTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.protocol.http;
+
+import org.apache.wicket.util.SlowTests;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.ArrayList;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Test for https://issues.apache.org/jira/browse/WICKET-6169
+ */
+@Category(SlowTests.class)
+public class RequestLoggerLiveSessionsTest 
+{
+	private final RequestLogger requestLogger = new RequestLogger();
+	
+	private final ArrayList<String> sessionIds = new ArrayList<>();
+
+	@Test
+	public void concurrentModification() {
+		SessionCreateThread sct = new SessionCreateThread();
+		SessionDestroyThread sdt = new SessionDestroyThread();
+		sct.start();
+		sdt.start();
+		AtomicBoolean nullPointerExceptionThrown = new AtomicBoolean(false);
+
+		int count = 10000000;
+
+		while (count-- > 0)
+		{
+			try {
+				requestLogger.getLiveSessions();
+			}
+			catch (NullPointerException e)
+			{
+				e.printStackTrace();
+				nullPointerExceptionThrown.set(true);
+				break;
+			}
+		}
+
+		sct.interrupt();
+		sdt.interrupt();
+
+		if (nullPointerExceptionThrown.get()) {
+			Assert.fail("The test should not fail with NullPointerException");
+		}
+	}
+	
+	private class SessionCreateThread extends Thread
+	{
+		private final Random random = new Random();
+		
+		public void run()
+		{
+			while (!isInterrupted())
+			{
+				if (sessionIds.size() < 50)
+				{
+					String sessionId = UUID.randomUUID().toString();
+					synchronized (sessionIds) {
+						sessionIds.add(sessionId);
+					}
+					requestLogger.sessionCreated(sessionId);
+				}
+				
+				try
+				{
+					Thread.sleep(random.nextInt(20));
+				}
+					catch (InterruptedException e) {
+				}
+			}
+		}
+	}
+
+	private class SessionDestroyThread extends Thread
+	{
+		private final Random random = new Random();
+		
+		public void run()
+		{
+			while (!isInterrupted())
+			{
+				if (sessionIds.size() > 0)
+				{
+					String sessionId = sessionIds.get(random.nextInt(sessionIds.size()));
+					requestLogger.sessionDestroyed(sessionId);
+					synchronized (sessionIds) {
+						sessionIds.remove(sessionId);
+					}
+				}
+				
+				try
+				{
+					Thread.sleep(random.nextInt(20));
+				}
+					catch (InterruptedException e) {
+				}
+			}
+		}
+	}
+}


[11/21] wicket git commit: WICKET-6169 NullPointerException accessing AbstractRequestLogger.getLiveSessions

Posted by ad...@apache.org.
WICKET-6169 NullPointerException accessing AbstractRequestLogger.getLiveSessions

Fix some more candidates for the same problem.
Remove implicit modifiers


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

Branch: refs/heads/WICKET-6183
Commit: 6966326f05e6fcbc782568eaee073e389d53f191
Parents: 0a6a96b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sat May 21 13:11:29 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/protocol/http/IRequestLogger.java | 8 ++++----
 .../wicket/protocol/http/AbstractRequestLoggerTest.java      | 1 -
 .../java/org/apache/wicket/jmx/wrapper/ResourceSettings.java | 2 +-
 .../org/apache/wicket/protocol/ws/api/HttpSessionCopy.java   | 2 +-
 .../wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java    | 2 +-
 .../apache/wicket/spring/test/ApplicationContextMock.java    | 2 +-
 .../main/java/org/apache/wicket/util/string/StringList.java  | 2 +-
 7 files changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/6966326f/wicket-core/src/main/java/org/apache/wicket/protocol/http/IRequestLogger.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/IRequestLogger.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/IRequestLogger.java
index acb91b1..36f0ca7 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/IRequestLogger.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/IRequestLogger.java
@@ -163,14 +163,14 @@ public interface IRequestLogger
 	/**
 	 * Perform the actual logging
 	 */
-	public void performLogging();
+	void performLogging();
 
 	/**
 	 * This class hold the information one request of a session has.
 	 * 
 	 * @author jcompagner
 	 */
-	public static class SessionData implements IClusterable, Comparable<SessionData>
+	class SessionData implements IClusterable, Comparable<SessionData>
 	{
 		private static final long serialVersionUID = 1L;
 
@@ -304,7 +304,7 @@ public interface IRequestLogger
 	 * 
 	 * @author jcompagner
 	 */
-	public static class RequestData implements IClusterable
+	class RequestData implements IClusterable
 	{
 		private static final long serialVersionUID = 1L;
 
@@ -560,7 +560,7 @@ public interface IRequestLogger
 	 * 
 	 * @author jcompagner
 	 */
-	public interface ISessionLogInfo
+	interface ISessionLogInfo
 	{
 		/**
 		 * If you use the request logger log functionality then this object should have a nice

http://git-wip-us.apache.org/repos/asf/wicket/blob/6966326f/wicket-core/src/test/java/org/apache/wicket/protocol/http/AbstractRequestLoggerTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/AbstractRequestLoggerTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/AbstractRequestLoggerTest.java
index a5bdc22..86ec61e 100644
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/AbstractRequestLoggerTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/AbstractRequestLoggerTest.java
@@ -25,7 +25,6 @@ import org.junit.Test;
  */
 public class AbstractRequestLoggerTest extends WicketTestCase
 {
-
 	private int counter;
 	
 	@Test

http://git-wip-us.apache.org/repos/asf/wicket/blob/6966326f/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/ResourceSettings.java
----------------------------------------------------------------------
diff --git a/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/ResourceSettings.java b/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/ResourceSettings.java
index b03de01..863804d 100644
--- a/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/ResourceSettings.java
+++ b/wicket-jmx/src/main/java/org/apache/wicket/jmx/wrapper/ResourceSettings.java
@@ -120,7 +120,7 @@ public class ResourceSettings implements ResourceSettingsMBean
 			{
 				list.add(loader.toString());
 			}
-			return list.toArray(new String[loaders.size()]);
+			return list.toArray(new String[0]);
 		}
 		return null;
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/6966326f/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/HttpSessionCopy.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/HttpSessionCopy.java b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/HttpSessionCopy.java
index 6423ab2..1b9da35 100644
--- a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/HttpSessionCopy.java
+++ b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/HttpSessionCopy.java
@@ -117,7 +117,7 @@ public class HttpSessionCopy implements HttpSession
 	@Override
 	public String[] getValueNames()
 	{
-		return Collections.list(attributes.keys()).toArray(new String[attributes.size()]);
+		return Collections.list(attributes.keys()).toArray(new String[0]);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/wicket/blob/6966326f/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java
----------------------------------------------------------------------
diff --git a/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java b/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java
index 699337b..bf22062 100644
--- a/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java
+++ b/wicket-native-websocket/wicket-native-websocket-javax/src/main/java/org/apache/wicket/protocol/ws/javax/JavaxUpgradeHttpRequest.java
@@ -87,7 +87,7 @@ public class JavaxUpgradeHttpRequest implements HttpServletRequest
 			{
 				String name = entry.getKey();
 				List<String> value = entry.getValue();
-				parametersMap.put(name, value.toArray(new String[value.size()]));
+				parametersMap.put(name, value.toArray(new String[0]));
 			}
 		}
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/6966326f/wicket-spring/src/main/java/org/apache/wicket/spring/test/ApplicationContextMock.java
----------------------------------------------------------------------
diff --git a/wicket-spring/src/main/java/org/apache/wicket/spring/test/ApplicationContextMock.java b/wicket-spring/src/main/java/org/apache/wicket/spring/test/ApplicationContextMock.java
index 290ed61..cd3ad09 100644
--- a/wicket-spring/src/main/java/org/apache/wicket/spring/test/ApplicationContextMock.java
+++ b/wicket-spring/src/main/java/org/apache/wicket/spring/test/ApplicationContextMock.java
@@ -249,7 +249,7 @@ public class ApplicationContextMock implements ApplicationContext, Serializable
 	@Override
 	public String[] getBeanDefinitionNames()
 	{
-		return beans.keySet().toArray(new String[beans.size()]);
+		return beans.keySet().toArray(new String[0]);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/wicket/blob/6966326f/wicket-util/src/main/java/org/apache/wicket/util/string/StringList.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/string/StringList.java b/wicket-util/src/main/java/org/apache/wicket/util/string/StringList.java
index bc20076..e052cf8 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/string/StringList.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/string/StringList.java
@@ -376,7 +376,7 @@ public final class StringList extends AbstractStringList
 	@Override
 	public String[] toArray()
 	{
-		return strings.toArray(new String[size()]);
+		return strings.toArray(new String[0]);
 	}
 
 	/**


[14/21] wicket git commit: Added javadoc

Posted by ad...@apache.org.
Added javadoc

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

Branch: refs/heads/WICKET-6183
Commit: f5fae5ac2ed2a0a6e229fef81479062bf38ecfd8
Parents: 9221e61
Author: Andrea Del Bene <ad...@apache.org>
Authored: Tue May 31 18:32:24 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Tue May 31 18:32:24 2016 +0200

----------------------------------------------------------------------
 .../apache/wicket/ajax/AbstractDefaultAjaxBehavior.java |  2 +-
 .../org/apache/wicket/ajax/markup/html/AjaxLink.java    | 12 ++++++++++++
 .../wicket/ajax/markup/html/StatelessAjaxLink.java      | 10 ++++++++++
 .../apache/wicket/ajax/markup/html/form/AjaxButton.java |  6 ++++++
 .../wicket/ajax/markup/html/form/AjaxSubmitLink.java    |  7 +++++++
 .../ajax/markup/html/form/StatelessAjaxButton.java      | 11 ++++++++++-
 .../ajax/markup/html/form/StatelessAjaxSubmitLink.java  | 11 ++++++++++-
 wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc       |  2 +-
 8 files changed, 57 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
index 3766b98..b95d24c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
@@ -88,7 +88,7 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior
 		if (getStatelessHint(component))
 		{
 			//generate behavior id
-	        component.getBehaviorId(this);
+			component.getBehaviorId(this);
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java
index 359edd5..825c0f2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket.ajax.markup.html;
 
+import org.apache.wicket.Component;
 import org.apache.wicket.IGenericComponent;
 import org.apache.wicket.ajax.AjaxEventBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -90,6 +91,12 @@ public abstract class AjaxLink<T> extends AbstractLink implements IAjaxLink, IGe
 				super.updateAjaxAttributes(attributes);
 				AjaxLink.this.updateAjaxAttributes(attributes);
 			}
+			
+			@Override
+			public boolean getStatelessHint(Component component)
+			{
+				return AjaxLink.this.getStatelessHint();
+			}
 		};
 	}
 
@@ -159,4 +166,9 @@ public abstract class AjaxLink<T> extends AbstractLink implements IAjaxLink, IGe
 		setDefaultModelObject(object);
 	}
 
+	@Override
+	protected boolean getStatelessHint()
+	{
+		return false;
+	}
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/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
index d083b23..d93c282 100644
--- 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
@@ -16,8 +16,18 @@
  */
 package org.apache.wicket.ajax.markup.html;
 
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
 import org.apache.wicket.model.IModel;
 
+/**
+ * Stateless version of {@link AjaxSubmitLink}. As such, it must not relay on 
+ * page status and must be provided with a static id (see user guide).
+ * 
+ * @author andrea del bene
+ *
+ * @param <T>
+ *            type of model object
+ */
 public abstract class StatelessAjaxLink<T> extends AjaxLink<T>
 {
 	private static final long serialVersionUID = 5580337001313353237L;

http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
index 83b5d8b..9a03463 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
@@ -230,4 +230,10 @@ public abstract class AjaxButton extends Button
 	protected void onError(AjaxRequestTarget target, Form<?> form)
 	{
 	}
+	
+	@Override
+	protected boolean getStatelessHint()
+	{
+		return false;
+	}
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
index b1bf987..f032552 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
@@ -219,4 +219,11 @@ public abstract class AjaxSubmitLink extends AbstractSubmitLink
 	{
 		logger.warn("unexpected invocation of #onAfterSubmit() on {}", this);
 	}
+	
+	
+	@Override
+	protected boolean getStatelessHint()
+	{
+		return false;
+	}
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/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
index 7e3c4af..43e825f 100644
--- 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
@@ -19,7 +19,16 @@ 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
+/**
+ * Stateless version of {@link AjaxButton}. As such, it must not relay on 
+ * page status and must be provided with a static id (see user guide).
+ * 
+ * @author andrea del bene
+ *
+ * @param <T>
+ *            type of model object
+ */
+public abstract class StatelessAjaxButton extends AjaxButton
 {
 	private static final long serialVersionUID = -3625309953596700148L;
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/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
index bd710fb..13601ec 100644
--- 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
@@ -18,7 +18,16 @@ package org.apache.wicket.ajax.markup.html.form;
 
 import org.apache.wicket.markup.html.form.Form;
 
-public class StatelessAjaxSubmitLink extends AjaxSubmitLink
+/**
+ * Stateless version of {@link AjaxSubmitLink}. As such, it must not relay on 
+ * page status and must be provided with a static id (see user guide).
+ * 
+ * @author andrea del bene
+ *
+ * @param <T>
+ *            type of model object
+ */
+public abstract class StatelessAjaxSubmitLink extends AjaxSubmitLink
 {
 	private static final long serialVersionUID = -3175689678864002395L;
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/f5fae5ac/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 e23f5c5..47f9c98 100644
--- a/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
@@ -38,7 +38,7 @@ However in this case calling @setOutputMarkupId@ on a component is not enough. S
 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>
+   <span id="staticIdToUse" wicket:id="componentWicketId"></span>
 {code}
 
 [See examples site|http://examples7x.wicket.apache.org/stateless] for a full showcase of AJAX-stateless capabilities.


[15/21] wicket git commit: WICKET-6175 Aautocomplete suggestion window is not closing in IE11

Posted by ad...@apache.org.
WICKET-6175 Aautocomplete suggestion window is not closing in IE11


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

Branch: refs/heads/WICKET-6183
Commit: e70e662d8fdfe13821789fe7bd6cf50850f35263
Parents: 86009a4
Author: Andrea Del Bene <ad...@apache.org>
Authored: Wed Jun 1 19:13:24 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu Jun 9 11:17:06 2016 +0200

----------------------------------------------------------------------
 .../ajax/markup/html/autocomplete/wicket-autocomplete.js         | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e70e662d/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
index f70deec..805ccb0 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
@@ -95,7 +95,9 @@
 				//'blur' event on input field. (See https://issues.apache.org/jira/browse/WICKET-5882)
 				if (containerId !== document.activeElement.id) {
 					window.setTimeout(hideAutoComplete, 500);
-				}				
+				} else {
+					jQuery(this).trigger("focus");
+				}
 			});
 
 			Wicket.Event.add(obj, 'focus', function (jqEvent) {


[12/21] wicket git commit: WICKET-6170 Wrong requestmapper used for cache decorated resources

Posted by ad...@apache.org.
WICKET-6170 Wrong requestmapper used for cache decorated resources

Undecorate the url before passing it for compatibility score calculation.


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

Branch: refs/heads/WICKET-6183
Commit: c1ea238e09f17f97530bb30035bffa974e7132f2
Parents: 6966326
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sat May 21 13:37:36 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../core/request/mapper/ResourceMapper.java     |  7 ++-
 ...esourceMapperWithDecoratedResourcesTest.java | 61 ++++++++++++++++++++
 .../core/request/mapper/decorated-resource.css  |  1 +
 3 files changed, 68 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/c1ea238e/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
index d89543e..b6565be 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
@@ -172,7 +172,12 @@ public class ResourceMapper extends AbstractBookmarkableMapper
 	@Override
 	public int getCompatibilityScore(Request request)
 	{
-		int score = super.getCompatibilityScore(request);
+		Url originalUrl = new Url(request.getUrl());
+		PageParameters parameters = extractPageParameters(request, mountSegments.length, parametersEncoder);
+		removeCachingDecoration(originalUrl, parameters);
+		Request requestWithoutDecoration = request.cloneWithUrl(originalUrl);
+
+		int score = super.getCompatibilityScore(requestWithoutDecoration);
 		if (score > 0)
 		{
 			score--; // pages always have priority over resources

http://git-wip-us.apache.org/repos/asf/wicket/blob/c1ea238e/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperWithDecoratedResourcesTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperWithDecoratedResourcesTest.java b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperWithDecoratedResourcesTest.java
new file mode 100644
index 0000000..6cacfbb
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/ResourceMapperWithDecoratedResourcesTest.java
@@ -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.
+ */
+package org.apache.wicket.core.request.mapper;
+
+import org.apache.wicket.mock.MockApplication;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.request.HomePage;
+import org.apache.wicket.request.resource.CssResourceReference;
+import org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy;
+import org.apache.wicket.request.resource.caching.version.CachingResourceVersion;
+import org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion;
+import org.apache.wicket.util.tester.WicketTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ * Simple test using the WicketTester
+ */
+public class ResourceMapperWithDecoratedResourcesTest extends WicketTestCase {
+
+	@Override
+	protected WebApplication newApplication() {
+		return new MockApplication() {
+			@Override
+			public void init() {
+				super.init();
+				getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy(
+						new CachingResourceVersion(new MessageDigestResourceVersion())));
+				mountResource("stylesheet.css", new CssResourceReference(ResourceMapperWithDecoratedResourcesTest.class, "decorated-resource.css"));
+				mountPage("/", HomePage.class);
+			}
+		};
+	}
+
+	@Test
+	public void resourceNoCacheDecorationSuccessfully() {
+		tester.executeUrl("stylesheet.css");
+		Assert.assertEquals("body { background-color: lightblue; }", tester.getLastResponseAsString());
+	}
+	
+	@Test
+	public void resourceWithCacheDecorationSuccessfully() {
+		tester.executeUrl("stylesheet-ver-9876543210.css");
+		Assert.assertEquals("body { background-color: lightblue; }", tester.getLastResponseAsString());
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/c1ea238e/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/decorated-resource.css
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/decorated-resource.css b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/decorated-resource.css
new file mode 100644
index 0000000..57a5407
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/decorated-resource.css
@@ -0,0 +1 @@
+body { background-color: lightblue; }
\ No newline at end of file


[21/21] wicket git commit: Minor addition to gdoc

Posted by ad...@apache.org.
Minor addition to gdoc


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

Branch: refs/heads/WICKET-6183
Commit: b87b91b3411d46b3762f39f3171c579645688af3
Parents: 186aac92
Author: Andrea Del Bene <ad...@apache.org>
Authored: Fri Jun 17 18:31:13 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri Jun 17 18:31:13 2016 +0200

----------------------------------------------------------------------
 wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/b87b91b3/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 47f9c98..af0db5d 100644
--- a/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_7.gdoc
@@ -41,4 +41,6 @@ By default calling @setOutputMarkupId@ we generate markup ids using a session-le
    <span id="staticIdToUse" wicket:id="componentWicketId"></span>
 {code}
 
-[See examples site|http://examples7x.wicket.apache.org/stateless] for a full showcase of AJAX-stateless capabilities.
+The following AJAX-stateless components are shipped with Wicket distribution: @StatelessAjaxLink@, @StatelessAjaxButton@, @StatelessAjaxSubmitLink@
+ 
+{externalink:wicket.examples.url@stateless}See examples {externalink} page for a full showcase of AJAX-stateless capabilities.


[10/21] wicket git commit: WICKET-6153 WicketTester's MockHttpServletRequest doesn't expose setLocale(aLocale) method

Posted by ad...@apache.org.
WICKET-6153 WicketTester's MockHttpServletRequest doesn't expose setLocale(aLocale) method


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

Branch: refs/heads/WICKET-6183
Commit: 41705d8011e4dfc94f9da9962665b03cfe56b3bb
Parents: c1ea238
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sat May 21 14:45:58 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/wicket/Session.java    |  2 +-
 .../http/mock/MockHttpServletRequest.java       | 14 +++++++++++---
 .../wicket/util/tester/BaseWicketTester.java    |  2 +-
 .../http/mock/MockHttpServletRequestTest.java   | 20 +++++++++++++++-----
 4 files changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/41705d80/wicket-core/src/main/java/org/apache/wicket/Session.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Session.java b/wicket-core/src/main/java/org/apache/wicket/Session.java
index f194b98..d18a644 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Session.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Session.java
@@ -488,7 +488,7 @@ public abstract class Session implements IClusterable, IEventSink
 	 */
 	private void destroy()
 	{
-		if (sessionStore != null)
+		if (getSessionStore() != null)
 		{
 			sessionStore.invalidate(RequestCycle.get().getRequest());
 			sessionStore = null;

http://git-wip-us.apache.org/repos/asf/wicket/blob/41705d80/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
index cf8087d..a7bd476 100755
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
@@ -323,7 +323,7 @@ public class MockHttpServletRequest implements HttpServletRequest
 		List<String> list = (List<String>)headers.get(name);
 		if (list == null)
 		{
-			list = new ArrayList<String>(1);
+			list = new ArrayList<>(1);
 			headers.put(name, list);
 		}
 		list.clear();
@@ -635,6 +635,10 @@ public class MockHttpServletRequest implements HttpServletRequest
 		return getLocales().nextElement();
 	}
 
+	public void setLocale(Locale locale) {
+		setHeader("Accept-Language", locale.getLanguage() + '-' + locale.getCountry());
+	}
+
 	/**
 	 * 
 	 * @param value
@@ -668,10 +672,14 @@ public class MockHttpServletRequest implements HttpServletRequest
 	@Override
 	public Enumeration<Locale> getLocales()
 	{
-		List<Locale> list = new ArrayList<Locale>();
-		final String header = getHeader("Accept-Language");
+		List<Locale> list = new ArrayList<>();
+		String header = getHeader("Accept-Language");
 		if (header != null)
 		{
+			int idxOfSemicolon = header.indexOf(';');
+			if (idxOfSemicolon > -1) {
+				header = header.substring(0 , idxOfSemicolon);
+			}
 			final String[] locales = Strings.split(header, ',');
 			for (String value : locales)
 			{

http://git-wip-us.apache.org/repos/asf/wicket/blob/41705d80/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
index 3cbe313..eabe75e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
@@ -483,7 +483,7 @@ public class BaseWicketTester
 
 	/**
 	 * Cleans up feedback messages. This usually happens on detach, but is disabled in unit testing
-	 * so feedback mesasges can be examined.
+	 * so feedback messages can be examined.
 	 */
 	public void cleanupFeedbackMessages()
 	{

http://git-wip-us.apache.org/repos/asf/wicket/blob/41705d80/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequestTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequestTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequestTest.java
index 004ea9b..99f956e 100755
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequestTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequestTest.java
@@ -17,15 +17,18 @@
 package org.apache.wicket.protocol.http.mock;
 
 import java.util.Enumeration;
+import java.util.Locale;
 
 import javax.servlet.http.HttpSession;
 
+import org.apache.wicket.Session;
 import org.apache.wicket.request.Url;
 import org.apache.wicket.util.tester.WicketTestCase;
-import org.apache.wicket.util.tester.WicketTester;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import static org.hamcrest.Matchers.is;
+
 /**
  * test features of {@link MockHttpServletRequest}
  */
@@ -34,7 +37,6 @@ public class MockHttpServletRequestTest extends WicketTestCase
 	@Test
 	public void setAbsoluteUrlWithHost()
 	{
-		WicketTester tester = new WicketTester();
 		MockHttpServletRequest request = tester.getRequest();
 		assertEquals("http", request.getScheme());
 		assertEquals("localhost", request.getServerName());
@@ -59,7 +61,6 @@ public class MockHttpServletRequestTest extends WicketTestCase
 	@Test
 	public void setAbsoluteUrlWithoutHost()
 	{
-		WicketTester tester = new WicketTester();
 		MockHttpServletRequest request = tester.getRequest();
 		assertEquals("http", request.getScheme());
 		assertEquals("localhost", request.getServerName());
@@ -84,7 +85,6 @@ public class MockHttpServletRequestTest extends WicketTestCase
 	@Test
 	public void setRelativeUrl()
 	{
-		WicketTester tester = new WicketTester();
 		MockHttpServletRequest request = tester.getRequest();
 		assertEquals("http", request.getScheme());
 		assertEquals("localhost", request.getServerName());
@@ -112,7 +112,6 @@ public class MockHttpServletRequestTest extends WicketTestCase
     @Test
     public void testNoQueryString_returnsNull()
     {
-        WicketTester tester = new WicketTester();
         MockHttpServletRequest request = tester.getRequest();
         request.setURL("my/servlet/without/query/param");
         
@@ -176,4 +175,15 @@ public class MockHttpServletRequestTest extends WicketTestCase
 		assertEquals("completelyNewValue", headers.nextElement());
 		assertFalse(headers.hasMoreElements());
 	}
+
+	@Test
+	public void setLocale() {
+		Session session = tester.getSession();
+		session.setLocale(Locale.US);
+		tester.getRequest().setLocale(Locale.CANADA_FRENCH);
+
+		session.invalidateNow();
+
+		assertThat(tester.getSession().getLocale(), is(Locale.CANADA_FRENCH));
+	}
 }


[02/21] wicket git commit: WICKET-6154 Performance bottleneck when using KeyInSessionSunJceCryptFactory

Posted by ad...@apache.org.
WICKET-6154 Performance bottleneck when using KeyInSessionSunJceCryptFactory

Extract PARAMETER_SPEC constant - a PBEParameterSpec that is used by default.


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

Branch: refs/heads/WICKET-6183
Commit: ebcb88dd5fde079f280f10635cdcb1d2dee5d36d
Parents: 77e1e85
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun May 22 10:46:59 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/ebcb88dd/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
index 778cfb0..b702851 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
@@ -53,6 +53,8 @@ public class SunJceCrypt extends AbstractCrypt
 	public final static byte[] SALT = { (byte)0x15, (byte)0x8c, (byte)0xa3, (byte)0x4a,
 			(byte)0x66, (byte)0x51, (byte)0x2a, (byte)0xbc };
 
+	private static final PBEParameterSpec PARAMETER_SPEC = new PBEParameterSpec(SALT, COUNT);
+
 	/** The name of encryption method (cipher) */
 	private final String cryptMethod;
 
@@ -141,7 +143,7 @@ public class SunJceCrypt extends AbstractCrypt
 	 */
 	protected AlgorithmParameterSpec createParameterSpec()
 	{
-		return new PBEParameterSpec(SALT, COUNT);
+		return PARAMETER_SPEC;
 	}
 
 	/**


[19/21] wicket git commit: Update dependencies

Posted by ad...@apache.org.
Update dependencies


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

Branch: refs/heads/WICKET-6183
Commit: 37906baf53cbb9f5964fbc7e99dee5ea517afd0e
Parents: f5fae5a
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon May 30 17:53:40 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu Jun 9 11:17:06 2016 +0200

----------------------------------------------------------------------
 pom.xml | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/37906baf/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index cf418b2..135b302 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,14 +130,14 @@
 		<jacoco.version>0.7.4.201502262128</jacoco.version>
 		<jetty.version>8.1.16.v20140903</jetty.version>
 		<jetty9.version>9.0.7.v20131107</jetty9.version>
-		<joda-time.version>2.7</joda-time.version>
+		<joda-time.version>2.9.4</joda-time.version>
 		<junit.version>4.12</junit.version>
 		<spring.version>4.1.7.RELEASE</spring.version>
 		<servlet-api.version>3.0.1</servlet-api.version>
 		<maven.javadoc.version>2.10.3</maven.javadoc.version>
-		<maven.surefire.version>2.18</maven.surefire.version>
-		<mockito.version>1.10.16</mockito.version>
-		<slf4j.version>1.7.12</slf4j.version>
+		<maven.surefire.version>2.19.1</maven.surefire.version>
+		<mockito.version>1.10.19</mockito.version>
+		<slf4j.version>1.7.21</slf4j.version>
 		<hamcrest.version>2.0.0.0</hamcrest.version>
 		<objenesis.version>2.1</objenesis.version>
 		<!-- do not increase the version - wicket-user-guide requires 2.2.4 -->
@@ -227,17 +227,17 @@
 			<dependency>
 				<groupId>commons-fileupload</groupId>
 				<artifactId>commons-fileupload</artifactId>
-				<version>1.3.1</version>
+				<version>1.3.2</version>
 			</dependency>
 			<dependency>
 				<groupId>commons-io</groupId>
 				<artifactId>commons-io</artifactId>
-				<version>2.4</version>
+				<version>2.5</version>
 			</dependency>
 			<dependency>
 				<groupId>de.agilecoders.wicket.webjars</groupId>
 				<artifactId>wicket-webjars</artifactId>
-				<version>0.5.2</version>
+				<version>0.5.4</version>
 			</dependency>
 			<dependency>
 				<groupId>javax.inject</groupId>


[07/21] wicket git commit: WICKET-6172 Inconsistent results from getTag[s]ByWicketId

Posted by ad...@apache.org.
WICKET-6172 Inconsistent results from getTag[s]ByWicketId


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

Branch: refs/heads/WICKET-6183
Commit: 7eced629a6b5ec6ee6be18da29efede1cc05714b
Parents: 366beff
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Thu May 26 19:05:59 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/util/tester/TagTester.java  | 10 ++++++++--
 .../apache/wicket/util/tester/TagTesterTest.java  | 18 +++++++++++++++++-
 2 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/7eced629/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
index b5aac3e..e2cc83c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java
@@ -614,7 +614,7 @@ public class TagTester
 				XmlPullParser parser = new XmlPullParser();
 				parser.parse(markup);
 
-				XmlTag elm = null;
+				XmlTag elm;
 				XmlTag openTag = null;
 				XmlTag closeTag = null;
 				int level = 0;
@@ -671,6 +671,13 @@ public class TagTester
 						openTag = null;
 						closeTag = null;
 					}
+					else if (openTag != null)
+					{
+						TagTester tester = new TagTester(parser, openTag, openTag);
+						testers.add(tester);
+						openTag = null;
+						closeTag = null;
+					}
 
 					if (stopAfterFirst && (closeTag != null))
 					{
@@ -680,7 +687,6 @@ public class TagTester
 			}
 			catch (Exception e)
 			{
-				// NOTE: IllegalStateException(Throwable) only exists since Java 1.5
 				throw new WicketRuntimeException(e);
 			}
 		}

http://git-wip-us.apache.org/repos/asf/wicket/blob/7eced629/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java b/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
index f604739..9a60a88 100644
--- a/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/util/tester/TagTesterTest.java
@@ -24,6 +24,8 @@ import static org.hamcrest.Matchers.notNullValue;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.List;
+
 /**
  * Test of TagTester
  */
@@ -42,7 +44,7 @@ public class TagTesterTest extends Assert
 	 * https://issues.apache.org/jira/browse/WICKET-5874
 	 */
 	@Test
-	public void getTagTestedForNonClosedTag()
+	public void getTagTesterForNonClosedTag()
 	{
 		TagTester tester = TagTester.createTagByAttribute(NON_CLOSED_INPUT, "wicket:id", "wicketId");
 		assertThat(tester, is(notNullValue()));
@@ -52,6 +54,20 @@ public class TagTesterTest extends Assert
 	}
 
 	/**
+	 * https://issues.apache.org/jira/browse/WICKET-6172
+	 */
+	@Test
+	public void getTagTestersForNonClosedTag()
+	{
+		List<TagTester> testers = TagTester.createTagsByAttribute(NON_CLOSED_INPUT, "wicket:id", "wicketId", false);
+		assertThat(testers, is(notNullValue()));
+		assertThat(testers.size(), is(1));
+
+		String type = testers.get(0).getAttribute("type");
+		assertThat(type, is(equalTo("text")));
+	}
+
+	/**
 	 * https://issues.apache.org/jira/browse/WICKET-5137
 	 */
 	@Test


[08/21] wicket git commit: WICKET-6154 Performance bottleneck when using KeyInSessionSunJceCryptFactory

Posted by ad...@apache.org.
WICKET-6154 Performance bottleneck when using KeyInSessionSunJceCryptFactory

Fix typo in javadoc


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

Branch: refs/heads/WICKET-6183
Commit: 366beff70bd44cd9d6ea599f75f8caa3585a7b88
Parents: ebcb88d
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun May 22 10:51:25 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri May 27 13:12:16 2016 +0200

----------------------------------------------------------------------
 .../test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/366beff7/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java b/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java
index fec7194..bd1ffa1 100644
--- a/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java
+++ b/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java
@@ -63,10 +63,10 @@ public class SunJceCryptTest extends Assert
 	}
 
 	/**
-	 * Checks whether Oracle Unlimited Strenght Jurisdiction Policy is installed
+	 * Checks whether Oracle Unlimited Strength Jurisdiction Policy is installed
 	 * Based on http://stackoverflow.com/a/8607735
 	 *
-	 * @return {@code true} if Unlimited Strenght Jurisdiction Policy is installed
+	 * @return {@code true} if Unlimited Strength Jurisdiction Policy is installed
 	 * @throws NoSuchAlgorithmException
 	 */
 	static boolean isUnlimitedStrengthJurisdictionPolicyInstalled() throws NoSuchAlgorithmException


[18/21] wicket git commit: WICKET-6178 MetaDataHeaderItem # generateString() should return specials characters escaped like StringEscapeUtils.escapeHtml(s) does

Posted by ad...@apache.org.
WICKET-6178 MetaDataHeaderItem # generateString() should return specials
characters escaped like StringEscapeUtils.escapeHtml(s) does

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

Branch: refs/heads/WICKET-6183
Commit: d1b4ce5c76e910685358aae36754d295913332de
Parents: db90877
Author: Andrea Del Bene <ad...@apache.org>
Authored: Thu Jun 9 11:09:19 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu Jun 9 11:17:06 2016 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/markup/head/MetaDataHeaderItem.java   | 3 +--
 .../apache/wicket/markup/head/MetaDataHeaderItemTest.java   | 9 +++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/d1b4ce5c/wicket-core/src/main/java/org/apache/wicket/markup/head/MetaDataHeaderItem.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/MetaDataHeaderItem.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/MetaDataHeaderItem.java
index 3d8cfa9..35b3cbd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/head/MetaDataHeaderItem.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/MetaDataHeaderItem.java
@@ -21,7 +21,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.wicket.core.util.string.JavaScriptUtils;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.request.Response;
@@ -123,7 +122,7 @@ public class MetaDataHeaderItem extends HeaderItem
 			{
 				buffer.append('=')
 					.append('"')
-					.append(JavaScriptUtils.escapeQuotes(value.toString()))
+					.append(Strings.replaceAll(value.toString(), "\"", "\\\""))
 					.append('"');
 			}
 		}

http://git-wip-us.apache.org/repos/asf/wicket/blob/d1b4ce5c/wicket-core/src/test/java/org/apache/wicket/markup/head/MetaDataHeaderItemTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/head/MetaDataHeaderItemTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/head/MetaDataHeaderItemTest.java
index 472a722..6cff0a5 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/head/MetaDataHeaderItemTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/head/MetaDataHeaderItemTest.java
@@ -42,4 +42,13 @@ public class MetaDataHeaderItemTest
 		
 		assertEquals(expectedString, metaTag.generateString());
 	}
+	
+	@Test
+	public void testEscapeOnlyDoubleQuotes() throws Exception
+	{
+		String expectedString = "<link rel=\"single quote \' double quotes\\\"\" href=\"\" />\n";
+		MetaDataHeaderItem metaTag = MetaDataHeaderItem.forLinkTag("single quote \' double quotes\"", "");
+		
+		assertEquals(expectedString, metaTag.generateString());
+	}
 }