You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2006/11/10 22:17:41 UTC
svn commit: r473490 -
/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/
Author: jcompagner
Date: Fri Nov 10 13:17:40 2006
New Revision: 473490
URL: http://svn.apache.org/viewvc?view=rev&rev=473490
Log:
stateless example
Added:
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.html
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.java
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/SessionModel.java
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.html
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.java
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessApplication.java
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.html
incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.java
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.html
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.html?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.html (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.html Fri Nov 10 13:17:40 2006
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Wicket Examples - stateless</title>
+ <link rel="stylesheet" type="text/css" href="style.css" />
+ </head>
+ <body>
+ <span wicket:id="message" id="message">Message goes here</span>
+ <br />
+ <a wicket:id="linkToStatelessPage" href="#">go to another
+ stateless page</a>
+ <br />
+ <a wicket:id="linkToStatefulPage" href="#">go to a stateful page
+ (triggers session creation if not already done so</a>
+ </body>
+</html>
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.java?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/Index.java Fri Nov 10 13:17:40 2006
@@ -0,0 +1,54 @@
+/*
+ * $Id: HelloWorld.java 5394 2006-04-16 13:36:52 +0000 (Sun, 16 Apr 2006)
+ * jdonnerstag $ $Revision: 5394 $ $Date: 2006-04-16 13:36:52 +0000 (Sun, 16 Apr
+ * 2006) $
+ *
+ * ==================================================================== Licensed
+ * 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 wicket.examples.stateless;
+
+import wicket.markup.html.WebPage;
+import wicket.markup.html.basic.Label;
+import wicket.markup.html.link.BookmarkablePageLink;
+import wicket.markup.html.link.StatelessLink;
+
+/**
+ * Index page of the stateless example.
+ *
+ * @author Eelco Hillenius
+ */
+public class Index extends WebPage
+{
+ /**
+ * Constructor
+ */
+ public Index()
+ {
+ setStatelessHint(true);
+ add(new Label("message", new SessionModel()));
+ // First a normal bookmarkable link (which is stateless by default)
+ add(new BookmarkablePageLink("linkToStatelessPage", StatelessPage.class));
+ // The second with a stateless link, so the onclick will be called but on a stateless page.
+ add(new StatelessLink("linkToStatefulPage")
+ {
+ /**
+ * @see wicket.markup.html.link.Link#onClick()
+ */
+ public void onClick()
+ {
+ setResponsePage(StatefulPage.class);
+ }
+ });
+ }
+}
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/SessionModel.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/SessionModel.java?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/SessionModel.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/SessionModel.java Fri Nov 10 13:17:40 2006
@@ -0,0 +1,53 @@
+/*
+ * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar
+ * 2006) eelco12 $ $Revision: 5004 $ $Date: 2006-03-17 20:47:08 -0800 (Fri, 17
+ * Mar 2006) $
+ *
+ * ==============================================================================
+ * Licensed 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 wicket.examples.stateless;
+
+import wicket.Application;
+import wicket.Component;
+import wicket.RequestCycle;
+import wicket.model.AbstractReadOnlyModel;
+
+/**
+ * Model that displays whether a session was created yet, and if it was, prints
+ * the session id.
+ *
+ * @author Eelco Hillenius
+ */
+public class SessionModel extends AbstractReadOnlyModel
+{
+ /**
+ * @see wicket.model.AbstractReadOnlyModel#getObject(Component)
+ */
+ public Object getObject(Component object)
+ {
+ final String msg;
+ String sessionId = Application.get().getSessionStore().getSessionId(
+ RequestCycle.get().getRequest(), false);
+ if (sessionId == null)
+ {
+ msg = "no concrete session is created yet (only a volatile one)";
+ }
+ else
+ {
+ msg = "a session exists for this client, with session id " + sessionId;
+ }
+ return msg;
+ }
+
+}
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.html?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.html (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.html Fri Nov 10 13:17:40 2006
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Wicket Examples - stateless</title>
+ <link rel="stylesheet" type="text/css" href="style.css" />
+ </head>
+ <body>
+ <span wicket:id="message" id="message">Message goes here</span>
+ <br />
+ <a wicket:id="indexLink" href="#">go to index</a>
+
+ <p>
+ This page is stateful as it has a callback (the link that points to
+ this page). If the actual session wasn't created before, this page
+ triggered it's creation.
+ </p>
+
+ <p>
+ This link is what makes this page stateful:
+ <br />
+ <a wicket:id="actionLink">Link clicked <span
+ wicket:id="linkClickCount">0</span> times</a>
+ </p>
+
+ </body>
+</html>
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.java?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatefulPage.java Fri Nov 10 13:17:40 2006
@@ -0,0 +1,77 @@
+/*
+ * $Id: HelloWorld.java 5394 2006-04-16 13:36:52 +0000 (Sun, 16 Apr 2006)
+ * jdonnerstag $ $Revision: 5394 $ $Date: 2006-04-16 13:36:52 +0000 (Sun, 16 Apr
+ * 2006) $
+ *
+ * ==================================================================== Licensed
+ * 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 wicket.examples.stateless;
+
+import wicket.markup.html.WebPage;
+import wicket.markup.html.basic.Label;
+import wicket.markup.html.link.BookmarkablePageLink;
+import wicket.markup.html.link.Link;
+import wicket.model.PropertyModel;
+
+/**
+ * Another page of the stateless example.
+ *
+ * @author Eelco Hillenius
+ */
+public class StatefulPage extends WebPage
+{
+ /** click count for Link. */
+ private int linkClickCount = 0;
+
+ /**
+ * Construct.
+ */
+ public StatefulPage()
+ {
+ add(new Label("message", new SessionModel()));
+ add(new BookmarkablePageLink("indexLink", Index.class));
+
+ // Action link counts link clicks
+ final Link actionLink = new Link("actionLink")
+ {
+ public void onClick()
+ {
+ linkClickCount++;
+ }
+ };
+ add(actionLink);
+ actionLink.add(new Label("linkClickCount", new PropertyModel(this, "linkClickCount")));
+ }
+
+ /**
+ * Gets linkClickCount.
+ *
+ * @return linkClickCount
+ */
+ public int getLinkClickCount()
+ {
+ return linkClickCount;
+ }
+
+ /**
+ * Sets linkClickCount.
+ *
+ * @param linkClickCount
+ * linkClickCount
+ */
+ public void setLinkClickCount(int linkClickCount)
+ {
+ this.linkClickCount = linkClickCount;
+ }
+}
\ No newline at end of file
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessApplication.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessApplication.java?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessApplication.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessApplication.java Fri Nov 10 13:17:40 2006
@@ -0,0 +1,44 @@
+/*
+ * $Id: HelloWorldApplication.java 5394 2006-04-16 13:36:52 +0000 (Sun, 16 Apr
+ * 2006) jdonnerstag $ $Revision: 5394 $ $Date: 2006-04-16 13:36:52 +0000 (Sun,
+ * 16 Apr 2006) $
+ *
+ * ==================================================================== Licensed
+ * 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 wicket.examples.stateless;
+
+import wicket.examples.WicketExampleApplication;
+
+/**
+ * Application class for the stateless application.
+ *
+ * @author Eelco Hillenius
+ */
+public class StatelessApplication extends WicketExampleApplication
+{
+ /**
+ * Constructor.
+ */
+ public StatelessApplication()
+ {
+ }
+
+ /**
+ * @see wicket.Application#getHomePage()
+ */
+ public Class getHomePage()
+ {
+ return Index.class;
+ }
+}
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.html
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.html?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.html (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.html Fri Nov 10 13:17:40 2006
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Wicket Examples - stateless</title>
+ <link rel="stylesheet" type="text/css" href="style.css" />
+ </head>
+ <body>
+ <span wicket:id="message" id="message">Message goes here</span>
+ <br />
+ <a wicket:id="indexLink" href="#">go to index</a>
+
+ <form wicket:id="statelessform">
+ <input type="text" wicket:id="textfield">
+ <input type="submit">
+ </form>
+
+ <p>
+ This page is stateless as it doesn't have any callbacks (like statefull links or forms).
+ If a page doesn't have any, there is no use keeping it around in the
+ session. Furthermore, as long as you don't have any stateful pages,
+ the actual session creation will be deferred. A Wicket session object
+ is available, but is a temporary one.
+ </p>
+
+ </body>
+</html>
Added: incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.java?view=auto&rev=473490
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket-examples/src/main/java/wicket/examples/stateless/StatelessPage.java Fri Nov 10 13:17:40 2006
@@ -0,0 +1,60 @@
+/*
+ * $Id: HelloWorld.java 5394 2006-04-16 13:36:52 +0000 (Sun, 16 Apr 2006)
+ * jdonnerstag $ $Revision: 5394 $ $Date: 2006-04-16 13:36:52 +0000 (Sun, 16 Apr
+ * 2006) $
+ *
+ * ==================================================================== Licensed
+ * 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 wicket.examples.stateless;
+
+import wicket.markup.html.WebPage;
+import wicket.markup.html.basic.Label;
+import wicket.markup.html.form.StatelessForm;
+import wicket.markup.html.form.TextField;
+import wicket.markup.html.link.BookmarkablePageLink;
+import wicket.model.Model;
+
+/**
+ * Another page of the stateless example.
+ *
+ * @author Eelco Hillenius
+ */
+public class StatelessPage extends WebPage
+{
+ private TextField tf;
+
+ /**
+ * Constructor
+ */
+ public StatelessPage()
+ {
+ setStatelessHint(true);
+ add(new Label("message", new SessionModel()));
+ add(new BookmarkablePageLink("indexLink", Index.class));
+
+ StatelessForm statelessForm = new StatelessForm("statelessform"){
+ /**
+ * @see wicket.markup.html.form.Form#onSubmit()
+ */
+ protected void onSubmit()
+ {
+ info("Onsubmit of stateless page pressed, textfield updated: " + tf.getModelObject());
+ tf.setModelObject(tf.getModelObject()+ "_" +tf.getModelObject());
+ }
+ };
+ tf = new TextField("textfield", new Model());
+ add(statelessForm);
+ statelessForm.add(tf);
+ }
+}
\ No newline at end of file