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 2013/02/08 09:24:14 UTC
[17/20] git commit: wicket reference models started
wicket reference models started
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/1e4ebecb
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/1e4ebecb
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/1e4ebecb
Branch: refs/heads/reference-guide
Commit: 1e4ebecbaf289bd2f3a36e720271f007ed2a5373
Parents: 017e45e
Author: Michael Mosmann <mi...@mosmann.de>
Authored: Thu Feb 7 22:22:07 2013 +0100
Committer: Michael Mosmann <mi...@mosmann.de>
Committed: Thu Feb 7 22:22:07 2013 +0100
----------------------------------------------------------------------
.gitignore | 2 +
wicket-reference-guide/models/pom.xml | 36 ++++++++++++
.../wicket/reference/models/ModelsApplication.java | 33 +++++++++++
.../reference/models/SerializableModelPage.html | 9 +++
.../reference/models/SerializableModelPage.java | 21 +++++++
.../org/apache/wicket/reference/models/Start.html | 9 +++
.../org/apache/wicket/reference/models/Start.java | 29 ++++++++++
.../models/src/main/webapp/WEB-INF/web.xml | 44 +++++++++++++++
wicket-reference-guide/pom.xml | 1 +
.../src/documentation/source/converter.rst | 5 ++
.../src/documentation/source/index.rst | 2 +
.../src/documentation/source/models.rst | 30 ++++++++++-
.../src/documentation/source/requestcycle.rst | 6 ++
13 files changed, 226 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 797d696..a68b376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@ target
velocity.log
.project
.classpath
+.settings
*velocity.log*
+*~
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/models/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/models/pom.xml b/wicket-reference-guide/models/pom.xml
new file mode 100644
index 0000000..cecc5e9
--- /dev/null
+++ b/wicket-reference-guide/models/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-reference-guide</artifactId>
+ <version>6.6.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>wicket-reference-guide-models</artifactId>
+ <packaging>jar</packaging>
+ <name>Wicket Reference guide - Models</name>
+ <description>Models application for Wicket Reference guide.</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/ModelsApplication.java
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/ModelsApplication.java b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/ModelsApplication.java
new file mode 100644
index 0000000..f25569b
--- /dev/null
+++ b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/ModelsApplication.java
@@ -0,0 +1,33 @@
+/*
+ * 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.reference.models;
+//#docu
+import org.apache.wicket.Page;
+import org.apache.wicket.protocol.http.WebApplication;
+
+public class ModelsApplication extends WebApplication
+{
+ /**
+ * @see org.apache.wicket.Application#getHomePage()
+ */
+ @Override
+ public Class<? extends Page> getHomePage()
+ {
+ return Start.class;
+ }
+}
+//#docu
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.html
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.html b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.html
new file mode 100644
index 0000000..229a800
--- /dev/null
+++ b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.html
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+<head>
+ <title>Models</title>
+</head>
+<body>
+ <span wicket:id="message">The real message goes here</span>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.java
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.java b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.java
new file mode 100644
index 0000000..2cbfdbc
--- /dev/null
+++ b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.java
@@ -0,0 +1,21 @@
+package org.apache.wicket.reference.models;
+
+import java.util.Date;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+public class SerializableModelPage extends WebPage
+{
+ public SerializableModelPage()
+ {
+//#docu
+IModel<String> message = Model.of("any message");
+message.setObject("current time: " + new Date());
+
+add(new Label("message", message));
+//#docu
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.html
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.html b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.html
new file mode 100644
index 0000000..a99771b
--- /dev/null
+++ b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.html
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
+<head>
+ <title>Model Start Page</title>
+</head>
+<body>
+ <span wicket:id="message">The real message goes here</span>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.java
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.java b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.java
new file mode 100644
index 0000000..71b816c
--- /dev/null
+++ b/wicket-reference-guide/models/src/main/java/org/apache/wicket/reference/models/Start.java
@@ -0,0 +1,29 @@
+/*
+ * 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.reference.models;
+//#docu
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+public class Start extends WebPage
+{
+ public Start()
+ {
+ add(new Label("message", "Hello World!"));
+ }
+}
+//#docu
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/models/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/models/src/main/webapp/WEB-INF/web.xml b/wicket-reference-guide/models/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..ae1b6e9
--- /dev/null
+++ b/wicket-reference-guide/models/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <filter>
+ <filter-name>ModelsApplication</filter-name>
+ <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
+ <init-param>
+ <param-name>applicationClassName</param-name>
+ <param-value>org.apache.wicket.reference.models.ModelsApplication</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>ModelsApplication</filter-name>
+ <url-pattern>/models/*</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping>
+
+ <session-config>
+ <session-timeout>5</session-timeout>
+ </session-config>
+
+</web-app>
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/pom.xml b/wicket-reference-guide/pom.xml
index 8e6784a..beefa68 100644
--- a/wicket-reference-guide/pom.xml
+++ b/wicket-reference-guide/pom.xml
@@ -29,6 +29,7 @@
<description>Wicket Reference guide contains the official documentation for Apache Wicket with code samples.</description>
<modules>
+ <module>models</module>
<module>helloworld</module>
<module>stateless</module>
</modules>
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/src/documentation/source/converter.rst
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/src/documentation/source/converter.rst b/wicket-reference-guide/src/documentation/source/converter.rst
new file mode 100644
index 0000000..59ede98
--- /dev/null
+++ b/wicket-reference-guide/src/documentation/source/converter.rst
@@ -0,0 +1,5 @@
+Converter
+==============
+
+.. todo:: Custom converter
+
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/src/documentation/source/index.rst
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/src/documentation/source/index.rst b/wicket-reference-guide/src/documentation/source/index.rst
index 20a04af..cab9e61 100644
--- a/wicket-reference-guide/src/documentation/source/index.rst
+++ b/wicket-reference-guide/src/documentation/source/index.rst
@@ -10,6 +10,8 @@ Contents:
application
components
models
+ converter
+ requestcycle
behaviors
ajax
events
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/src/documentation/source/models.rst
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/src/documentation/source/models.rst b/wicket-reference-guide/src/documentation/source/models.rst
index 75338c8..c154134 100644
--- a/wicket-reference-guide/src/documentation/source/models.rst
+++ b/wicket-reference-guide/src/documentation/source/models.rst
@@ -1,2 +1,30 @@
Model
-=====
+============================
+.. toctree::
+ :maxdepth: 3
+
+Models are a important part of any wicket application. Despite it's simple interface its a complex topic. But let's start with some easy examples.
+
+A very simple Model
+-------------------
+
+There is a simple model implementation, which can hold any data, which is serializable (see :ref:`models--detach-label`). This implementation implements two methods from the IModel interface for interacting with the model value.
+
+.. includecode:: ../../../models/src/main/java/org/apache/wicket/reference/models/SerializableModelPage.java#docu
+
+This examples shows an easy way to create a model instance for a value and how the value can be changed afterwards. The Label component accepts any model value (not only strings, see :doc:`converter`).
+
+TODO
+-------------------
+
+.. todo:: custom detach
+.. todo:: cascading models
+
+.. _models--detach-label:
+
+Model and detach (TODO)
+-------------------
+
+As any page contains mainly components and models. Most data is stored in models, it is important to know, that models are detached after the page is rendered (see :doc:`requestcycle`). to remove anything from the page which is not needed anymore.
+
+
http://git-wip-us.apache.org/repos/asf/wicket/blob/1e4ebecb/wicket-reference-guide/src/documentation/source/requestcycle.rst
----------------------------------------------------------------------
diff --git a/wicket-reference-guide/src/documentation/source/requestcycle.rst b/wicket-reference-guide/src/documentation/source/requestcycle.rst
new file mode 100644
index 0000000..1142586
--- /dev/null
+++ b/wicket-reference-guide/src/documentation/source/requestcycle.rst
@@ -0,0 +1,6 @@
+Request Cycle
+=============
+
+.. todo:: Detach
+.. todo:: Render Cycle
+