Author: adelbene
Date: Sat Nov 16 16:44:23 2013
New Revision: 1542531
URL: http://svn.apache.org/r1542531
Log:
Added a code example to configure app via code (Servlet 3 or later)
Added class ComponentRenderer in the test chapter
Modified:
wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/BootStrap.html
wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/UrlMappings.html
wicket/common/site/trunk/_site/guide/gapi/deprecated-list.html
wicket/common/site/trunk/_site/guide/gapi/help-doc.html
wicket/common/site/trunk/_site/guide/gapi/index-all.html
wicket/common/site/trunk/_site/guide/gapi/spring/resources.html
wicket/common/site/trunk/_site/guide/guide/chapter2.html
wicket/common/site/trunk/_site/guide/guide/chapter20.html
wicket/common/site/trunk/_site/guide/guide/chapter3.html
wicket/common/site/trunk/_site/guide/guide/pages/chapter20_3.html
wicket/common/site/trunk/_site/guide/guide/pages/chapter2_4.html
wicket/common/site/trunk/_site/guide/guide/pages/chapter3_2.html
wicket/common/site/trunk/_site/guide/guide/single.html
wicket/common/site/trunk/_site/guide/guide/single.pdf
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter2/chapter2_4.gdoc
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter20/chapter20_3.gdoc
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter3/chapter3_2.gdoc
Modified:
wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/BootStrap.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/BootStrap.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/BootStrap.html
(original)
+++ wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/BootStrap.html Sat
Nov 16 16:44:23 2013
@@ -6,9 +6,9 @@
<html>
<head>
-<!-- Generated by groovydoc (2.0.8) on Mon Nov 11 22:42:13 CET 2013 -->
+<!-- Generated by groovydoc (2.0.8) on Sat Nov 16 17:29:44 CET 2013 -->
<title>BootStrap (Groovy Documentation)</title>
-<meta name="date" content="2013-11-11">
+<meta name="date" content="2013-11-16">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../groovy.ico" type="image/x-icon" rel="icon">
Modified:
wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/UrlMappings.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/UrlMappings.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/UrlMappings.html
(original)
+++ wicket/common/site/trunk/_site/guide/gapi/DefaultPackage/UrlMappings.html
Sat Nov 16 16:44:23 2013
@@ -6,9 +6,9 @@
<html>
<head>
-<!-- Generated by groovydoc (2.0.8) on Mon Nov 11 22:42:13 CET 2013 -->
+<!-- Generated by groovydoc (2.0.8) on Sat Nov 16 17:29:44 CET 2013 -->
<title>UrlMappings (Groovy Documentation)</title>
-<meta name="date" content="2013-11-11">
+<meta name="date" content="2013-11-16">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../groovy.ico" type="image/x-icon" rel="icon">
Modified: wicket/common/site/trunk/_site/guide/gapi/deprecated-list.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/gapi/deprecated-list.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/gapi/deprecated-list.html (original)
+++ wicket/common/site/trunk/_site/guide/gapi/deprecated-list.html Sat Nov 16
16:44:23 2013
@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Generated by groovydoc (2.0.8) on -->
<title>Deprecated API (wicket-userguide)</title>
-<meta name="date" content="2013-11-11">
+<meta name="date" content="2013-11-16">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<link href="groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="groovy.ico" type="image/x-icon" rel="icon">
Modified: wicket/common/site/trunk/_site/guide/gapi/help-doc.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/gapi/help-doc.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/gapi/help-doc.html (original)
+++ wicket/common/site/trunk/_site/guide/gapi/help-doc.html Sat Nov 16 16:44:23
2013
@@ -7,7 +7,7 @@
<title>API Help (wicket-userguide)</title>
<link href="groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="groovy.ico" type="image/x-icon" rel="icon">
-<meta name="date" content="2013-11-11">
+<meta name="date" content="2013-11-16">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript">
Modified: wicket/common/site/trunk/_site/guide/gapi/index-all.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/gapi/index-all.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/gapi/index-all.html (original)
+++ wicket/common/site/trunk/_site/guide/gapi/index-all.html Sat Nov 16
16:44:23 2013
@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Generated by groovydoc (2.0.8) on -->
<title>Index (wicket-userguide)</title>
-<meta name="date" content="2013-11-11">
+<meta name="date" content="2013-11-16">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<link href="groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="groovy.ico" type="image/x-icon" rel="icon">
Modified: wicket/common/site/trunk/_site/guide/gapi/spring/resources.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/gapi/spring/resources.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/gapi/spring/resources.html (original)
+++ wicket/common/site/trunk/_site/guide/gapi/spring/resources.html Sat Nov 16
16:44:23 2013
@@ -6,9 +6,9 @@
<html>
<head>
-<!-- Generated by groovydoc (2.0.8) on Mon Nov 11 22:42:13 CET 2013 -->
+<!-- Generated by groovydoc (2.0.8) on Sat Nov 16 17:29:44 CET 2013 -->
<title>resources (Groovy Documentation)</title>
-<meta name="date" content="2013-11-11">
+<meta name="date" content="2013-11-16">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../groovy.ico" type="image/x-icon" rel="icon">
Modified: wicket/common/site/trunk/_site/guide/guide/chapter2.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/chapter2.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/chapter2.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/chapter2.html Sat Nov 16
16:44:23 2013
@@ -211,7 +211,7 @@ Wicket is not the only component oriente
<li><strong class="bold">Wicket is a community driven project</strong>: The
Wicket team supports and promotes the dialogue with the framework's users
through two mailing lists <a href="http://wicket.apache.org/help/email.html"
target="blank">(one for users and another one for framework developers)</a> and
an <a href="https://issues.apache.org/jira/browse/WICKET" target="blank">Apache
JIRA</a> (the issue tracking system). Moreover, as any other Apache project,
Wicket is developed paying great attention to user feedbacks and to suggested
features.</li>
<li><strong class="bold">Wicket is just about Java and good old HTML</strong>:
almost all web frameworks force users to adopt special tags or to use server
side code inside HTML markup. This is clearly in contrast with the concept of
separation between presentation and business logic and it leads to a more
confusing code in our pages. In Wicket we don't have to take care of generating
HTML inside the page itself, and we won't need to use any tag other than
standard HTML tags. All we have to do is to attach our components (Java
instances) to the HTML tags using a simple tag attribute called
<code>wicket:id</code> (we will shortly see how to use it).</li>
<li><strong class="bold">With Wicket we can easily use JavaBeans and <a
href="http://en.wikipedia.org/wiki/Plain_Old_Java_Object"
target="blank">POJO</a> in our web tier</strong>: one of the most annoying and
error-prone task in web development is collecting user input through a form and
keeping form fields updated with previously inserted values. This usually
requires a huge amount of code to extract input from request parameters (which
are strings), parse them to Java types and store them into some kind of
variable. And this is just half of the work we have to do as we must implement
the inverse path (load data from Java to the web form).Moreover, most of the
times our forms will use a JavaBean or a POJO as backing object, meaning that
we must manually map form fields with the corresponding object fields and vice
versa. Wicket comes with an intuitive and flexible mechanism that does this
mapping for us without any configuration overhead (using a convention over
configuration appro
ach) and in a transparent way. <a href="../guide/single.html#chapter10"
class="guide">Chapter 10</a> will introduce the concept of Wicket model and we
will learn how to harness this entity with forms.</li>
-<li><strong class="bold">No complex XML needed</strong>: Wicket was designed
to minimize the amount of configuration files needed to run our applications.
No XML file is required except for the standard deployment descriptor
web.xml.</li>
+<li><strong class="bold">No complex XML needed</strong>: Wicket was designed
to minimize the amount of configuration files needed to run our applications.
No XML file is required except for the standard deployment descriptor web.xml
(unless you are using Servlet 3 or a later version. See <a
href="../guide/single.html#chapter3_2" class="guide">Chapter 4</a> for more
details).</li>
</ul><p class="paragraph"/>
Modified: wicket/common/site/trunk/_site/guide/guide/chapter20.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/chapter20.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/chapter20.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/chapter20.html Sat Nov 16
16:44:23 2013
@@ -384,8 +384,14 @@ formTester.submit(<span class="java-
<span class="java-object">String</span> responseTxt =
tester.getLastResponse().getDocument();<p class="paragraph"/> TagTester
tagTester = TagTester.createTagByAttribute(responseTxt, <span
class="java-quote">"class"</span>, <span
class="java-quote">"myClass"</span>);<p class="paragraph"/>
Assert.assertNotNull(tagTester);
Assert.assertEquals(<span class="java-quote">"span"</span>,
tagTester.getName());<p class="paragraph"/> List<TagTester>
tagTesterList = TagTester.createTagsByAttribute(responseTxt,
<span
class="java-quote">"class"</span>, <span
class="java-quote">"myClass"</span>, <span
class="java-keyword">false</span>);<p class="paragraph"/>
Assert.assertEquals(2, tagTesterList.size());
-}</pre></div><p class="paragraph"/>The name of the tag found by TagTester
can be retrieved with its method getName. Method createTagsByAttribute returns
all the tags that have the given value on the given attribute. In the code
above we have used this method to test that our markup contains two tags having
attribute class equal to myClass.
-
+}</pre></div><p class="paragraph"/>The name of the tag found by TagTester
can be retrieved with its method getName. Method createTagsByAttribute returns
all the tags that have the given value on the class attribute. In the code
above we have used this method to test that our markup contains two tags having
attribute class equal to myClass.<p class="paragraph"/>Another utility class
that comes in handy when we want to test components markup is ComponentRenderer
in package org.apache.wicket.core.util.string. The purpose of this class is to
render a page or a component in isolation with its static methods
renderComponent and renderPage. Both methods return the generated markup as
CharSequence:<p class="paragraph"/><div class="code"><pre>@Test
+<span class="java-keyword">public</span> void customComponentMarkupTest()
+{
+ //instantiate MyComponent
+ MyComponent myComponent = //...<p class="paragraph"/> //render and
save component markup
+ <span class="java-object">String</span> componentMarkup =
ComponentRenderer.renderComponent(myComponent);<p class="paragraph"/>
//perform test operations
+ //…
+}</pre></div>
<h2 id="chapter20_4">21.4 Summary</h2>
Modified: wicket/common/site/trunk/_site/guide/guide/chapter3.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/chapter3.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/chapter3.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/chapter3.html Sat Nov 16
16:44:23 2013
@@ -204,7 +204,9 @@ All the example projects presented in th
<span
class="xml-tag"><filter-name></span>TestApplication<span
class="xml-tag"></filter-name></span>
<span class="xml-tag"><url-pattern></span>/*<span
class="xml-tag"></url-pattern></span>
<span class="xml-tag"></filter-mapping></span>
-<span class="xml-tag"></web-app></span></pre></div><p
class="paragraph"/>Since this is a standard servlet filter we must map it to a
specific set of URLs through the <code><filter-mapping></code> tag). In
the xml above we have mapped every URL to our Wicket filter.<p
class="paragraph"/><blockquote class="note">
+<span class="xml-tag"></web-app></span></pre></div><p
class="paragraph"/>Since this is a standard servlet filter we must map it to a
specific set of URLs through the <code><filter-mapping></code> tag). In
the xml above we have mapped every URL to our Wicket filter.<p
class="paragraph"/>If we are using Servlet 3 or a later version, we can of
course use a class in place of web.xml to configure our application. The
following example uses annotation @WebFilter.<p class="paragraph"/><div
class="code"><pre>@WebFilter(value = <span
class="java-quote">"/*"</span>, initParams = { @WebInitParam(name
= <span class="java-quote">"applicationClassName"</span>, value = <span
class="java-quote">"com.mycompany.WicketApplication"</span>),
+ @WebInitParam(name=<span
class="java-quote">"filterMappingUrlPattern"</span>, value=<span
class="java-quote">"/*"</span>) })
+<span class="java-keyword">public</span> class ProjectFilter <span
class="java-keyword">extends</span> WicketFilter {<p
class="paragraph"/>}</pre></div><p class="paragraph"/><p
class="paragraph"/><blockquote class="note">
Wicket can be started in two modes named respectively DEVELOPMENT and
DEPLOYMENT. The first mode activates some extra features which help application
development, like resources monitoring and reloading, full stack trace
rendering of exceptions, an AJAX debugger window, etc… The DEPLOYMENT
mode turns off all these features optimizing performances and resource
consumption. In our example projects we will use the default mode which is
DEVELOPMENT. <a href="../guide/single.html#chapter23_1" class="guide">Chapter
23.1</a> contains the chapter âSwitching Wicket to DEPLOYMENT modeâ where
we can find further details about these two modes as well as the possible ways
we have to set the desired one. In any case, DO NOT deploy your applications in
a production environment without switching to DEPLOYMENT mode!
</blockquote><p class="paragraph"/><h3>The application class</h3><p
class="paragraph"/>If we look back at web.xml we can see that we have provided
the Wicket filter with a parameter called <code>applicationClassName</code>.
This value must be the fully qualified class name of a subclass of
<code>org.apache.wicket.Application</code>. This subclass represents our web
application built upon Wicket and it's responsible for configuring it when the
server is starting up. Most of the times our custom application class won't
inherit directly from class <code>Application</code>, but rather from class
<code>org.apache.wicket.protocol.http.WebApplication</code> which provides a
closer integration with servlet infrastructure.
Class <code>Application</code> comes with a set of configuration methods that
we can override to customize our application's settings. One of these methods
is <code>getHomePage()</code> that must be overridden as it is declared
abstract:<p class="paragraph"/><div class="code"><pre><span
class="java-keyword">public</span> <span
class="java-keyword">abstract</span> <span
class="java-object">Class</span><? <span
class="java-keyword">extends</span> Page> getHomePage()</pre></div><p
class="paragraph"/>As you may guess from its name, this method specifies which
page to use as homepage for our application.
Modified: wicket/common/site/trunk/_site/guide/guide/pages/chapter20_3.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/pages/chapter20_3.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/pages/chapter20_3.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/pages/chapter20_3.html Sat Nov
16 16:44:23 2013
@@ -175,8 +175,14 @@ function addJsClass() {
<span class="java-object">String</span> responseTxt =
tester.getLastResponse().getDocument();<p class="paragraph"/> TagTester
tagTester = TagTester.createTagByAttribute(responseTxt, <span
class="java-quote">"class"</span>, <span
class="java-quote">"myClass"</span>);<p class="paragraph"/>
Assert.assertNotNull(tagTester);
Assert.assertEquals(<span class="java-quote">"span"</span>,
tagTester.getName());<p class="paragraph"/> List<TagTester>
tagTesterList = TagTester.createTagsByAttribute(responseTxt,
<span
class="java-quote">"class"</span>, <span
class="java-quote">"myClass"</span>, <span
class="java-keyword">false</span>);<p class="paragraph"/>
Assert.assertEquals(2, tagTesterList.size());
-}</pre></div><p class="paragraph"/>The name of the tag found by TagTester
can be retrieved with its method getName. Method createTagsByAttribute returns
all the tags that have the given value on the given attribute. In the code
above we have used this method to test that our markup contains two tags having
attribute class equal to myClass.
-
+}</pre></div><p class="paragraph"/>The name of the tag found by TagTester
can be retrieved with its method getName. Method createTagsByAttribute returns
all the tags that have the given value on the class attribute. In the code
above we have used this method to test that our markup contains two tags having
attribute class equal to myClass.<p class="paragraph"/>Another utility class
that comes in handy when we want to test components markup is ComponentRenderer
in package org.apache.wicket.core.util.string. The purpose of this class is to
render a page or a component in isolation with its static methods
renderComponent and renderPage. Both methods return the generated markup as
CharSequence:<p class="paragraph"/><div class="code"><pre>@Test
+<span class="java-keyword">public</span> void customComponentMarkupTest()
+{
+ //instantiate MyComponent
+ MyComponent myComponent = //...<p class="paragraph"/> //render and
save component markup
+ <span class="java-object">String</span> componentMarkup =
ComponentRenderer.renderComponent(myComponent);<p class="paragraph"/>
//perform test operations
+ //…
+}</pre></div>
<div style="clear:both;margin-top:15px;"></div>
Modified: wicket/common/site/trunk/_site/guide/guide/pages/chapter2_4.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/pages/chapter2_4.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/pages/chapter2_4.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/pages/chapter2_4.html Sat Nov 16
16:44:23 2013
@@ -163,7 +163,7 @@ Wicket is not the only component oriente
<li><strong class="bold">Wicket is a community driven project</strong>: The
Wicket team supports and promotes the dialogue with the framework's users
through two mailing lists <a href="http://wicket.apache.org/help/email.html"
target="blank">(one for users and another one for framework developers)</a> and
an <a href="https://issues.apache.org/jira/browse/WICKET" target="blank">Apache
JIRA</a> (the issue tracking system). Moreover, as any other Apache project,
Wicket is developed paying great attention to user feedbacks and to suggested
features.</li>
<li><strong class="bold">Wicket is just about Java and good old HTML</strong>:
almost all web frameworks force users to adopt special tags or to use server
side code inside HTML markup. This is clearly in contrast with the concept of
separation between presentation and business logic and it leads to a more
confusing code in our pages. In Wicket we don't have to take care of generating
HTML inside the page itself, and we won't need to use any tag other than
standard HTML tags. All we have to do is to attach our components (Java
instances) to the HTML tags using a simple tag attribute called
<code>wicket:id</code> (we will shortly see how to use it).</li>
<li><strong class="bold">With Wicket we can easily use JavaBeans and <a
href="http://en.wikipedia.org/wiki/Plain_Old_Java_Object"
target="blank">POJO</a> in our web tier</strong>: one of the most annoying and
error-prone task in web development is collecting user input through a form and
keeping form fields updated with previously inserted values. This usually
requires a huge amount of code to extract input from request parameters (which
are strings), parse them to Java types and store them into some kind of
variable. And this is just half of the work we have to do as we must implement
the inverse path (load data from Java to the web form).Moreover, most of the
times our forms will use a JavaBean or a POJO as backing object, meaning that
we must manually map form fields with the corresponding object fields and vice
versa. Wicket comes with an intuitive and flexible mechanism that does this
mapping for us without any configuration overhead (using a convention over
configuration appro
ach) and in a transparent way. <a href="../guide/single.html#chapter10"
class="guide">Chapter 10</a> will introduce the concept of Wicket model and we
will learn how to harness this entity with forms.</li>
-<li><strong class="bold">No complex XML needed</strong>: Wicket was designed
to minimize the amount of configuration files needed to run our applications.
No XML file is required except for the standard deployment descriptor
web.xml.</li>
+<li><strong class="bold">No complex XML needed</strong>: Wicket was designed
to minimize the amount of configuration files needed to run our applications.
No XML file is required except for the standard deployment descriptor web.xml
(unless you are using Servlet 3 or a later version. See <a
href="../guide/single.html#chapter3_2" class="guide">Chapter 4</a> for more
details).</li>
</ul><p class="paragraph"/>
Modified: wicket/common/site/trunk/_site/guide/guide/pages/chapter3_2.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/pages/chapter3_2.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/pages/chapter3_2.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/pages/chapter3_2.html Sat Nov 16
16:44:23 2013
@@ -174,7 +174,9 @@ All the example projects presented in th
<span
class="xml-tag"><filter-name></span>TestApplication<span
class="xml-tag"></filter-name></span>
<span class="xml-tag"><url-pattern></span>/*<span
class="xml-tag"></url-pattern></span>
<span class="xml-tag"></filter-mapping></span>
-<span class="xml-tag"></web-app></span></pre></div><p
class="paragraph"/>Since this is a standard servlet filter we must map it to a
specific set of URLs through the <code><filter-mapping></code> tag). In
the xml above we have mapped every URL to our Wicket filter.<p
class="paragraph"/><blockquote class="note">
+<span class="xml-tag"></web-app></span></pre></div><p
class="paragraph"/>Since this is a standard servlet filter we must map it to a
specific set of URLs through the <code><filter-mapping></code> tag). In
the xml above we have mapped every URL to our Wicket filter.<p
class="paragraph"/>If we are using Servlet 3 or a later version, we can of
course use a class in place of web.xml to configure our application. The
following example uses annotation @WebFilter.<p class="paragraph"/><div
class="code"><pre>@WebFilter(value = <span
class="java-quote">"/*"</span>, initParams = { @WebInitParam(name
= <span class="java-quote">"applicationClassName"</span>, value = <span
class="java-quote">"com.mycompany.WicketApplication"</span>),
+ @WebInitParam(name=<span
class="java-quote">"filterMappingUrlPattern"</span>, value=<span
class="java-quote">"/*"</span>) })
+<span class="java-keyword">public</span> class ProjectFilter <span
class="java-keyword">extends</span> WicketFilter {<p
class="paragraph"/>}</pre></div><p class="paragraph"/><p
class="paragraph"/><blockquote class="note">
Wicket can be started in two modes named respectively DEVELOPMENT and
DEPLOYMENT. The first mode activates some extra features which help application
development, like resources monitoring and reloading, full stack trace
rendering of exceptions, an AJAX debugger window, etc… The DEPLOYMENT
mode turns off all these features optimizing performances and resource
consumption. In our example projects we will use the default mode which is
DEVELOPMENT. <a href="../guide/single.html#chapter23_1" class="guide">Chapter
23.1</a> contains the chapter âSwitching Wicket to DEPLOYMENT modeâ where
we can find further details about these two modes as well as the possible ways
we have to set the desired one. In any case, DO NOT deploy your applications in
a production environment without switching to DEPLOYMENT mode!
</blockquote><p class="paragraph"/><h3>The application class</h3><p
class="paragraph"/>If we look back at web.xml we can see that we have provided
the Wicket filter with a parameter called <code>applicationClassName</code>.
This value must be the fully qualified class name of a subclass of
<code>org.apache.wicket.Application</code>. This subclass represents our web
application built upon Wicket and it's responsible for configuring it when the
server is starting up. Most of the times our custom application class won't
inherit directly from class <code>Application</code>, but rather from class
<code>org.apache.wicket.protocol.http.WebApplication</code> which provides a
closer integration with servlet infrastructure.
Class <code>Application</code> comes with a set of configuration methods that
we can override to customize our application's settings. One of these methods
is <code>getHomePage()</code> that must be overridden as it is declared
abstract:<p class="paragraph"/><div class="code"><pre><span
class="java-keyword">public</span> <span
class="java-keyword">abstract</span> <span
class="java-object">Class</span><? <span
class="java-keyword">extends</span> Page> getHomePage()</pre></div><p
class="paragraph"/>As you may guess from its name, this method specifies which
page to use as homepage for our application.
Modified: wicket/common/site/trunk/_site/guide/guide/single.html
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/single.html?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/single.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/single.html Sat Nov 16 16:44:23
2013
@@ -513,7 +513,7 @@ Wicket is not the only component oriente
<li><strong class="bold">Wicket is a community driven project</strong>: The
Wicket team supports and promotes the dialogue with the framework's users
through two mailing lists <a href="http://wicket.apache.org/help/email.html"
target="blank">(one for users and another one for framework developers)</a> and
an <a href="https://issues.apache.org/jira/browse/WICKET" target="blank">Apache
JIRA</a> (the issue tracking system). Moreover, as any other Apache project,
Wicket is developed paying great attention to user feedbacks and to suggested
features.</li>
<li><strong class="bold">Wicket is just about Java and good old HTML</strong>:
almost all web frameworks force users to adopt special tags or to use server
side code inside HTML markup. This is clearly in contrast with the concept of
separation between presentation and business logic and it leads to a more
confusing code in our pages. In Wicket we don't have to take care of generating
HTML inside the page itself, and we won't need to use any tag other than
standard HTML tags. All we have to do is to attach our components (Java
instances) to the HTML tags using a simple tag attribute called
<code>wicket:id</code> (we will shortly see how to use it).</li>
<li><strong class="bold">With Wicket we can easily use JavaBeans and <a
href="http://en.wikipedia.org/wiki/Plain_Old_Java_Object"
target="blank">POJO</a> in our web tier</strong>: one of the most annoying and
error-prone task in web development is collecting user input through a form and
keeping form fields updated with previously inserted values. This usually
requires a huge amount of code to extract input from request parameters (which
are strings), parse them to Java types and store them into some kind of
variable. And this is just half of the work we have to do as we must implement
the inverse path (load data from Java to the web form).Moreover, most of the
times our forms will use a JavaBean or a POJO as backing object, meaning that
we must manually map form fields with the corresponding object fields and vice
versa. Wicket comes with an intuitive and flexible mechanism that does this
mapping for us without any configuration overhead (using a convention over
configuration appro
ach) and in a transparent way. <a href="../guide/single.html#chapter10"
class="guide">Chapter 10</a> will introduce the concept of Wicket model and we
will learn how to harness this entity with forms.</li>
-<li><strong class="bold">No complex XML needed</strong>: Wicket was designed
to minimize the amount of configuration files needed to run our applications.
No XML file is required except for the standard deployment descriptor
web.xml.</li>
+<li><strong class="bold">No complex XML needed</strong>: Wicket was designed
to minimize the amount of configuration files needed to run our applications.
No XML file is required except for the standard deployment descriptor web.xml
(unless you are using Servlet 3 or a later version. See <a
href="../guide/single.html#chapter3_2" class="guide">Chapter 4</a> for more
details).</li>
</ul><p class="paragraph"/>
@@ -545,7 +545,9 @@ All the example projects presented in th
<span
class="xml-tag"><filter-name></span>TestApplication<span
class="xml-tag"></filter-name></span>
<span class="xml-tag"><url-pattern></span>/*<span
class="xml-tag"></url-pattern></span>
<span class="xml-tag"></filter-mapping></span>
-<span class="xml-tag"></web-app></span></pre></div><p
class="paragraph"/>Since this is a standard servlet filter we must map it to a
specific set of URLs through the <code><filter-mapping></code> tag). In
the xml above we have mapped every URL to our Wicket filter.<p
class="paragraph"/><blockquote class="note">
+<span class="xml-tag"></web-app></span></pre></div><p
class="paragraph"/>Since this is a standard servlet filter we must map it to a
specific set of URLs through the <code><filter-mapping></code> tag). In
the xml above we have mapped every URL to our Wicket filter.<p
class="paragraph"/>If we are using Servlet 3 or a later version, we can of
course use a class in place of web.xml to configure our application. The
following example uses annotation @WebFilter.<p class="paragraph"/><div
class="code"><pre>@WebFilter(value = <span
class="java-quote">"/*"</span>, initParams = { @WebInitParam(name
= <span class="java-quote">"applicationClassName"</span>, value = <span
class="java-quote">"com.mycompany.WicketApplication"</span>),
+ @WebInitParam(name=<span
class="java-quote">"filterMappingUrlPattern"</span>, value=<span
class="java-quote">"/*"</span>) })
+<span class="java-keyword">public</span> class ProjectFilter <span
class="java-keyword">extends</span> WicketFilter {<p
class="paragraph"/>}</pre></div><p class="paragraph"/><p
class="paragraph"/><blockquote class="note">
Wicket can be started in two modes named respectively DEVELOPMENT and
DEPLOYMENT. The first mode activates some extra features which help application
development, like resources monitoring and reloading, full stack trace
rendering of exceptions, an AJAX debugger window, etc… The DEPLOYMENT
mode turns off all these features optimizing performances and resource
consumption. In our example projects we will use the default mode which is
DEVELOPMENT. <a href="../guide/single.html#chapter23_1" class="guide">Chapter
23.1</a> contains the chapter âSwitching Wicket to DEPLOYMENT modeâ where
we can find further details about these two modes as well as the possible ways
we have to set the desired one. In any case, DO NOT deploy your applications in
a production environment without switching to DEPLOYMENT mode!
</blockquote><p class="paragraph"/><h3>The application class</h3><p
class="paragraph"/>If we look back at web.xml we can see that we have provided
the Wicket filter with a parameter called <code>applicationClassName</code>.
This value must be the fully qualified class name of a subclass of
<code>org.apache.wicket.Application</code>. This subclass represents our web
application built upon Wicket and it's responsible for configuring it when the
server is starting up. Most of the times our custom application class won't
inherit directly from class <code>Application</code>, but rather from class
<code>org.apache.wicket.protocol.http.WebApplication</code> which provides a
closer integration with servlet infrastructure.
Class <code>Application</code> comes with a set of configuration methods that
we can override to customize our application's settings. One of these methods
is <code>getHomePage()</code> that must be overridden as it is declared
abstract:<p class="paragraph"/><div class="code"><pre><span
class="java-keyword">public</span> <span
class="java-keyword">abstract</span> <span
class="java-object">Class</span><? <span
class="java-keyword">extends</span> Page> getHomePage()</pre></div><p
class="paragraph"/>As you may guess from its name, this method specifies which
page to use as homepage for our application.
@@ -3759,8 +3761,14 @@ formTester.submit(<span class="java-
<span class="java-object">String</span> responseTxt =
tester.getLastResponse().getDocument();<p class="paragraph"/> TagTester
tagTester = TagTester.createTagByAttribute(responseTxt, <span
class="java-quote">"class"</span>, <span
class="java-quote">"myClass"</span>);<p class="paragraph"/>
Assert.assertNotNull(tagTester);
Assert.assertEquals(<span class="java-quote">"span"</span>,
tagTester.getName());<p class="paragraph"/> List<TagTester>
tagTesterList = TagTester.createTagsByAttribute(responseTxt,
<span
class="java-quote">"class"</span>, <span
class="java-quote">"myClass"</span>, <span
class="java-keyword">false</span>);<p class="paragraph"/>
Assert.assertEquals(2, tagTesterList.size());
-}</pre></div><p class="paragraph"/>The name of the tag found by TagTester
can be retrieved with its method getName. Method createTagsByAttribute returns
all the tags that have the given value on the given attribute. In the code
above we have used this method to test that our markup contains two tags having
attribute class equal to myClass.
-
+}</pre></div><p class="paragraph"/>The name of the tag found by TagTester
can be retrieved with its method getName. Method createTagsByAttribute returns
all the tags that have the given value on the class attribute. In the code
above we have used this method to test that our markup contains two tags having
attribute class equal to myClass.<p class="paragraph"/>Another utility class
that comes in handy when we want to test components markup is ComponentRenderer
in package org.apache.wicket.core.util.string. The purpose of this class is to
render a page or a component in isolation with its static methods
renderComponent and renderPage. Both methods return the generated markup as
CharSequence:<p class="paragraph"/><div class="code"><pre>@Test
+<span class="java-keyword">public</span> void customComponentMarkupTest()
+{
+ //instantiate MyComponent
+ MyComponent myComponent = //...<p class="paragraph"/> //render and
save component markup
+ <span class="java-object">String</span> componentMarkup =
ComponentRenderer.renderComponent(myComponent);<p class="paragraph"/>
//perform test operations
+ //…
+}</pre></div>
<h2 id="chapter20_4">21.4 Summary</h2>
Modified: wicket/common/site/trunk/_site/guide/guide/single.pdf
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/single.pdf?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
Binary files - no diff available.
Modified:
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter2/chapter2_4.gdoc
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter2/chapter2_4.gdoc?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
---
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter2/chapter2_4.gdoc
(original)
+++
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter2/chapter2_4.gdoc
Sat Nov 16 16:44:23 2013
@@ -8,4 +8,4 @@ Wicket is not the only component oriente
* *With Wicket we can easily use JavaBeans and
"POJO":http://en.wikipedia.org/wiki/Plain_Old_Java_Object in our web tier*: one
of the most annoying and error-prone task in web development is collecting user
input through a form and keeping form fields updated with previously inserted
values. This usually requires a huge amount of code to extract input from
request parameters (which are strings), parse them to Java types and store them
into some kind of variable. And this is just half of the work we have to do as
we must implement the inverse path (load data from Java to the web
form).Moreover, most of the times our forms will use a JavaBean or a POJO as
backing object, meaning that we must manually map form fields with the
corresponding object fields and vice versa. Wicket comes with an intuitive and
flexible mechanism that does this mapping for us without any configuration
overhead (using a convention over configuration approach) and in a transparent
way. [Chapter 10|guide:chapter1
0] will introduce the concept of Wicket model and we will learn how to harness
this entity with forms.
-* *No complex XML needed*: Wicket was designed to minimize the amount of
configuration files needed to run our applications. No XML file is required
except for the standard deployment descriptor web.xml.
\ No newline at end of file
+* *No complex XML needed*: Wicket was designed to minimize the amount of
configuration files needed to run our applications. No XML file is required
except for the standard deployment descriptor web.xml (unless you are using
Servlet 3 or a later version. See [Chapter 4|guide:chapter3_2] for more
details).
\ No newline at end of file
Modified:
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter20/chapter20_3.gdoc
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter20/chapter20_3.gdoc?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
---
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter20/chapter20_3.gdoc
(original)
+++
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter20/chapter20_3.gdoc
Sat Nov 16 16:44:23 2013
@@ -29,17 +29,34 @@ public void homePageMarkupTest()
tester.startPage(HomePage.class);
//retrieve response's markup
String responseTxt = tester.getLastResponse().getDocument();
-
+
TagTester tagTester = TagTester.createTagByAttribute(responseTxt,
"class", "myClass");
-
+
Assert.assertNotNull(tagTester);
Assert.assertEquals("span", tagTester.getName());
-
+
List<TagTester> tagTesterList =
TagTester.createTagsByAttribute(responseTxt,
"class", "myClass", false);
-
+
Assert.assertEquals(2, tagTesterList.size());
}
{code}
-The name of the tag found by TagTester can be retrieved with its method
getName. Method createTagsByAttribute returns all the tags that have the given
value on the given attribute. In the code above we have used this method to
test that our markup contains two tags having attribute class equal to myClass.
+The name of the tag found by TagTester can be retrieved with its method
getName. Method createTagsByAttribute returns all the tags that have the given
value on the class attribute. In the code above we have used this method to
test that our markup contains two tags having attribute class equal to myClass.
+
+Another utility class that comes in handy when we want to test components
markup is ComponentRenderer in package org.apache.wicket.core.util.string. The
purpose of this class is to render a page or a component in isolation with its
static methods renderComponent and renderPage. Both methods return the
generated markup as CharSequence:
+
+{code}
+@Test
+public void customComponentMarkupTest()
+{
+ //instantiate MyComponent
+ MyComponent myComponent = //...
+
+ //render and save component markup
+ String componentMarkup = ComponentRenderer.renderComponent(myComponent);
+
+ //perform test operations
+ //...
+}
+{code}
\ No newline at end of file
Modified:
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter3/chapter3_2.gdoc
URL:
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter3/chapter3_2.gdoc?rev=1542531&r1=1542530&r2=1542531&view=diff
==============================================================================
---
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter3/chapter3_2.gdoc
(original)
+++
wicket/common/site/trunk/_site/guide/guide/src/docs/guide/chapter3/chapter3_2.gdoc
Sat Nov 16 16:44:23 2013
@@ -35,6 +35,18 @@ The content of web.xml declares a servle
Since this is a standard servlet filter we must map it to a specific set of
URLs through the @<filter-mapping>@ tag). In the xml above we have mapped every
URL to our Wicket filter.
+If we are using Servlet 3 or a later version, we can of course use a class in
place of web.xml to configure our application. The following example uses
annotation @WebFilter.
+
+{code}
+@WebFilter(value = "/*", initParams = { @WebInitParam(name =
"applicationClassName", value = "com.mycompany.WicketApplication"),
+ @WebInitParam(name="filterMappingUrlPattern",
value="/*") })
+public class ProjectFilter extends WicketFilter {
+
+}
+{code}
+
+
+
{note}
Wicket can be started in two modes named respectively DEVELOPMENT and
DEPLOYMENT. The first mode activates some extra features which help application
development, like resources monitoring and reloading, full stack trace
rendering of exceptions, an AJAX debugger window, etc... The DEPLOYMENT mode
turns off all these features optimizing performances and resource consumption.
In our example projects we will use the default mode which is DEVELOPMENT.
[Chapter 23.1|guide:chapter23_1] contains the chapter âSwitching Wicket to
DEPLOYMENT modeâ where we can find further details about these two modes as
well as the possible ways we have to set the desired one. In any case, DO NOT
deploy your applications in a production environment without switching to
DEPLOYMENT mode!
{note}