Author: cbrisson
Date: Tue Jun 26 10:21:36 2018
New Revision: 1834414

URL: http://svn.apache.org/viewvc?rev=1834414&view=rev
Log:
[site/tools] Update VelocityLayoutServlet doc => prod

Modified:
    velocity/site/production/tools/devel/view-layoutservlet.html

Modified: velocity/site/production/tools/devel/view-layoutservlet.html
URL: 
http://svn.apache.org/viewvc/velocity/site/production/tools/devel/view-layoutservlet.html?rev=1834414&r1=1834413&r2=1834414&view=diff
==============================================================================
--- velocity/site/production/tools/devel/view-layoutservlet.html (original)
+++ velocity/site/production/tools/devel/view-layoutservlet.html Tue Jun 26 
10:21:36 2018
@@ -249,13 +249,30 @@ h2:hover > .headerlink, h3:hover > .head
 
 <p>This saves you the trouble of doing the basic <html>,<head>, and <body> 
tags in every single screen.  That's the point of layouts: to save effort and 
eliminate redundancy.  Note that this still lets the inner screen control the 
title of the page.  This works because the layout template is blessed by the 
VLS with access to the same context as the screen <em>after</em> the screen is 
done with it. Just do a <code>#set( $page_title = "Hello" )</code> in the 
screen.</p>
 <h2 id="alternative-layouts">Alternative Layouts<a class="headerlink" 
href="#alternative-layouts" title="Permanent link">&para;</a></h2>
-<p>VLS provides two ways to specify an alternate template for a requested 
page:</p>
+<p>VLS provides several ways to specify an alternate template for a requested 
page:</p>
 <ol>
-<li><strong>Specify the layout in the request parameters</strong></li>
-</ol>
-<p>Just add the query string "layout=MyOtherLayout.vm" to any request params 
and the VLS will find it and render your screen within that layout instead of 
the default layout.  It don't matter how you get the layout param into the 
query data, only that it's there.</p>
-<ol>
-<li><strong>Specify the layout in the requested screen.</strong></li>
+<li>
+<p><strong>Specify the layout in the request attribute</strong></p>
+<div class="codehilite"><pre><span class="n">request</span><span 
class="o">.</span><span class="na">setAttribute</span><span 
class="o">(</span><span class="s">&quot;layout&quot;</span><span 
class="o">,</span> <span class="s">&quot;MyOtherLayout.vm&quot;</span><span 
class="o">);</span>
+</pre></div>
+
+
+</li>
+<li>
+<p><strong>Specify the layout by overloading the 
<code>VelocityLayoutServlet.findLayout(HttpServletRequest)</code> 
function</strong></p>
+<div class="codehilite"><pre><span class="nd">@Override</span>
+<span class="kd">public</span> <span class="n">String</span> <span 
class="nf">findLayout</span><span class="o">(</span><span 
class="n">HttpServletRequest</span> <span class="n">request</span><span 
class="o">)</span>
+<span class="o">{</span>
+    <span class="k">if</span> <span class="o">(</span><span 
class="n">request</span><span class="o">.</span><span 
class="na">getParameter</span><span class="o">(</span><span 
class="s">&quot;change_layout&quot;</span><span class="o">)</span> <span 
class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span 
class="k">return</span> <span 
class="s">&quot;MyOtherLayout.vm&quot;</span><span class="o">;</span>
+    <span class="k">else</span> <span class="k">return</span> <span 
class="kd">super</span><span class="o">.</span><span 
class="na">findLayout</span><span class="o">(</span><span 
class="n">request</span><span class="o">)</span>
+<span class="o">}</span>
+</pre></div>
+
+
+</li>
+<li>
+<p><strong>Specify the layout in the requested screen.</strong></p>
+</li>
 </ol>
 <p>In the requested screen, put a line like this:</p>
 <div class="codehilite"><pre><span class="cp">#</span><span 
class="nf">set</span><span class="p">(</span> <span class="p">$</span><span 
class="nv">layout</span> <span class="o">=</span> <span 
class="s2">&quot;MyOtherLayout.vm&quot;</span> <span class="p">)</span><span 
class="x"></span>


Reply via email to