Modified: wicket/common/site/trunk/_site/guide/guide/pages/chapter7_2.html
URL: 
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/pages/chapter7_2.html?rev=1548920&r1=1548919&r2=1548920&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/pages/chapter7_2.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/pages/chapter7_2.html Sat Dec  7 
14:58:57 2013
@@ -175,7 +175,7 @@ function addJsClass() {
 &#125;</pre></div><p class="paragraph"/>Now if we run the new example (project 
LifeCycleStagesRevisited) and we click on the “Reload” button, a new page 
version is created and the page id is increased by one:<p 
class="paragraph"/><img border="0" class="center" 
src="../img/reload-page.png"></img><p class="paragraph"/>If we press the back 
button the page version previously rendered (and serialized) will be retrieved 
(i.e. deserialized) and it will be used again to respond to our request (and 
page id is decremented):<p class="paragraph"/><img border="0" class="center" 
src="../img/browser-back.png"></img><p class="paragraph"/><blockquote 
class="note">
 For more details about page storing you can visit the wiki page at 
https://cwiki.apache.org/confluence/display/WICKET/Page+Storage . 
 On this page you can find which classes are involved into page storing 
mechanism and how they work together.
-</blockquote><p class="paragraph"/>As we have stated at the beginning of this 
chapter, page versions are stored using Java serialization, therefore every 
object referenced inside a page must be serializable1. In paragraph 9.6 we will 
see how to overcome this limit and work with non-serializable objects in our 
components using detachable Wicket models.<p class="paragraph"/><h3>Using a 
specific page version with PageReference</h3><p class="paragraph"/>To retrieve 
a specific page version in our code we can use class org.apache.wicket. 
PageReference by providing its constructor with the corresponding page id:<p 
class="paragraph"/><div class="code"><pre>//load page version with page id = 3
+</blockquote><p class="paragraph"/>As we have stated at the beginning of this 
chapter, page versions are stored using Java serialization, therefore every 
object referenced inside a page must be serializable1. In paragraph 9.6 we will 
see how to overcome this limit and work with non-serializable objects in our 
components using detachable Wicket models.<p class="paragraph"/><h3>Using a 
specific page version with PageReference</h3><p class="paragraph"/>To retrieve 
a specific page version in our code we can use class 
org.apache.wicket.PageReference by providing its constructor with the 
corresponding page id:<p class="paragraph"/><div class="code"><pre>//load page 
version with page id = 3
 PageReference pageReference = <span class="java&#45;keyword">new</span> 
PageReference(3);
 //load the related page instance
 Page page = pageReference.getPage();</pre></div><p class="paragraph"/>To get 
the related page instance we must use method getPage.<p 
class="paragraph"/><h3>Turning off page versioning</h3><p class="paragraph"/>If 
for any reason we need to switch off versioning for a given page, we can call 
its method setVersioned(false).<p class="paragraph"/><h3>Pluggable 
serialization</h3><p class="paragraph"/>Starting from version 1.5 it is 
possible to choose which implementation of Java serialization will be used by 
Wicket to store page versions. Wicket serializes pages using an implementation 
of interface org.apache.wicket.serialize.ISerializer. The default 
implementation is org.apache.wicket.serialize.java.JavaSerializer and it uses 
the standard Java serialization mechanism based on classes ObjectOutputStream 
and ObjectInputStream. However on Internet we can find other interesting 
serialization libraries like Kryo1 which performs faster then the standard 
implementation.The serializer in use can
  be customized with the setSerializer(ISerializer) method defined by setting 
interface org.apache.wicket.settings.IFrameworkSettings.<p 
class="paragraph"/>We can access this interface inside the method init of the 
class Application using the getFrameworkSettings() method :<p 
class="paragraph"/><div class="code"><pre>@Override
@@ -183,7 +183,7 @@ Page page = pageReference.getPage();</pr
 &#123;
        <span class="java&#45;keyword">super</span>.init();
        getFrameworkSettings().setSerializer(yourSerializer);
-&#125;</pre></div><p class="paragraph"/>A serializer based on Kryo library is 
provided by the WicketStuff project. You can find more information on this 
project, as well as the instructions to use its modules, in Appendix B.<p 
class="paragraph"/><h3>Page caching</h3><p class="paragraph"/>By default Wicket 
persists versions of pages into a session-relative file on disk, but it uses a 
two-levels cache to speed up this process. The first level of the cache uses a 
http session attribute called 
“wicket:persistentPageManagerData-&#60;APPLICATION_NAME&#62;” to store 
pages. The second level cache stores pages into application-scoped variables 
which are identified by a session id and a page id.<p class="paragraph"/>The 
following picture is an overview of these two caching levels:<p 
class="paragraph"/><img border="0" class="center" 
src="../img/wicket-cache.png"></img><p class="paragraph"/>The session-scoped 
cache is faster then the other memory levels but it contains only the pages 
 used to serve the last request. Wicket allows us to set the maximum amount of 
memory allowed for the application-scoped cache and for the page store file. 
Both parameters can be configured via setting interface org.apache 
.wicket.settings.IStoreSettings.<p class="paragraph"/>This interface provides 
the setMaxSizePerSession(Bytes bytes) method to set the size for page store 
file. The Bytes parameter is the maximum size allowed for this file:<p 
class="paragraph"/><div class="code"><pre>@Override
+&#125;</pre></div><p class="paragraph"/>A serializer based on Kryo library is 
provided by the WicketStuff project. You can find more information on this 
project, as well as the instructions to use its modules, in Appendix B.<p 
class="paragraph"/><h3>Page caching</h3><p class="paragraph"/>By default Wicket 
persists versions of pages into a session-relative file on disk, but it uses a 
two-levels cache to speed up this process. The first level of the cache uses a 
http session attribute called 
“wicket:persistentPageManagerData-&#60;APPLICATION_NAME&#62;” to store 
pages. The second level cache stores pages into application-scoped variables 
which are identified by a session id and a page id.<p class="paragraph"/>The 
following picture is an overview of these two caching levels:<p 
class="paragraph"/><img border="0" class="center" 
src="../img/wicket-cache.png"></img><p class="paragraph"/>The session-scoped 
cache is faster then the other memory levels but it contains only the pages 
 used to serve the last request. Wicket allows us to set the maximum amount of 
memory allowed for the application-scoped cache and for the page store file. 
Both parameters can be configured via setting interface 
org.apache.wicket.settings.IStoreSettings.<p class="paragraph"/>This interface 
provides the setMaxSizePerSession(Bytes bytes) method to set the size for page 
store file. The Bytes parameter is the maximum size allowed for this file:<p 
class="paragraph"/><div class="code"><pre>@Override
 <span class="java&#45;keyword">public</span> void init()
 &#123;
        <span class="java&#45;keyword">super</span>.init();

Modified: wicket/common/site/trunk/_site/guide/guide/pages/chapter8_3.html
URL: 
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/pages/chapter8_3.html?rev=1548920&r1=1548919&r2=1548920&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/pages/chapter8_3.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/pages/chapter8_3.html Sat Dec  7 
14:58:57 2013
@@ -168,7 +168,7 @@ This paragraph will provide just the bas
 <li>a page class, via the urlFor(Class&#60;C&#62; pageClass, PageParameters 
parameters) method</li>
 <li>an IRequestHandler via the urlFor(IRequestHandler handler) method</li>
 <li>a ResourceReference via the urlFor(ResourceReference reference, 
PageParameters params) method (resource entities will be introduced in chapter 
13).</li>
-</ul><p class="paragraph"/>The overloaded urlFor method from above also has a 
corresponding version that returns an instance of org.apache.wicket.request.Url 
instead of a CharSequence. This version has the prefix 'map' in its name (i.e. 
it has mapUrlFor as full name).<p class="paragraph"/><h3>Method 
setResponsePage</h3><p class="paragraph"/>The RequestCycle class contains the 
implementation of the setResponsePage method we use to redirect a user to a 
specific page (see paragraph 2.4). The namesake method of class 
org.apache.wicket. Component is just a convenience method that internally 
invokes the actual implementation on current request cycle:<p 
class="paragraph"/><div class="code"><pre><span 
class="java&#45;keyword">public</span> <span 
class="java&#45;keyword">final</span> void setResponsePage(<span 
class="java&#45;keyword">final</span> Page page) &#123;
+</ul><p class="paragraph"/>The overloaded urlFor method from above also has a 
corresponding version that returns an instance of org.apache.wicket.request.Url 
instead of a CharSequence. This version has the prefix 'map' in its name (i.e. 
it has mapUrlFor as full name).<p class="paragraph"/><h3>Method 
setResponsePage</h3><p class="paragraph"/>The RequestCycle class contains the 
implementation of the setResponsePage method we use to redirect a user to a 
specific page (see paragraph 2.4). The namesake method of class 
org.apache.wicket.Component is just a convenience method that internally 
invokes the actual implementation on current request cycle:<p 
class="paragraph"/><div class="code"><pre><span 
class="java&#45;keyword">public</span> <span 
class="java&#45;keyword">final</span> void setResponsePage(<span 
class="java&#45;keyword">final</span> Page page) &#123;
        getRequestCycle().setResponsePage(page);
 &#125;</pre></div><p class="paragraph"/><h3>RequestCycle's hook methods and 
listeners</h3><p class="paragraph"/>The RequestCycle comes with some hook 
methods which can be overridden to perform custom actions when request handling 
reaches a specific stage. These methods are:
 <ul class="star">
@@ -190,7 +190,7 @@ This paragraph will provide just the bas
 <span class="java&#45;keyword">public</span> void init() &#123;<p 
class="paragraph"/>  <span class="java&#45;keyword">super</span>.init();<p 
class="paragraph"/>       IRequestCycleListener myListener;
        //listener initialization&#8230;
        getRequestCycleListeners().add(myListener)              
-&#125;</pre></div><p class="paragraph"/>The getRequestCycleListeners method 
returns an instance of class org.apache.wicket. 
request.cycle.RequestCycleListenerCollection. This class is a sort of typed 
collection for IRequestCycleListener and it also implements the <a 
href="http://en.wikipedia.org/wiki/Composite_pattern"; target="blank">Composite 
pattern</a> .<p class="paragraph"/>
+&#125;</pre></div><p class="paragraph"/>The getRequestCycleListeners method 
returns an instance of class 
org.apache.wicket.request.cycle.RequestCycleListenerCollection. This class is a 
sort of typed collection for IRequestCycleListener and it also implements the 
<a href="http://en.wikipedia.org/wiki/Composite_pattern"; 
target="blank">Composite pattern</a> .<p class="paragraph"/>
 
 
                 <div style="clear:both;margin-top:15px;"></div>

Modified: wicket/common/site/trunk/_site/guide/guide/pages/chapter8_4.html
URL: 
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/pages/chapter8_4.html?rev=1548920&r1=1548919&r2=1548920&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/pages/chapter8_4.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/pages/chapter8_4.html Sat Dec  7 
14:58:57 2013
@@ -157,7 +157,7 @@ function addJsClass() {
                 
 
 <h2 id="chapter8_4">9.4 Session Class</h2>
-<p class="paragraph"/>In Wicket we use class org.apache.wicket.Session to 
handle session-relative informations such as client informations, session 
attributes, session-level cache (seen in paragraph 6.2.4), etc...<p 
class="paragraph"/>In addition, we know from paragraph 6.1 that Wicket creates 
a user session to store versions of stateful pages. Similarly to what happens 
with RequestCycle, the new Session's instances are generated by the Application 
class with the newSession(Request request, Response response) method. This 
method is not declared as final, hence it can be overridden if we need to use a 
custom implementation of the Session class.<p class="paragraph"/>By default if 
our custom application class is a subclass of WebApplication, method newSession 
will return an instance of class org.apache.wicket.protocol.http.WebSession. As 
we have mentioned talking about RequestCycle, also class Session provides a 
static get() method which returns the session associated to the current th
 read.<p class="paragraph"/><h3>Session and listeners</h3><p 
class="paragraph"/>Similar to the RequestCycle, class org.apache.wicket.Session 
also offers support for listener entities. With Session these entities must 
implement the callback interface org.apache.wicket. ISessionListener which 
exposes only the onCreated(Session session) method. As you might guess from its 
name, this method is called when a new session is created. Session listeners 
must be added to our application using a typed collection, just like we have 
done before with request cycle listeners:<p class="paragraph"/><div 
class="code"><pre>@Override
+<p class="paragraph"/>In Wicket we use class org.apache.wicket.Session to 
handle session-relative informations such as client informations, session 
attributes, session-level cache (seen in paragraph 6.2.4), etc...<p 
class="paragraph"/>In addition, we know from paragraph 6.1 that Wicket creates 
a user session to store versions of stateful pages. Similarly to what happens 
with RequestCycle, the new Session's instances are generated by the Application 
class with the newSession(Request request, Response response) method. This 
method is not declared as final, hence it can be overridden if we need to use a 
custom implementation of the Session class.<p class="paragraph"/>By default if 
our custom application class is a subclass of WebApplication, method newSession 
will return an instance of class org.apache.wicket.protocol.http.WebSession. As 
we have mentioned talking about RequestCycle, also class Session provides a 
static get() method which returns the session associated to the current th
 read.<p class="paragraph"/><h3>Session and listeners</h3><p 
class="paragraph"/>Similar to the RequestCycle, class org.apache.wicket.Session 
also offers support for listener entities. With Session these entities must 
implement the callback interface org.apache.wicket.ISessionListener which 
exposes only the onCreated(Session session) method. As you might guess from its 
name, this method is called when a new session is created. Session listeners 
must be added to our application using a typed collection, just like we have 
done before with request cycle listeners:<p class="paragraph"/><div 
class="code"><pre>@Override
 <span class="java&#45;keyword">public</span> void init()&#123;<p 
class="paragraph"/>   <span class="java&#45;keyword">super</span>.init();<p 
class="paragraph"/>       //listener initialization&#8230;
        ISessionListener myListener;
        //add a custom session listener

Modified: wicket/common/site/trunk/_site/guide/guide/pages/chapter9_6.html
URL: 
http://svn.apache.org/viewvc/wicket/common/site/trunk/_site/guide/guide/pages/chapter9_6.html?rev=1548920&r1=1548919&r2=1548920&view=diff
==============================================================================
--- wicket/common/site/trunk/_site/guide/guide/pages/chapter9_6.html (original)
+++ wicket/common/site/trunk/_site/guide/guide/pages/chapter9_6.html Sat Dec  7 
14:58:57 2013
@@ -164,7 +164,7 @@ function addJsClass() {
        mountPage(<span class="java&#45;quote">"/pageMount"</span>, 
MountedPage.class);
        //Other initialization code&#8230;
 &#125;</pre></div><p class="paragraph"/>The path provided to mountPage will be 
used to generate the URL for any page of the specified class:<p 
class="paragraph"/><div class="code"><pre>//it will <span 
class="java&#45;keyword">return</span> <span 
class="java&#45;quote">"/pageMount"</span>
-RequestCycle.get().urlFor(MountedPage.class);</pre></div><p 
class="paragraph"/>Under the hood the mountPage method mounts an instance of 
the request mapper org.apache. wicket.request.mapper.MountedMapper configured 
for the given path:<p class="paragraph"/><div class="code"><pre><span 
class="java&#45;keyword">public</span> <span 
class="java&#45;keyword">final</span> &#60;T <span 
class="java&#45;keyword">extends</span> Page&#62; void mountPage(<span 
class="java&#45;keyword">final</span> <span 
class="java&#45;object">String</span> path,<span 
class="java&#45;keyword">final</span> <span 
class="java&#45;object">Class</span>&#60;T&#62; pageClass) &#123;
+RequestCycle.get().urlFor(MountedPage.class);</pre></div><p 
class="paragraph"/>Under the hood the mountPage method mounts an instance of 
the request mapper org.apache.wicket.request.mapper.MountedMapper configured 
for the given path:<p class="paragraph"/><div class="code"><pre><span 
class="java&#45;keyword">public</span> <span 
class="java&#45;keyword">final</span> &#60;T <span 
class="java&#45;keyword">extends</span> Page&#62; void mountPage(<span 
class="java&#45;keyword">final</span> <span 
class="java&#45;object">String</span> path,<span 
class="java&#45;keyword">final</span> <span 
class="java&#45;object">Class</span>&#60;T&#62; pageClass) &#123;
        mount(<span class="java&#45;keyword">new</span> MountedMapper(path, 
pageClass));
 &#125;</pre></div><p class="paragraph"/>Request mappers and the Application's 
method mount have been introduced in the previous chapter (paragraph 7.3.1).<p 
class="paragraph"/><h3>Using parameter placeholders with mounted pages</h3><p 
class="paragraph"/>The path specified for mounted pages can contain dynamic 
segments which are populated with the values of the named parameters used to 
build the page. These segments are declared using special segments called 
parameter placeholders. Consider the path used in the following example:<p 
class="paragraph"/><div class="code"><pre>mountPage(<span 
class="java&#45;quote">"/pageMount/$&#123;foo&#125;/otherSegm"</span>, 
MountedPageWithPlaceholder.class);</pre></div><p class="paragraph"/>The path 
used above is composed by three segments: the first and the last are fixed 
while the second will be replaced by the value of the named parameter foo that 
must be provided when the page  MountedPageWithPlaceholder is instantiated:<p 
class="paragraph"/>Jav
 a code:<p class="paragraph"/><div class="code"><pre>PageParameters 
pageParameters = <span class="java&#45;keyword">new</span> PageParameters();
 pageParameters.add(<span class="java&#45;quote">"foo"</span>, <span 
class="java&#45;quote">"foo"</span>);<p 
class="paragraph"/>setResponsePage(MountedPageWithPlaceholder.class, 
pageParameters)</pre></div><p class="paragraph"/>Generated URL:<p 
class="paragraph"/><div class="code"><pre>&#60;Application 
path&#62;/pageMount/foo/otherSegm</pre></div><p class="paragraph"/>On the 
contrary if we manually insert an URL like '&#60;web app 
path&#62;/pageMount/bar/otherSegm', we can read value 'bar' retrieving the 
named parameter foo inside our page.<p class="paragraph"/>Place holders can be 
declared as optional using the '#' character in place of '$':<p 
class="paragraph"/><div class="code"><pre>mountPage(<span 
class="java&#45;quote">"/pageMount/&#35;&#123;foo&#125;/otherSegm"</span>, 
MountedPageOptionalPlaceholder.class);</pre></div><p class="paragraph"/>If the 
named parameter for an optional placeholder is missing, the corresponding 
segment is removed from the final URL:<p class="paragraph"/>
 Java code:<p class="paragraph"/><div class="code"><pre>PageParameters 
pageParameters = <span class="java&#45;keyword">new</span> PageParameters();


Reply via email to