You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2014/02/18 11:01:47 UTC

[03/17] git commit: Sync the CDI example with the one from wicket-6.x

Sync the CDI example with the one from wicket-6.x


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

Branch: refs/heads/sandbox/component-queueing-2
Commit: e9b4f388aef1d9c18988689170c460b0c436f128
Parents: af7d79b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Feb 17 14:14:05 2014 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Feb 17 14:14:05 2014 +0200

----------------------------------------------------------------------
 .../examples/cdi/AutoConversationPage1.html     | 19 +++++++
 .../examples/cdi/AutoConversationPage1.java     | 57 ++++++++++++++++++++
 .../examples/cdi/AutoConversationPage2.html     | 17 ++++++
 .../examples/cdi/AutoConversationPage2.java     | 43 +++++++++++++++
 .../wicket/examples/cdi/CdiApplication.java     | 20 +++----
 .../apache/wicket/examples/cdi/CdiHomePage.html |  3 ++
 6 files changed, 150 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e9b4f388/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.html b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.html
new file mode 100644
index 0000000..5768bab
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.html
@@ -0,0 +1,19 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:extend>
+	<p>
+		This page demonstrates automatic conversation managed. Below is a counter
+		that is conversation-scoped. Click increment a couple of times and then click
+		the 'Continue to next page', the counter value should persist on the
+		next page.
+	</p>
+	<p>
+		Current counter value is: <span wicket:id="count">100</span>
+		<a wicket:id="increment">increment</a>
+	</p>
+	<p>
+		<a wicket:id="next">Continue to next page</a>
+	</p>
+</wicket:extend>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/e9b4f388/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.java b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.java
new file mode 100644
index 0000000..fd5190d
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage1.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.cdi;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+
+import org.apache.wicket.cdi.ConversationalComponent;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.PropertyModel;
+
+public class AutoConversationPage1 extends CdiExamplePage implements ConversationalComponent
+{
+	@Inject
+	ConversationCounter counter;
+
+	@Inject
+	Conversation conversation;
+
+	public AutoConversationPage1()
+	{
+		add(new Label("count", new PropertyModel(this, "counter.count")));
+
+		add(new Link<Void>("increment")
+		{
+			@Override
+			public void onClick()
+			{
+				counter.increment();
+			}
+		});
+
+		add(new Link<Void>("next")
+		{
+			@Override
+			public void onClick()
+			{
+				setResponsePage(new AutoConversationPage2());
+			}
+		});
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/e9b4f388/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.html b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.html
new file mode 100644
index 0000000..1e1a9ef
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.html
@@ -0,0 +1,17 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:extend>
+	<p>
+		This page is not marked with ConversationalComponent. Therefore, the conversation that was
+		started on the previous page is ended. Notice the conversational counter injected into this
+		page initially has the same value as in the	previous page, this is because the conversation
+		was still active in the request that rendered this page. However, clicking 'refresh' below,
+		will reset the counter to 0.
+	</p>
+	<p>
+		Current counter value is: <span wicket:id="count">100</span>
+		<a wicket:id="refresh">refresh</a>
+	</p>
+</wicket:extend>
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/e9b4f388/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.java b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.java
new file mode 100644
index 0000000..7f3ee95
--- /dev/null
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/AutoConversationPage2.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.cdi;
+
+import javax.inject.Inject;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.PropertyModel;
+
+public class AutoConversationPage2 extends CdiExamplePage
+{
+	@Inject
+	ConversationCounter counter;
+
+	public AutoConversationPage2()
+	{
+		add(new Label("count", new PropertyModel(this, "counter.count")));
+
+		add(new Link<Void>("refresh")
+		{
+			@Override
+			public void onClick()
+			{
+			}
+		});
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/e9b4f388/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
index a5c4869..c56d2e7 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiApplication.java
@@ -16,27 +16,29 @@
  */
 package org.apache.wicket.examples.cdi;
 
+import javax.enterprise.inject.spi.BeanManager;
+
 import org.apache.wicket.Page;
 import org.apache.wicket.cdi.CdiConfiguration;
-import org.apache.wicket.cdi.ConversationPropagation;
 import org.apache.wicket.protocol.http.WebApplication;
+import org.jboss.weld.environment.servlet.Listener;
 
-public class CdiApplication extends WebApplication {
+public class CdiApplication extends WebApplication
+{
 
 	@Override
-	public Class<? extends Page> getHomePage() {
+	public Class<? extends Page> getHomePage()
+	{
 		return CdiHomePage.class;
 	}
 
 	@Override
-	protected void init() {
+	protected void init()
+	{
 		super.init();
 
-		new CdiConfiguration().setPropagation(
-				ConversationPropagation.NONBOOKMARKABLE).configure(this);
-
-		mountPage("injection", InjectionPage.class);
-		mountPage("conversation", ConversationPage1.class);
+		// configure wicket/cdi
+		new CdiConfiguration().configure(this);
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/e9b4f388/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiHomePage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiHomePage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiHomePage.html
index ef2431a..d750a11 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiHomePage.html
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/cdi/CdiHomePage.html
@@ -9,6 +9,9 @@
 		<li>
 			<a href="ConversationPage1.html">Conversation Propagation Example</a>
 		</li>
+		<li>
+			<a href="AutoConversationPage1.html">Automatic Conversation Management Example</a>
+		</li>
 	</ul>
 	</wicket:link>
 </wicket:extend>