added language element to programlisting for syntax highlighting

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@986 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Thomas Risberg 2009-04-13 14:27:47 +00:00
parent 4e4ccbc4c3
commit 0f60b61443
4 changed files with 157 additions and 157 deletions

View File

@ -341,7 +341,7 @@
<para>Consider the following <classname>DispatcherServlet</classname> <para>Consider the following <classname>DispatcherServlet</classname>
servlet configuration (in the <literal>'web.xml'</literal> file.)</para> servlet configuration (in the <literal>'web.xml'</literal> file.)</para>
<programlisting>&lt;web-app&gt; <programlisting language="xml">&lt;web-app&gt;
&lt;servlet&gt; &lt;servlet&gt;
&lt;servlet-name&gt;<emphasis role="bold">golfing</emphasis>&lt;/servlet-name&gt; &lt;servlet-name&gt;<emphasis role="bold">golfing</emphasis>&lt;/servlet-name&gt;
@ -613,7 +613,7 @@
<interfacename>org.springframework.web.servlet.mvc.Controller</interfacename> <interfacename>org.springframework.web.servlet.mvc.Controller</interfacename>
interface, the source code for which is listed below.</para> interface, the source code for which is listed below.</para>
<programlisting>public interface Controller { <programlisting language="java">public interface Controller {
/** /**
* Process the request and return a ModelAndView object which the DispatcherServlet * Process the request and return a ModelAndView object which the DispatcherServlet
@ -731,7 +731,7 @@
consisting of a class and a declaration in the web application consisting of a class and a declaration in the web application
context.</para> context.</para>
<programlisting>package samples; <programlisting language="java">package samples;
public class SampleController extends AbstractController { public class SampleController extends AbstractController {
@ -745,7 +745,7 @@ public class SampleController extends AbstractController {
} }
}</programlisting> }</programlisting>
<programlisting>&lt;bean id="sampleController" class="samples.SampleController"&gt; <programlisting language="xml">&lt;bean id="sampleController" class="samples.SampleController"&gt;
&lt;property name="cacheSeconds" value="120"/&gt; &lt;property name="cacheSeconds" value="120"/&gt;
&lt;/bean&gt;</programlisting> &lt;/bean&gt;</programlisting>
@ -843,18 +843,18 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<para>The standard signature (mirrors the <para>The standard signature (mirrors the
<interfacename>Controller</interfacename> interface method).</para> <interfacename>Controller</interfacename> interface method).</para>
<programlisting>public ModelAndView displayCatalog(HttpServletRequest, HttpServletResponse)</programlisting> <programlisting language="java">public ModelAndView displayCatalog(HttpServletRequest, HttpServletResponse)</programlisting>
<para>This signature accepts a <classname>Login</classname> argument <para>This signature accepts a <classname>Login</classname> argument
that will be populated (bound) with parameters retrieved from the that will be populated (bound) with parameters retrieved from the
request.</para> request.</para>
<programlisting>public ModelAndView login(HttpServletRequest, HttpServletResponse, Login)</programlisting> <programlisting language="java">public ModelAndView login(HttpServletRequest, HttpServletResponse, Login)</programlisting>
<para>This signature requires that the request already have a valid <para>This signature requires that the request already have a valid
session.</para> session.</para>
<programlisting>public ModelAndView viewCart(HttpServletRequest, HttpServletResponse, HttpSession)</programlisting> <programlisting language="java">public ModelAndView viewCart(HttpServletRequest, HttpServletResponse, HttpSession)</programlisting>
<para>This signature accepts a <classname>Product</classname> argument <para>This signature accepts a <classname>Product</classname> argument
that will be populated (bound) with parameters retrieved from the that will be populated (bound) with parameters retrieved from the
@ -864,13 +864,13 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
always be the final argument (fourth when a session is specified, or always be the final argument (fourth when a session is specified, or
third otherwise).</para> third otherwise).</para>
<programlisting>public ModelAndView updateCart(HttpServletRequest, HttpServletResponse, HttpSession, Product)</programlisting> <programlisting language="java">public ModelAndView updateCart(HttpServletRequest, HttpServletResponse, HttpSession, Product)</programlisting>
<para>This signature has a <literal>void</literal> return type <para>This signature has a <literal>void</literal> return type
indicating that the handler method assumes the responsibility of writing indicating that the handler method assumes the responsibility of writing
the response.</para> the response.</para>
<programlisting>public void home(HttpServletRequest, HttpServletResponse)</programlisting> <programlisting language="java">public void home(HttpServletRequest, HttpServletResponse)</programlisting>
<para>This signature has a <interfacename>Map</interfacename> return <para>This signature has a <interfacename>Map</interfacename> return
type indicating that a view name translator will be responsible for type indicating that a view name translator will be responsible for
@ -878,7 +878,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
consist of the <interfacename>Map's</interfacename> entries (see the consist of the <interfacename>Map's</interfacename> entries (see the
section entitled <xref linkend="mvc-coc" /> below).</para> section entitled <xref linkend="mvc-coc" /> below).</para>
<programlisting>public Map list(HttpServletRequest, HttpServletResponse)</programlisting> <programlisting language="java">public Map list(HttpServletRequest, HttpServletResponse)</programlisting>
<para>The <interfacename>MethodNameResolver</interfacename> is <para>The <interfacename>MethodNameResolver</interfacename> is
responsible for resolving method names based on the specifics of the responsible for resolving method names based on the specifics of the
@ -944,13 +944,13 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<classname>Exception</classname>. Here is an example signature for one <classname>Exception</classname>. Here is an example signature for one
such <classname>Exception</classname> handling method.</para> such <classname>Exception</classname> handling method.</para>
<programlisting>public ModelAndView processException(HttpServletRequest, HttpServletResponse, IllegalArgumentException)</programlisting> <programlisting language="java">public ModelAndView processException(HttpServletRequest, HttpServletResponse, IllegalArgumentException)</programlisting>
<para>Let's look at an example showing the delegate-style of <para>Let's look at an example showing the delegate-style of
<classname>MultiActionController</classname> usage in conjunction with <classname>MultiActionController</classname> usage in conjunction with
the <classname>ParameterMethodNameResolver</classname>.</para> the <classname>ParameterMethodNameResolver</classname>.</para>
<programlisting>&lt;bean id="paramMultiController" <programlisting language="xml">&lt;bean id="paramMultiController"
class="org.springframework.web.servlet.mvc.multiaction.MultiActionController"&gt; class="org.springframework.web.servlet.mvc.multiaction.MultiActionController"&gt;
&lt;property name="methodNameResolver"&gt; &lt;property name="methodNameResolver"&gt;
@ -966,7 +966,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
&lt;/bean&gt; &lt;/bean&gt;
}</programlisting> }</programlisting>
<programlisting>public class SampleDelegate { <programlisting language="java">public class SampleDelegate {
public ModelAndView retrieveIndex(HttpServletRequest req, HttpServletResponse resp) { public ModelAndView retrieveIndex(HttpServletRequest req, HttpServletResponse resp) {
return new ModelAndView("index", "date", new Long(System.currentTimeMillis())); return new ModelAndView("index", "date", new Long(System.currentTimeMillis()));
@ -977,7 +977,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<classname>PropertiesMethodNameResolver</classname> to match any number <classname>PropertiesMethodNameResolver</classname> to match any number
couple of URLs to the method we defined:</para> couple of URLs to the method we defined:</para>
<programlisting>&lt;bean id="propsResolver" <programlisting language="xml">&lt;bean id="propsResolver"
class="org....mvc.multiaction.PropertiesMethodNameResolver"&gt; class="org....mvc.multiaction.PropertiesMethodNameResolver"&gt;
&lt;property name="mappings"&gt; &lt;property name="mappings"&gt;
&lt;value&gt; &lt;value&gt;
@ -1204,7 +1204,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
appropriate form <interfacename>Controller</interfacename> as appropriate form <interfacename>Controller</interfacename> as
follows:</para> follows:</para>
<programlisting>&lt;beans&gt; <programlisting language="xml">&lt;beans&gt;
&lt;bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/&gt; &lt;bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/&gt;
&lt;bean name="/editaccount.form" class="org.springframework.web.servlet.mvc.SimpleFormController"&gt; &lt;bean name="/editaccount.form" class="org.springframework.web.servlet.mvc.SimpleFormController"&gt;
@ -1222,7 +1222,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<literal>web.xml</literal> as well, to let through all the requests <literal>web.xml</literal> as well, to let through all the requests
ending with <literal>.form</literal>.</para> ending with <literal>.form</literal>.</para>
<programlisting>&lt;web-app&gt; <programlisting language="xml">&lt;web-app&gt;
... ...
&lt;servlet&gt; &lt;servlet&gt;
&lt;servlet-name&gt;sample&lt;/servlet-name&gt; &lt;servlet-name&gt;sample&lt;/servlet-name&gt;
@ -1258,7 +1258,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<classname>org.springframework.util.PathMatcher</classname> class). Here <classname>org.springframework.util.PathMatcher</classname> class). Here
is an example:</para> is an example:</para>
<programlisting>&lt;web-app&gt; <programlisting language="xml">&lt;web-app&gt;
... ...
&lt;servlet&gt; &lt;servlet&gt;
&lt;servlet-name&gt;sample&lt;/servlet-name&gt; &lt;servlet-name&gt;sample&lt;/servlet-name&gt;
@ -1284,7 +1284,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
all requests ending with .html and <literal>.form</literal> to be all requests ending with .html and <literal>.form</literal> to be
handled by the sample dispatcher servlet.</para> handled by the sample dispatcher servlet.</para>
<programlisting>&lt;beans&gt; <programlisting language="xml">&lt;beans&gt;
<lineannotation>&lt;!-- no <literal>'id'</literal> required, <interfacename>HandlerMapping</interfacename> beans are automatically detected by the <classname>DispatcherServlet</classname> --&gt;</lineannotation> <lineannotation>&lt;!-- no <literal>'id'</literal> required, <interfacename>HandlerMapping</interfacename> beans are automatically detected by the <classname>DispatcherServlet</classname> --&gt;</lineannotation>
&lt;bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt; &lt;bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
@ -1354,7 +1354,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
requests and reroutes the user to a specific page if the time is not requests and reroutes the user to a specific page if the time is not
between 9 a.m. and 6 p.m.</para> between 9 a.m. and 6 p.m.</para>
<programlisting>&lt;beans&gt; <programlisting language="xml">&lt;beans&gt;
&lt;bean id="handlerMapping" &lt;bean id="handlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt; class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
&lt;property name="interceptors"&gt; &lt;property name="interceptors"&gt;
@ -1377,7 +1377,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
&lt;/bean&gt; &lt;/bean&gt;
&lt;beans&gt;</programlisting> &lt;beans&gt;</programlisting>
<programlisting>package samples; <programlisting language="java">package samples;
public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
@ -1542,7 +1542,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
translates a view name to a URL and hands the request over to the translates a view name to a URL and hands the request over to the
RequestDispatcher to render the view.</para> RequestDispatcher to render the view.</para>
<programlisting>&lt;bean id="viewResolver" <programlisting language="xml">&lt;bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt; class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
&lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt;
&lt;property name="prefix" value="/WEB-INF/jsp/"/&gt; &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
@ -1557,7 +1557,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
<para>When mixing different view technologies in a web application, you <para>When mixing different view technologies in a web application, you
can use the <classname>ResourceBundleViewResolver</classname>:</para> can use the <classname>ResourceBundleViewResolver</classname>:</para>
<programlisting>&lt;bean id="viewResolver" <programlisting language="xml">&lt;bean id="viewResolver"
class="org.springframework.web.servlet.view.ResourceBundleViewResolver"&gt; class="org.springframework.web.servlet.view.ResourceBundleViewResolver"&gt;
&lt;property name="basename" value="views"/&gt; &lt;property name="basename" value="views"/&gt;
&lt;property name="defaultParentView" value="parentView"/&gt; &lt;property name="defaultParentView" value="parentView"/&gt;
@ -1601,7 +1601,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
Excel views (which are not supported by the Excel views (which are not supported by the
<classname>InternalResourceViewResolver</classname>):</para> <classname>InternalResourceViewResolver</classname>):</para>
<programlisting>&lt;bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; <programlisting language="xml">&lt;bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
&lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt;
&lt;property name="prefix" value="/WEB-INF/jsp/"/&gt; &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
&lt;property name="suffix" value=".jsp"/&gt; &lt;property name="suffix" value=".jsp"/&gt;
@ -1801,7 +1801,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
below an example of defining a below an example of defining a
<classname>CookieLocaleResolver</classname>.</para> <classname>CookieLocaleResolver</classname>.</para>
<programlisting>&lt;bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt; <programlisting language="xml">&lt;bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt;
&lt;property name="cookieName" value="clientlanguage"/&gt; &lt;property name="cookieName" value="clientlanguage"/&gt;
@ -1884,7 +1884,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
on the <interfacename>LocaleResolver</interfacename> that also exists in on the <interfacename>LocaleResolver</interfacename> that also exists in
the context).</para> the context).</para>
<programlisting>&lt;bean id="localeChangeInterceptor" <programlisting language="xml">&lt;bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt; class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
&lt;property name="paramName" value="siteLanguage"/&gt; &lt;property name="paramName" value="siteLanguage"/&gt;
&lt;/bean&gt; &lt;/bean&gt;
@ -1959,7 +1959,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
fragment uses the theme defined above to customize the look and fragment uses the theme defined above to customize the look and
feel:</para> feel:</para>
<programlisting>&lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%&gt; <programlisting language="xml">&lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%&gt;
&lt;html&gt; &lt;html&gt;
&lt;head&gt; &lt;head&gt;
&lt;link rel="stylesheet" href="&lt;spring:theme code="styleSheet"/&gt;" type="text/css"/&gt; &lt;link rel="stylesheet" href="&lt;spring:theme code="styleSheet"/&gt;" type="text/css"/&gt;
@ -2079,7 +2079,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
<para>The following example shows how to use the <para>The following example shows how to use the
<classname>CommonsMultipartResolver</classname>:</para> <classname>CommonsMultipartResolver</classname>:</para>
<programlisting>&lt;bean id="multipartResolver" <programlisting language="xml">&lt;bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt; class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
<lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation> <lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation>
@ -2089,7 +2089,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
<para>This is an example using the <para>This is an example using the
<classname>CosMultipartResolver</classname>:</para> <classname>CosMultipartResolver</classname>:</para>
<programlisting>&lt;bean id="multipartResolver" class="org.springframework.web.multipart.cos.CosMultipartResolver"&gt; <programlisting language="xml">&lt;bean id="multipartResolver" class="org.springframework.web.multipart.cos.CosMultipartResolver"&gt;
<lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation> <lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation>
&lt;property name="maxUploadSize" value="100000"/&gt; &lt;property name="maxUploadSize" value="100000"/&gt;
@ -2124,7 +2124,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
Spring bind the file onto your form (backing object). To actually let Spring bind the file onto your form (backing object). To actually let
the user upload a file, we have to create a (HTML) form:</para> the user upload a file, we have to create a (HTML) form:</para>
<programlisting>&lt;html&gt; <programlisting language="xml">&lt;html&gt;
&lt;head&gt; &lt;head&gt;
&lt;title&gt;Upload a file please&lt;/title&gt; &lt;title&gt;Upload a file please&lt;/title&gt;
&lt;/head&gt; &lt;/head&gt;
@ -2159,7 +2159,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
resolver, a url mapping to a controller that will process the bean, and resolver, a url mapping to a controller that will process the bean, and
the controller itself.</para> the controller itself.</para>
<programlisting>&lt;beans&gt; <programlisting language="xml">&lt;beans&gt;
<lineannotation>&lt;!-- lets use the Commons-based implementation of the MultipartResolver interface --&gt;</lineannotation> <lineannotation>&lt;!-- lets use the Commons-based implementation of the MultipartResolver interface --&gt;</lineannotation>
&lt;bean id="multipartResolver" &lt;bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/&gt; class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/&gt;
@ -2183,7 +2183,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
<para>After that, create the controller and the actual class to hold the <para>After that, create the controller and the actual class to hold the
file property.</para> file property.</para>
<programlisting>public class FileUploadController extends SimpleFormController { <programlisting language="java">public class FileUploadController extends SimpleFormController {
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors) throws ServletException, IOException { Object command, BindException errors) throws ServletException, IOException {
@ -2235,7 +2235,7 @@ public class FileUploadBean {
<para>An equivalent example in which a file is bound straight to a <para>An equivalent example in which a file is bound straight to a
String-typed property on a (form backing) object might look like:</para> String-typed property on a (form backing) object might look like:</para>
<programlisting>public class FileUploadController extends SimpleFormController { <programlisting language="java">public class FileUploadController extends SimpleFormController {
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors) throws ServletException, IOException { Object command, BindException errors) throws ServletException, IOException {
@ -2286,7 +2286,7 @@ public class FileUploadBean {
register any custom <interfacename>PropertyEditor</interfacename> register any custom <interfacename>PropertyEditor</interfacename>
because there is no type conversion to be performed.</para> because there is no type conversion to be performed.</para>
<programlisting>public class FileUploadController extends SimpleFormController { <programlisting language="java">public class FileUploadController extends SimpleFormController {
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors) throws ServletException, IOException { Object command, BindException errors) throws ServletException, IOException {
@ -2379,7 +2379,7 @@ public class FileUploadBean {
<interfacename>Controller</interfacename> implementation. Take especial <interfacename>Controller</interfacename> implementation. Take especial
notice of the <emphasis>name</emphasis> of the class.</para> notice of the <emphasis>name</emphasis> of the class.</para>
<programlisting>public class <emphasis role="bold">ViewShoppingCartController</emphasis> implements Controller { <programlisting language="java">public class <emphasis role="bold">ViewShoppingCartController</emphasis> implements Controller {
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
<lineannotation>// the implementation is not hugely important for this example...</lineannotation> <lineannotation>// the implementation is not hugely important for this example...</lineannotation>
@ -2389,7 +2389,7 @@ public class FileUploadBean {
<para>Here is a snippet from the attendent Spring Web MVC configuration <para>Here is a snippet from the attendent Spring Web MVC configuration
file...</para> file...</para>
<programlisting>&lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/&gt; <programlisting language="xml">&lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/&gt;
&lt;bean id="<emphasis role="bold">viewShoppingCart</emphasis>" class="x.y.z.ViewShoppingCartController"&gt; &lt;bean id="<emphasis role="bold">viewShoppingCart</emphasis>" class="x.y.z.ViewShoppingCartController"&gt;
<lineannotation>&lt;!-- inject dependencies as required... --&gt;</lineannotation> <lineannotation>&lt;!-- inject dependencies as required... --&gt;</lineannotation>
@ -2484,7 +2484,7 @@ public class FileUploadBean {
objects are added to the <classname>ModelAndView</classname> without any objects are added to the <classname>ModelAndView</classname> without any
associated name being specified.</para> associated name being specified.</para>
<programlisting>public class DisplayShoppingCartController implements Controller { <programlisting language="java">public class DisplayShoppingCartController implements Controller {
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
@ -2612,7 +2612,7 @@ public class FileUploadBean {
request URLs to logical view names in a fashion that is probably best request URLs to logical view names in a fashion that is probably best
explained by recourse to an example.</para> explained by recourse to an example.</para>
<programlisting>public class RegistrationController implements Controller { <programlisting language="java">public class RegistrationController implements Controller {
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
<lineannotation>// process the request...</lineannotation> <lineannotation>// process the request...</lineannotation>
@ -2623,7 +2623,7 @@ public class FileUploadBean {
} }
}</programlisting> }</programlisting>
<programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" &lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd"&gt; "http://www.springframework.org/dtd/spring-beans-2.0.dtd"&gt;
&lt;beans&gt; &lt;beans&gt;
@ -2734,7 +2734,7 @@ public class FileUploadBean {
and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well
- provided that you intend to use <interfacename>@RequestMapping</interfacename>.</para> - provided that you intend to use <interfacename>@RequestMapping</interfacename>.</para>
<programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans" &lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans xsi:schemaLocation="http://www.springframework.org/schema/beans
@ -2784,7 +2784,7 @@ public class FileUploadBean {
the <emphasis>spring-context</emphasis> schema as shown in the following the <emphasis>spring-context</emphasis> schema as shown in the following
XML snippet:</para> XML snippet:</para>
<programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans" &lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:p="http://www.springframework.org/schema/p"
@ -2832,7 +2832,7 @@ public class FileUploadBean {
<para>The following is an example of a form controller from the <para>The following is an example of a form controller from the
PetClinic sample application using this annotation:</para> PetClinic sample application using this annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
<emphasis role="bold">@RequestMapping("/editPet.do")</emphasis> <emphasis role="bold">@RequestMapping("/editPet.do")</emphasis>
@SessionAttributes("pet") @SessionAttributes("pet")
public class EditPetForm { public class EditPetForm {
@ -2878,7 +2878,7 @@ public class EditPetForm {
PetClinic sample application using PetClinic sample application using
<classname>@RequestMapping</classname>:</para> <classname>@RequestMapping</classname>:</para>
<programlisting>@Controller <programlisting language="java">@Controller
public class ClinicController { public class ClinicController {
private final Clinic clinic; private final Clinic clinic;
@ -3125,7 +3125,7 @@ public class ClinicController {
<para>The following code snippet from the PetClinic sample application <para>The following code snippet from the PetClinic sample application
shows the usage:</para> shows the usage:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("/editPet.do") @RequestMapping("/editPet.do")
@SessionAttributes("pet") @SessionAttributes("pet")
public class EditPetForm { public class EditPetForm {
@ -3182,7 +3182,7 @@ public class EditPetForm {
<para>The following code snippet shows these two usages of this <para>The following code snippet shows these two usages of this
annotation:</para> annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("/editPet.do") @RequestMapping("/editPet.do")
@SessionAttributes("pet") @SessionAttributes("pet")
public class EditPetForm { public class EditPetForm {
@ -3224,7 +3224,7 @@ public class EditPetForm {
<para>The following code snippet shows the usage of this <para>The following code snippet shows the usage of this
annotation:</para> annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("/editPet.do") @RequestMapping("/editPet.do")
<emphasis role="bold">@SessionAttributes("pet")</emphasis> <emphasis role="bold">@SessionAttributes("pet")</emphasis>
public class EditPetForm { public class EditPetForm {
@ -3241,7 +3241,7 @@ public class EditPetForm {
<para>Let us consider that the following cookie has been received with an http request: </para> <para>Let us consider that the following cookie has been received with an http request: </para>
<programlisting>JSESSIONID=415A4AC178C59DACE0B2C9CA727CDD84</programlisting> <programlisting>JSESSIONID=415A4AC178C59DACE0B2C9CA727CDD84</programlisting>
<para>The following code sample allows you to easily get the value of the "JSESSIONID"cookie:</para> <para>The following code sample allows you to easily get the value of the "JSESSIONID"cookie:</para>
<programlisting>@RequestMapping("/displayHeaderInfo.do") <programlisting language="java">@RequestMapping("/displayHeaderInfo.do")
public void displayHeaderInfo(<emphasis role="bold">@CookieValue("JSESSIONID")</emphasis> String cookie) { public void displayHeaderInfo(<emphasis role="bold">@CookieValue("JSESSIONID")</emphasis> String cookie) {
//... //...
@ -3266,7 +3266,7 @@ Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300 Keep-Alive 300
]]></programlisting> ]]></programlisting>
<para>The following code sample allows you to easily get the value of the "Accept-Encoding" and "Keep-Alive" headers:</para> <para>The following code sample allows you to easily get the value of the "Accept-Encoding" and "Keep-Alive" headers:</para>
<programlisting>@RequestMapping("/displayHeaderInfo.do") <programlisting language="java">@RequestMapping("/displayHeaderInfo.do")
public void displayHeaderInfo(<emphasis role="bold">@RequestHeader("Accept-Encoding")</emphasis> String encoding, public void displayHeaderInfo(<emphasis role="bold">@RequestHeader("Accept-Encoding")</emphasis> String encoding,
<emphasis role="bold">@RequestHeader("Keep-Alive")</emphasis> long keepAlive) { <emphasis role="bold">@RequestHeader("Keep-Alive")</emphasis> long keepAlive) {
@ -3314,7 +3314,7 @@ Keep-Alive 300
<classname>CustomDateEditor</classname> for all <classname>CustomDateEditor</classname> for all
<classname>java.util.Date</classname> form properties.</para> <classname>java.util.Date</classname> form properties.</para>
<programlisting>@Controller <programlisting language="java">@Controller
public class MyFormController { public class MyFormController {
<emphasis role="bold">@InitBinder</emphasis> <emphasis role="bold">@InitBinder</emphasis>
@ -3346,7 +3346,7 @@ public class MyFormController {
which configures PropertyEditors required by several of the PetClinic which configures PropertyEditors required by several of the PetClinic
controllers.</para> controllers.</para>
<programlisting>&lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt; <programlisting language="xml">&lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
&lt;property name="cacheSeconds" value="0" /&gt; &lt;property name="cacheSeconds" value="0" /&gt;
&lt;property name="webBindingInitializer"&gt; &lt;property name="webBindingInitializer"&gt;
&lt;bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer" /&gt; &lt;bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer" /&gt;

View File

@ -140,7 +140,7 @@
<classname>DispatcherPortlet</classname> is declared in the <classname>DispatcherPortlet</classname> is declared in the
<literal>portlet.xml</literal> of your web application:</para> <literal>portlet.xml</literal> of your web application:</para>
<programlisting><![CDATA[<portlet> <programlisting language="xml"><![CDATA[<portlet>
<portlet-name>sample</portlet-name> <portlet-name>sample</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class> <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<supports> <supports>
@ -353,7 +353,7 @@
<literal>web.xml</literal> file for your web application as <literal>web.xml</literal> file for your web application as
follows:</para> follows:</para>
<programlisting><![CDATA[<servlet> <programlisting language="xml"><![CDATA[<servlet>
<servlet-name>ViewRendererServlet</servlet-name> <servlet-name>ViewRendererServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class> <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
</servlet> </servlet>
@ -407,7 +407,7 @@
<interfacename>org.springframework.web.portlet.mvc.Controller</interfacename> <interfacename>org.springframework.web.portlet.mvc.Controller</interfacename>
interface, which is listed below.</para> interface, which is listed below.</para>
<programlisting><![CDATA[public interface Controller { <programlisting language="java"><![CDATA[public interface Controller {
/** /**
* Process the render request and return a ModelAndView object which the * Process the render request and return a ModelAndView object which the
@ -530,7 +530,7 @@
<para>Here is short example consisting of a class and a declaration <para>Here is short example consisting of a class and a declaration
in the web application context.</para> in the web application context.</para>
<programlisting><![CDATA[package samples; <programlisting language="java"><![CDATA[package samples;
import javax.portlet.RenderRequest; import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse; import javax.portlet.RenderResponse;
@ -647,7 +647,7 @@ public class SampleController extends AbstractController {
instantiate an existing <interfacename>Portlet</interfacename> as a instantiate an existing <interfacename>Portlet</interfacename> as a
<interfacename>Controller</interfacename> as follows:</para> <interfacename>Controller</interfacename> as follows:</para>
<programlisting><![CDATA[<bean id="myPortlet" class="org.springframework.web.portlet.mvc.PortletWrappingController"> <programlisting language="xml"><![CDATA[<bean id="myPortlet" class="org.springframework.web.portlet.mvc.PortletWrappingController">
<property name="portletClass" value="sample.MyPortlet"/> <property name="portletClass" value="sample.MyPortlet"/>
<property name="portletName" value="my-portlet"/> <property name="portletName" value="my-portlet"/>
<property name="initParameters"> <property name="initParameters">
@ -745,7 +745,7 @@ public class SampleController extends AbstractController {
based on the current mode of the portlet (e.g. view, edit, based on the current mode of the portlet (e.g. view, edit,
help). An example:</para> help). An example:</para>
<programlisting><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <programlisting language="xml"><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="portletModeMap"> <property name="portletModeMap">
<map> <map>
<entry key="view" value-ref="viewHandler"/> <entry key="view" value-ref="viewHandler"/>
@ -771,7 +771,7 @@ public class SampleController extends AbstractController {
<para>The bean configuration for this mapping will look something <para>The bean configuration for this mapping will look something
like this:</para> like this:</para>
<programlisting><![CDATA[<bean class="org.springframework.web.portlet.handler.ParameterHandlerMapping”> <programlisting language="xml"><![CDATA[<bean class="org.springframework.web.portlet.handler.ParameterHandlerMapping”>
<property name="parameterMap"> <property name="parameterMap">
<map> <map>
<entry key="add" value-ref="addItemHandler"/> <entry key="add" value-ref="addItemHandler"/>
@ -804,7 +804,7 @@ public class SampleController extends AbstractController {
<para>The bean configuration for this mapping will look something <para>The bean configuration for this mapping will look something
like this:</para> like this:</para>
<programlisting><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> <programlisting language="xml"><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping">
<property name="portletModeParameterMap"> <property name="portletModeParameterMap">
<map> <map>
<entry key="view"> ]]><lineannotation>&lt;!-- 'view' portlet mode --&gt;</lineannotation><![CDATA[ <entry key="view"> ]]><lineannotation>&lt;!-- 'view' portlet mode --&gt;</lineannotation><![CDATA[
@ -992,7 +992,7 @@ public class SampleController extends AbstractController {
<para>The following example shows how to use the <para>The following example shows how to use the
<classname>CommonsPortletMultipartResolver</classname>:</para> <classname>CommonsPortletMultipartResolver</classname>:</para>
<programlisting><![CDATA[<bean id="portletMultipartResolver" <programlisting language="xml"><![CDATA[<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"> class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver">
]]><lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation><![CDATA[ ]]><lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation><![CDATA[
@ -1035,7 +1035,7 @@ public class SampleController extends AbstractController {
actually let the user upload a file, we have to create a (JSP/HTML) actually let the user upload a file, we have to create a (JSP/HTML)
form:</para> form:</para>
<programlisting><![CDATA[<h1>Please upload a file</h1> <programlisting language="xml"><![CDATA[<h1>Please upload a file</h1>
<form method="post" action="<portlet:actionURL/>" enctype="multipart/form-data"> <form method="post" action="<portlet:actionURL/>" enctype="multipart/form-data">
<input type="file" name="file"/> <input type="file" name="file"/>
<input type="submit"/> <input type="submit"/>
@ -1064,7 +1064,7 @@ public class SampleController extends AbstractController {
resolver, a mapping to a controller that will process the bean, and resolver, a mapping to a controller that will process the bean, and
the controller itself.</para> the controller itself.</para>
<programlisting><![CDATA[<bean id="portletMultipartResolver" <programlisting language="xml"><![CDATA[<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"/> class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"/>
<bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
@ -1084,7 +1084,7 @@ public class SampleController extends AbstractController {
<para>After that, create the controller and the actual class to hold <para>After that, create the controller and the actual class to hold
the file property.</para> the file property.</para>
<programlisting><![CDATA[public class FileUploadController extends SimpleFormController { <programlisting language="java"><![CDATA[public class FileUploadController extends SimpleFormController {
public void onSubmitAction(ActionRequest request, ActionResponse response, public void onSubmitAction(ActionRequest request, ActionResponse response,
Object command, BindException errors) throws Exception { Object command, BindException errors) throws Exception {
@ -1136,7 +1136,7 @@ public class FileUploadBean {
String-typed property on a (form backing) object might look like String-typed property on a (form backing) object might look like
this:</para> this:</para>
<programlisting><![CDATA[public class FileUploadController extends SimpleFormController { <programlisting language="java"><![CDATA[public class FileUploadController extends SimpleFormController {
public void onSubmitAction(ActionRequest request, ActionResponse response, public void onSubmitAction(ActionRequest request, ActionResponse response,
Object command, BindException errors) throws Exception { Object command, BindException errors) throws Exception {
@ -1187,7 +1187,7 @@ public class FileUploadBean {
register any custom property editor because there is no type register any custom property editor because there is no type
conversion to be performed.</para> conversion to be performed.</para>
<programlisting><![CDATA[public class FileUploadController extends SimpleFormController { <programlisting language="java"><![CDATA[public class FileUploadController extends SimpleFormController {
public void onSubmitAction(ActionRequest request, ActionResponse response, public void onSubmitAction(ActionRequest request, ActionResponse response,
Object command, BindException errors) throws Exception { Object command, BindException errors) throws Exception {
@ -1273,7 +1273,7 @@ public class FileUploadBean {
and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well
- provided that you intend to use <interfacename>@RequestMapping</interfacename>.</para> - provided that you intend to use <interfacename>@RequestMapping</interfacename>.</para>
<programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans" &lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans xsi:schemaLocation="http://www.springframework.org/schema/beans
@ -1322,7 +1322,7 @@ public class FileUploadBean {
the <emphasis>spring-context</emphasis> schema as shown in the following the <emphasis>spring-context</emphasis> schema as shown in the following
XML snippet:</para> XML snippet:</para>
<programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans" &lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:p="http://www.springframework.org/schema/p"
@ -1371,7 +1371,7 @@ public class FileUploadBean {
<para>The following is an example of a form controller from the <para>The following is an example of a form controller from the
PetPortal sample application using this annotation:</para> PetPortal sample application using this annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
<emphasis role="bold">@RequestMapping("EDIT")</emphasis> <emphasis role="bold">@RequestMapping("EDIT")</emphasis>
@SessionAttributes("site") @SessionAttributes("site")
public class PetSitesEditController { public class PetSitesEditController {
@ -1580,7 +1580,7 @@ public class PetSitesEditController {
<para>The following code snippet from the PetPortal sample application <para>The following code snippet from the PetPortal sample application
shows the usage:</para> shows the usage:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("EDIT") @RequestMapping("EDIT")
@SessionAttributes("site") @SessionAttributes("site")
public class PetSitesEditController { public class PetSitesEditController {
@ -1636,7 +1636,7 @@ public class PetSitesEditController {
<para>The following code snippet shows these two usages of this <para>The following code snippet shows these two usages of this
annotation:</para> annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("EDIT") @RequestMapping("EDIT")
@SessionAttributes("site") @SessionAttributes("site")
public class PetSitesEditController { public class PetSitesEditController {
@ -1676,7 +1676,7 @@ public class PetSitesEditController {
<para>The following code snippet shows the usage of this <para>The following code snippet shows the usage of this
annotation:</para> annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("EDIT") @RequestMapping("EDIT")
<emphasis role="bold">@SessionAttributes("site")</emphasis> <emphasis role="bold">@SessionAttributes("site")</emphasis>
public class PetSitesEditController { public class PetSitesEditController {
@ -1722,7 +1722,7 @@ public class PetSitesEditController {
<classname>CustomDateEditor</classname> for all <classname>CustomDateEditor</classname> for all
<classname>java.util.Date</classname> form properties.</para> <classname>java.util.Date</classname> form properties.</para>
<programlisting>@Controller <programlisting language="java">@Controller
public class MyFormController { public class MyFormController {
<emphasis role="bold">@InitBinder</emphasis> <emphasis role="bold">@InitBinder</emphasis>

View File

@ -33,7 +33,7 @@
<classname>ResourceBundleViewResolver</classname>. Both are declared in the <classname>ResourceBundleViewResolver</classname>. Both are declared in the
<interfacename>WebApplicationContext</interfacename>:</para> <interfacename>WebApplicationContext</interfacename>:</para>
<programlisting><lineannotation>&lt;!-- the <classname>ResourceBundleViewResolver</classname> --&gt;</lineannotation><![CDATA[ <programlisting language="xml"><lineannotation>&lt;!-- the <classname>ResourceBundleViewResolver</classname> --&gt;</lineannotation><![CDATA[
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views"/> <property name="basename" value="views"/>
</bean> </bean>
@ -50,7 +50,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<classname>ResourceBundleViewResolver</classname> you can mix different types of views using <classname>ResourceBundleViewResolver</classname> you can mix different types of views using
only one resolver.</para> only one resolver.</para>
<programlisting><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <programlisting language="xml"><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/> <property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/> <property name="suffix" value=".jsp"/>
@ -115,7 +115,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>To use the tags from this library, add the following directive to <para>To use the tags from this library, add the following directive to
the top of your JSP page:</para> the top of your JSP page:</para>
<programlisting>&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;</programlisting> <programlisting language="xml">&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;</programlisting>
<para>... where <literal>form</literal> is the tag name prefix you want <para>... where <literal>form</literal> is the tag name prefix you want
to use for the tags from this library.</para> to use for the tags from this library.</para>
@ -137,7 +137,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<literal>form.jsp</literal>. Below is an example of what <literal>form.jsp</literal>. Below is an example of what
<literal>form.jsp</literal> would look like:</para> <literal>form.jsp</literal> would look like:</para>
<programlisting>&lt;form:form&gt; <programlisting language="xml">&lt;form:form&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt; &lt;td&gt;First Name:&lt;/td&gt;
@ -163,7 +163,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>The generated HTML looks like a standard form:</para> <para>The generated HTML looks like a standard form:</para>
<programlisting>&lt;form method="POST"&gt; <programlisting language="xml">&lt;form method="POST"&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt; &lt;td&gt;First Name:&lt;/td&gt;
@ -187,7 +187,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
practice), then you can bind the form to the named variable like practice), then you can bind the form to the named variable like
so:</para> so:</para>
<programlisting>&lt;form:form <lineannotation><emphasis role="bold">commandName="user"</emphasis></lineannotation>&gt; <programlisting language="xml">&lt;form:form <lineannotation><emphasis role="bold">commandName="user"</emphasis></lineannotation>&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt; &lt;td&gt;First Name:&lt;/td&gt;
@ -224,7 +224,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
the <classname>Preferences</classname> class:</para> the <classname>Preferences</classname> class:</para>
</section> </section>
<programlisting>public class Preferences { <programlisting language="java">public class Preferences {
private boolean receiveNewsletter; private boolean receiveNewsletter;
@ -259,7 +259,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>The <literal>form.jsp</literal> would look like:</para> <para>The <literal>form.jsp</literal> would look like:</para>
<programlisting>&lt;form:form&gt; <programlisting language="xml">&lt;form:form&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td&gt;Subscribe to newsletter?:&lt;/td&gt; &lt;td&gt;Subscribe to newsletter?:&lt;/td&gt;
@ -318,7 +318,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>Note that regardless of the approach, the same HTML structure is <para>Note that regardless of the approach, the same HTML structure is
generated. Below is an HTML snippet of some checkboxes:</para> generated. Below is an HTML snippet of some checkboxes:</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Interests:&lt;/td&gt; &lt;td&gt;Interests:&lt;/td&gt;
&lt;td&gt; &lt;td&gt;
Quidditch: &lt;input name="preferences.interests" type="checkbox" value="Quidditch"/&gt; Quidditch: &lt;input name="preferences.interests" type="checkbox" value="Quidditch"/&gt;
@ -363,7 +363,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
user. Below is an example of the JSP using this tag:</para> user. Below is an example of the JSP using this tag:</para>
</section> </section>
<programlisting>&lt;form:form&gt; <programlisting language="xml">&lt;form:form&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td&gt;Interests:&lt;/td&gt; &lt;td&gt;Interests:&lt;/td&gt;
@ -391,7 +391,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>A typical usage pattern will involve multiple tag instances bound <para>A typical usage pattern will involve multiple tag instances bound
to the same property but with different values.</para> to the same property but with different values.</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Sex:&lt;/td&gt; &lt;td&gt;Sex:&lt;/td&gt;
&lt;td&gt;Male: &lt;form:radiobutton path="sex" value="M"/&gt; &lt;br/&gt; &lt;td&gt;Male: &lt;form:radiobutton path="sex" value="M"/&gt; &lt;br/&gt;
Female: &lt;form:radiobutton path="sex" value="F"/&gt; &lt;/td&gt; Female: &lt;form:radiobutton path="sex" value="F"/&gt; &lt;/td&gt;
@ -415,7 +415,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
custom object where you can provide the property names for the value custom object where you can provide the property names for the value
using "itemValue" and the label using "itemLabel".</para> using "itemValue" and the label using "itemLabel".</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Sex:&lt;/td&gt; &lt;td&gt;Sex:&lt;/td&gt;
&lt;td&gt;&lt;form:radiobuttons path="sex" items="${sexOptions}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;form:radiobuttons path="sex" items="${sexOptions}"/&gt;&lt;/td&gt;
&lt;/tr&gt;</programlisting> &lt;/tr&gt;</programlisting>
@ -427,7 +427,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>This tag renders an HTML 'input' tag with type 'password' using <para>This tag renders an HTML 'input' tag with type 'password' using
the bound value.</para> the bound value.</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Password:&lt;/td&gt; &lt;td&gt;Password:&lt;/td&gt;
&lt;td&gt; &lt;td&gt;
&lt;form:password path="password" /&gt; &lt;form:password path="password" /&gt;
@ -439,7 +439,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
shown, then set the value of the <literal>'showPassword'</literal> shown, then set the value of the <literal>'showPassword'</literal>
attribute to true, like so.</para> attribute to true, like so.</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Password:&lt;/td&gt; &lt;td&gt;Password:&lt;/td&gt;
&lt;td&gt; &lt;td&gt;
&lt;form:password path="password" value="^76525bvHGq" showPassword="true" /&gt; &lt;form:password path="password" value="^76525bvHGq" showPassword="true" /&gt;
@ -457,7 +457,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>Let's assume a <classname>User</classname> has a list of <para>Let's assume a <classname>User</classname> has a list of
skills.</para> skills.</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Skills:&lt;/td&gt; &lt;td&gt;Skills:&lt;/td&gt;
&lt;td&gt;&lt;form:select path="skills" items="${skills}"/&gt;&lt;/td&gt; &lt;td&gt;&lt;form:select path="skills" items="${skills}"/&gt;&lt;/td&gt;
&lt;/tr&gt;</programlisting> &lt;/tr&gt;</programlisting>
@ -465,7 +465,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>If the <literal>User's</literal> skill were in Herbology, the HTML <para>If the <literal>User's</literal> skill were in Herbology, the HTML
source of the 'Skills' row would look like:</para> source of the 'Skills' row would look like:</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Skills:&lt;/td&gt; &lt;td&gt;Skills:&lt;/td&gt;
&lt;td&gt;&lt;select name="skills" multiple="true"&gt; &lt;td&gt;&lt;select name="skills" multiple="true"&gt;
&lt;option value="Potions"&gt;Potions&lt;/option&gt; &lt;option value="Potions"&gt;Potions&lt;/option&gt;
@ -481,7 +481,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>This tag renders an HTML 'option'. It sets 'selected' as <para>This tag renders an HTML 'option'. It sets 'selected' as
appropriate based on the bound value.</para> appropriate based on the bound value.</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;House:&lt;/td&gt; &lt;td&gt;House:&lt;/td&gt;
&lt;td&gt; &lt;td&gt;
&lt;form:select path="house"&gt; &lt;form:select path="house"&gt;
@ -496,7 +496,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>If the <literal>User's</literal> house was in Gryffindor, the HTML <para>If the <literal>User's</literal> house was in Gryffindor, the HTML
source of the 'House' row would look like:</para> source of the 'House' row would look like:</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;House:&lt;/td&gt; &lt;td&gt;House:&lt;/td&gt;
&lt;td&gt; &lt;td&gt;
&lt;select name="house"&gt; &lt;select name="house"&gt;
@ -515,7 +515,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>This tag renders a list of HTML 'option' tags. It sets the <para>This tag renders a list of HTML 'option' tags. It sets the
'selected' attribute as appropriate based on the bound value.</para> 'selected' attribute as appropriate based on the bound value.</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Country:&lt;/td&gt; &lt;td&gt;Country:&lt;/td&gt;
&lt;td&gt; &lt;td&gt;
&lt;form:select path="country"&gt; &lt;form:select path="country"&gt;
@ -528,7 +528,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>If the <classname>User</classname> lived in the UK, the HTML <para>If the <classname>User</classname> lived in the UK, the HTML
source of the 'Country' row would look like:</para> source of the 'Country' row would look like:</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Country:&lt;/td&gt; &lt;td&gt;Country:&lt;/td&gt;
&lt;td&gt; &lt;td&gt;
&lt;select name="country"&gt; &lt;select name="country"&gt;
@ -563,7 +563,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>This tag renders an HTML 'textarea'.</para> <para>This tag renders an HTML 'textarea'.</para>
<programlisting>&lt;tr&gt; <programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Notes:&lt;/td&gt; &lt;td&gt;Notes:&lt;/td&gt;
&lt;td&gt;&lt;form:textarea path="notes" rows="3" cols="20" /&gt;&lt;/td&gt; &lt;td&gt;&lt;form:textarea path="notes" rows="3" cols="20" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;form:errors path="notes" /&gt;&lt;/td&gt; &lt;td&gt;&lt;form:errors path="notes" /&gt;&lt;/td&gt;
@ -577,13 +577,13 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
bound value. To submit an unbound hidden value, use the HTML bound value. To submit an unbound hidden value, use the HTML
<literal>input</literal> tag with type 'hidden'.</para> <literal>input</literal> tag with type 'hidden'.</para>
<programlisting>&lt;form:hidden path="house" /&gt; <programlisting language="xml">&lt;form:hidden path="house" /&gt;
</programlisting> </programlisting>
<para>If we choose to submit the 'house' value as a hidden one, the HTML <para>If we choose to submit the 'house' value as a hidden one, the HTML
would look like:</para> would look like:</para>
<programlisting>&lt;input name="house" type="hidden" value="Gryffindor"/&gt; <programlisting language="xml">&lt;input name="house" type="hidden" value="Gryffindor"/&gt;
</programlisting> </programlisting>
</section> </section>
@ -600,7 +600,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<classname>User</classname> class called <classname>User</classname> class called
<classname>UserValidator</classname>.</para> <classname>UserValidator</classname>.</para>
<programlisting>public class UserValidator implements Validator { <programlisting language="java">public class UserValidator implements Validator {
public boolean supports(Class candidate) { public boolean supports(Class candidate) {
return User.class.isAssignableFrom(candidate); return User.class.isAssignableFrom(candidate);
@ -614,7 +614,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>The <literal>form.jsp</literal> would look like:</para> <para>The <literal>form.jsp</literal> would look like:</para>
<programlisting>&lt;form:form&gt; <programlisting language="xml">&lt;form:form&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt; &lt;td&gt;First Name:&lt;/td&gt;
@ -641,7 +641,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<literal>firstName</literal> and <literal>lastName</literal> fields, <literal>firstName</literal> and <literal>lastName</literal> fields,
this is what the HTML would look like:</para> this is what the HTML would look like:</para>
<programlisting>&lt;form method="POST"&gt; <programlisting language="xml">&lt;form method="POST"&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt; &lt;td&gt;First Name:&lt;/td&gt;
@ -682,7 +682,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>The example below will display a list of errors at the top of the <para>The example below will display a list of errors at the top of the
page, followed by field-specific errors next to the fields:</para> page, followed by field-specific errors next to the fields:</para>
<programlisting>&lt;form:form&gt; <programlisting language="xml">&lt;form:form&gt;
&lt;form:errors path="*" cssClass="errorBox" /&gt; &lt;form:errors path="*" cssClass="errorBox" /&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
@ -705,7 +705,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>The HTML would look like:</para> <para>The HTML would look like:</para>
<programlisting>&lt;form method="POST"&gt; <programlisting language="xml">&lt;form method="POST"&gt;
&lt;span name="*.errors" class="errorBox"&gt;Field is required.&lt;br/&gt;Field is required.&lt;/span&gt; &lt;span name="*.errors" class="errorBox"&gt;Field is required.&lt;br/&gt;Field is required.&lt;/span&gt;
&lt;table&gt; &lt;table&gt;
&lt;tr&gt; &lt;tr&gt;
@ -779,7 +779,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
using the <classname>TilesConfigurer</classname>. Have a look at the using the <classname>TilesConfigurer</classname>. Have a look at the
following piece of example ApplicationContext configuration:</para> following piece of example ApplicationContext configuration:</para>
<programlisting><![CDATA[<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> <programlisting language="xml"><![CDATA[<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions"> <property name="definitions">
<list> <list>
<value>/WEB-INF/defs/general.xml</value> <value>/WEB-INF/defs/general.xml</value>
@ -808,7 +808,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>The <classname>UrlBasedViewResolver</classname> instantiates the given <para>The <classname>UrlBasedViewResolver</classname> instantiates the given
<literal>viewClass</literal> for each view it has to resolve.</para> <literal>viewClass</literal> for each view it has to resolve.</para>
<programlisting><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <programlisting language="xml"><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/> <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>]]></programlisting> </bean>]]></programlisting>
@ -821,11 +821,11 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
property file containing viewnames and viewclasses the resolver can property file containing viewnames and viewclasses the resolver can
use:</para> use:</para>
<programlisting><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <programlisting language="xml"><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views"/> <property name="basename" value="views"/>
</bean>]]></programlisting> </bean>]]></programlisting>
<programlisting><![CDATA[... <programlisting language="java"><![CDATA[...
welcomeView.class=org.springframework.web.servlet.view.tiles2.TilesView welcomeView.class=org.springframework.web.servlet.view.tiles2.TilesView
welcomeView.url=welcome ]]><lineannotation>(this is the name of a Tiles definition)</lineannotation><![CDATA[ welcomeView.url=welcome ]]><lineannotation>(this is the name of a Tiles definition)</lineannotation><![CDATA[
@ -868,7 +868,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
scoped beans etc. Note that you need to define one Spring bean definition per scoped beans etc. Note that you need to define one Spring bean definition per
preparer name (as used in your Tiles definitions).</para> preparer name (as used in your Tiles definitions).</para>
<programlisting><![CDATA[<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> <programlisting language="xml"><![CDATA[<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions"> <property name="definitions">
<list> <list>
<value>/WEB-INF/defs/general.xml</value> <value>/WEB-INF/defs/general.xml</value>
@ -927,7 +927,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
<para>A suitable configuration is initialized by adding the relevant <para>A suitable configuration is initialized by adding the relevant
configurer bean definition to your <filename>'*-servlet.xml'</filename> as shown below:</para> configurer bean definition to your <filename>'*-servlet.xml'</filename> as shown below:</para>
<programlisting><lineannotation>&lt;!-- <programlisting language="xml"><lineannotation>&lt;!--
This bean sets up the Velocity environment for us based on a root path for templates. This bean sets up the Velocity environment for us based on a root path for templates.
Optionally, a properties file can be specified for more control over the Velocity Optionally, a properties file can be specified for more control over the Velocity
environment, but the defaults are pretty sane for file based template loading. environment, but the defaults are pretty sane for file based template loading.
@ -1003,7 +1003,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
need this file, specify its location on the need this file, specify its location on the
<literal>VelocityConfigurer</literal> bean definition above.</para> <literal>VelocityConfigurer</literal> bean definition above.</para>
<programlisting>&lt;bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"&gt; <programlisting language="xml">&lt;bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"&gt;
&lt;property name="configLocation value="/WEB-INF/velocity.properties"/&gt; &lt;property name="configLocation value="/WEB-INF/velocity.properties"/&gt;
&lt;/bean&gt;</programlisting> &lt;/bean&gt;</programlisting>
@ -1011,7 +1011,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
the bean definition for the Velocity config bean by replacing the the bean definition for the Velocity config bean by replacing the
"configLocation" property with the following inline properties.</para> "configLocation" property with the following inline properties.</para>
<programlisting><![CDATA[<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <programlisting language="xml"><![CDATA[<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="velocityProperties"> <property name="velocityProperties">
<props> <props>
<prop key="resource.loader">file</prop> <prop key="resource.loader">file</prop>
@ -1043,7 +1043,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
<literal>freemarkerVariables</literal> property requires a <literal>freemarkerVariables</literal> property requires a
<literal>java.util.Map</literal>.</para> <literal>java.util.Map</literal>.</para>
<programlisting><![CDATA[<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <programlisting language="xml"><![CDATA[<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/freemarker/"/> <property name="templateLoaderPath" value="/WEB-INF/freemarker/"/>
<property name="freemarkerVariables"> <property name="freemarkerVariables">
<map> <map>
@ -1104,7 +1104,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
<literal>personFormV</literal> and <literal>personFormF</literal> <literal>personFormV</literal> and <literal>personFormF</literal>
views configured earlier;</para> views configured earlier;</para>
<programlisting>&lt;!-- velocity macros are automatically available --&gt; <programlisting language="xml">&lt;!-- velocity macros are automatically available --&gt;
&lt;html&gt; &lt;html&gt;
... ...
&lt;form action="" method="POST"&gt; &lt;form action="" method="POST"&gt;
@ -1121,7 +1121,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
... ...
&lt;/html&gt;</programlisting> &lt;/html&gt;</programlisting>
<programlisting>&lt;!-- freemarker macros have to be imported into a namespace. We strongly <programlisting language="xml">&lt;!-- freemarker macros have to be imported into a namespace. We strongly
recommend sticking to 'spring' --&gt; recommend sticking to 'spring' --&gt;
&lt;#import "spring.ftl" as spring /&gt; &lt;#import "spring.ftl" as spring /&gt;
&lt;html&gt; &lt;html&gt;
@ -1389,7 +1389,7 @@ recommend sticking to 'spring' --&gt;
<section id="views-form-macros-input"> <section id="views-form-macros-input">
<title>Input Fields</title> <title>Input Fields</title>
<para><programlisting>&lt;!-- the Name field example from above using form macros in VTL --&gt; <para><programlisting language="xml">&lt;!-- the Name field example from above using form macros in VTL --&gt;
... ...
Name: Name:
#springFormInput("command.name" "")&lt;br&gt; #springFormInput("command.name" "")&lt;br&gt;
@ -1410,7 +1410,7 @@ recommend sticking to 'spring' --&gt;
values for the attributes parameter, unlike Velocity, and the two values for the attributes parameter, unlike Velocity, and the two
macro calls above could be expressed as follows in FTL:</para> macro calls above could be expressed as follows in FTL:</para>
<programlisting>&lt;@spring.formInput "command.name"/&gt; <programlisting language="xml">&lt;@spring.formInput "command.name"/&gt;
&lt;@spring.showErrors "&lt;br&gt;"/&gt;</programlisting> &lt;@spring.showErrors "&lt;br&gt;"/&gt;</programlisting>
<para>Output is shown below of the form fragment generating the name <para>Output is shown below of the form fragment generating the name
@ -1500,7 +1500,7 @@ New York</programlisting>
for example, the map of codes would be created with suitable keys for example, the map of codes would be created with suitable keys
like the example below.</para> like the example below.</para>
<programlisting>protected Map referenceData(HttpServletRequest request) throws Exception { <programlisting language="java">protected Map referenceData(HttpServletRequest request) throws Exception {
Map cityMap = new LinkedHashMap(); Map cityMap = new LinkedHashMap();
cityMap.put("LDN", "London"); cityMap.put("LDN", "London");
cityMap.put("PRS", "Paris"); cityMap.put("PRS", "Paris");
@ -1559,7 +1559,7 @@ New York</programlisting>
<para>In similar fashion, HTML escaping can be specified per <para>In similar fashion, HTML escaping can be specified per
field:</para> field:</para>
<programlisting>&lt;#-- until this point, default HTML escaping is used --&gt; <programlisting language="xml">&lt;#-- until this point, default HTML escaping is used --&gt;
&lt;#assign htmlEscape = true in spring&gt; &lt;#assign htmlEscape = true in spring&gt;
&lt;#-- next field will use HTML escaping --&gt; &lt;#-- next field will use HTML escaping --&gt;
@ -1598,7 +1598,7 @@ New York</programlisting>
dispatcher servlet config file contains a reference to a dispatcher servlet config file contains a reference to a
<interfacename>ViewResolver</interfacename>, URL mappings and a single controller <interfacename>ViewResolver</interfacename>, URL mappings and a single controller
bean...</para> bean...</para>
<programlisting><![CDATA[<bean id="homeController"class="xslt.HomeController"/>]]></programlisting> <programlisting language="xml"><![CDATA[<bean id="homeController"class="xslt.HomeController"/>]]></programlisting>
<para>... that encapsulates our word generation logic.</para> <para>... that encapsulates our word generation logic.</para>
</section> </section>
@ -1608,7 +1608,7 @@ New York</programlisting>
<para>The controller logic is encapsulated in a subclass of <para>The controller logic is encapsulated in a subclass of
<classname>AbstractController</classname>, with the handler method being defined like so...</para> <classname>AbstractController</classname>, with the handler method being defined like so...</para>
<programlisting><![CDATA[protected ModelAndView handleRequestInternal( <programlisting language="java"><![CDATA[protected ModelAndView handleRequestInternal(
HttpServletRequest request, HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
@ -1649,7 +1649,7 @@ New York</programlisting>
<methodname>createXsltSource(..)</methodname> method. The first parameter passed <methodname>createXsltSource(..)</methodname> method. The first parameter passed
to this method is our model map. Here's the complete listing of the to this method is our model map. Here's the complete listing of the
<classname>HomePage</classname> class in our trivial word application:</para> <classname>HomePage</classname> class in our trivial word application:</para>
<programlisting><![CDATA[ <programlisting language="java"><![CDATA[
package xslt; package xslt;
]]><lineannotation>// imports omitted for brevity</lineannotation><![CDATA[ ]]><lineannotation>// imports omitted for brevity</lineannotation><![CDATA[
@ -1717,7 +1717,7 @@ home.root=words]]></programlisting>
<filename>'home.xslt'</filename> and it lives in the war file in the <filename>'home.xslt'</filename> and it lives in the war file in the
<filename class="directory">'WEB-INF/xsl'</filename> directory.</para> <filename class="directory">'WEB-INF/xsl'</filename> directory.</para>
<programlisting><![CDATA[<?xml version="1.0" encoding="utf-8"?> <programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes"/> <xsl:output method="html" omit-xml-declaration="yes"/>
@ -1847,7 +1847,7 @@ pdf.class=pdf.HomePage</programlisting> <emphasis>If you want to start with a
<para>Here's the complete listing for our POI Excel view which displays <para>Here's the complete listing for our POI Excel view which displays
the word list from the model map in consecutive rows of the first the word list from the model map in consecutive rows of the first
column of a new spreadsheet.. <programlisting>package excel; column of a new spreadsheet.. <programlisting language="java">package excel;
// imports omitted for brevity // imports omitted for brevity
@ -1883,7 +1883,7 @@ public class HomePage extends AbstractExcelView {
} }
}</programlisting></para> }</programlisting></para>
<para>And this a view generating the same Excel file, now using JExcelApi: <programlisting>package excel; <para>And this a view generating the same Excel file, now using JExcelApi: <programlisting language="java">package excel;
// imports omitted for brevity // imports omitted for brevity
@ -1927,7 +1927,7 @@ public class HomePage extends AbstractExcelView {
class extends class extends
<literal>org.springframework.web.servlet.view.document.AbstractPdfView</literal> <literal>org.springframework.web.servlet.view.document.AbstractPdfView</literal>
and implements the <literal>buildPdfDocument()</literal> method as and implements the <literal>buildPdfDocument()</literal> method as
follows.. <programlisting>package pdf; follows.. <programlisting language="java">package pdf;
// imports omitted for brevity // imports omitted for brevity
@ -2012,7 +2012,7 @@ public class PDFPage extends AbstractPdfView {
<para>Typically, you will use the <classname>ResourceBundleViewResolver</classname> <para>Typically, you will use the <classname>ResourceBundleViewResolver</classname>
to map view names to view classes and files in a properties file.</para> to map view names to view classes and files in a properties file.</para>
<programlisting><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <programlisting language="xml"><![CDATA[<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views"/> <property name="basename" value="views"/>
</bean>]]></programlisting> </bean>]]></programlisting>
@ -2117,7 +2117,7 @@ simpleReport.url=/WEB-INF/reports/DataSourceReport.jasper]]></programlisting>
entry to your model with the formay key as the key and the mapping key entry to your model with the formay key as the key and the mapping key
as the value, for example:</para> as the value, for example:</para>
<programlisting><![CDATA[public ModelAndView handleSimpleReportMulti(HttpServletRequest request, <programlisting language="java"><![CDATA[public ModelAndView handleSimpleReportMulti(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
String uri = request.getRequestURI(); String uri = request.getRequestURI();
@ -2208,7 +2208,7 @@ HttpServletResponse response) throws Exception {
locate this object in the model and treat it as the report datasource. locate this object in the model and treat it as the report datasource.
For example, you may populate your model like so:</para> For example, you may populate your model like so:</para>
<programlisting><![CDATA[private Map getModel() { <programlisting language="java"><![CDATA[private Map getModel() {
Map model = new HashMap(); Map model = new HashMap();
Collection beanData = getBeanData(); Collection beanData = getBeanData();
model.put("myBeanData", beanData); model.put("myBeanData", beanData);
@ -2222,7 +2222,7 @@ HttpServletResponse response) throws Exception {
cases Spring will instances of <literal>Collection</literal> in a cases Spring will instances of <literal>Collection</literal> in a
<literal>JRBeanCollectionDataSource</literal> instance. For example:</para> <literal>JRBeanCollectionDataSource</literal> instance. For example:</para>
<programlisting><![CDATA[private Map getModel() { <programlisting language="java"><![CDATA[private Map getModel() {
Map model = new HashMap(); Map model = new HashMap();
Collection beanData = getBeanData(); Collection beanData = getBeanData();
Collection someData = getSomeData(); Collection someData = getSomeData();
@ -2268,10 +2268,10 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
sub-reports from an external source. To do this you declare a sub-reports from an external source. To do this you declare a
parameter in your report file like so:</para> parameter in your report file like so:</para>
<programlisting><![CDATA[<parameter name="ProductsSubReport" class="net.sf.jasperreports.engine.JasperReport"/>]]></programlisting> <programlisting language="xml"><![CDATA[<parameter name="ProductsSubReport" class="net.sf.jasperreports.engine.JasperReport"/>]]></programlisting>
<para>Then, you define your sub-report to use this sub-report parameter:</para> <para>Then, you define your sub-report to use this sub-report parameter:</para>
<programlisting>&lt;subreport&gt; <programlisting language="xml">&lt;subreport&gt;
&lt;reportElement isPrintRepeatedValues="false" x="5" y="25" width="325" &lt;reportElement isPrintRepeatedValues="false" x="5" y="25" width="325"
height="20" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/&gt; height="20" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/&gt;
&lt;subreportParameter name="City"&gt; &lt;subreportParameter name="City"&gt;
@ -2290,7 +2290,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
pass into the JasperReports engine as a sub-report using the pass into the JasperReports engine as a sub-report using the
<literal>subReportUrls</literal> property:</para> <literal>subReportUrls</literal> property:</para>
<programlisting><![CDATA[<property name="subReportUrls"> <programlisting language="xml"><![CDATA[<property name="subReportUrls">
<map> <map>
<entry key="ProductsSubReport" value="/WEB-INF/reports/subReportChild.jrxml"/> <entry key="ProductsSubReport" value="/WEB-INF/reports/subReportChild.jrxml"/>
</map> </map>
@ -2314,7 +2314,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
which of the parameters in your <literal>ModelAndView</literal> Spring which of the parameters in your <literal>ModelAndView</literal> Spring
should convert. To do this configure the list of parameter names using should convert. To do this configure the list of parameter names using
the <literal>subReportDataKeys</literal> property of the your chosen the <literal>subReportDataKeys</literal> property of the your chosen
view class: <programlisting>&lt;property name="subReportDataKeys" view class: <programlisting language="xml">&lt;property name="subReportDataKeys"
value="SubReportData"/&gt;</programlisting> Here, the key you supply MUST value="SubReportData"/&gt;</programlisting> Here, the key you supply MUST
correspond to both the key used in your <literal>ModelAndView</literal> correspond to both the key used in your <literal>ModelAndView</literal>
and the key used in your report design file.</para> and the key used in your report design file.</para>
@ -2335,7 +2335,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
entry should be the value you want to assign to the parameter. An entry should be the value you want to assign to the parameter. An
example of this is shown below:</para> example of this is shown below:</para>
<programlisting>&lt;bean id="htmlReport" class="org.springframework.web.servlet.view.jasperreports.JasperReportsHtmlView"&gt; <programlisting language="xml">&lt;bean id="htmlReport" class="org.springframework.web.servlet.view.jasperreports.JasperReportsHtmlView"&gt;
&lt;property name="url" value="/WEB-INF/reports/simpleReport.jrxml"/&gt; &lt;property name="url" value="/WEB-INF/reports/simpleReport.jrxml"/&gt;
&lt;property name="exporterParameters"&gt; &lt;property name="exporterParameters"&gt;
&lt;map&gt; &lt;map&gt;

View File

@ -88,7 +88,7 @@
<para> <para>
Find below the &lt;listener/&gt; configuration: Find below the &lt;listener/&gt; configuration:
</para> </para>
<programlisting><![CDATA[<listener> <programlisting language="xml"><![CDATA[<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>]]></programlisting> </listener>]]></programlisting>
<note> <note>
@ -102,7 +102,7 @@
<para> <para>
Find below the &lt;context-param/&gt; configuration: Find below the &lt;context-param/&gt; configuration:
</para> </para>
<programlisting><![CDATA[<context-param> <programlisting language="xml"><![CDATA[<context-param>
<param-name>contextConfigLocation</param-name> <param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value> <param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>]]></programlisting> </context-param>]]></programlisting>
@ -121,7 +121,7 @@
<interface>ApplicationContext</interface> created by the <interface>ApplicationContext</interface> created by the
<classname>ContextLoaderListener</classname>. <classname>ContextLoaderListener</classname>.
</para> </para>
<programlisting><![CDATA[WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);]]></programlisting> <programlisting language="java"><![CDATA[WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);]]></programlisting>
<para> <para>
The <ulink url="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/context/support/WebApplicationContextUtils.html"><classname>WebApplicationContextUtils</classname></ulink> The <ulink url="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/context/support/WebApplicationContextUtils.html"><classname>WebApplicationContextUtils</classname></ulink>
class is for convenience, so you don't have to remember the name of the class is for convenience, so you don't have to remember the name of the
@ -188,7 +188,7 @@
element and a <literal>&lt;variable-resolver/&gt;</literal> element within it. element and a <literal>&lt;variable-resolver/&gt;</literal> element within it.
The value of the variable resolver should reference Spring's The value of the variable resolver should reference Spring's
<classname>DelegatingVariableResolver</classname>; for example:</para> <classname>DelegatingVariableResolver</classname>; for example:</para>
<programlisting><![CDATA[<faces-config> <programlisting language="xml"><![CDATA[<faces-config>
<application> <application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver> <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
<locale-config> <locale-config>
@ -210,7 +210,7 @@
file. Find below an example where <literal>#{userManager}</literal> is a bean file. Find below an example where <literal>#{userManager}</literal> is a bean
that is retrieved from the Spring 'business context'. that is retrieved from the Spring 'business context'.
</para> </para>
<programlisting><![CDATA[<managed-bean> <programlisting language="xml"><![CDATA[<managed-bean>
<managed-bean-name>userList</managed-bean-name> <managed-bean-name>userList</managed-bean-name>
<managed-bean-class>com.whatever.jsf.UserList</managed-bean-class> <managed-bean-class>com.whatever.jsf.UserList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope> <managed-bean-scope>request</managed-bean-scope>
@ -235,7 +235,7 @@
Configuration-wise, simply define <classname>SpringBeanVariableResolver</classname> Configuration-wise, simply define <classname>SpringBeanVariableResolver</classname>
in your <emphasis>faces-context.xml</emphasis> file: in your <emphasis>faces-context.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<faces-config> <programlisting language="xml"><![CDATA[<faces-config>
<application> <application>
<variable-resolver>org.springframework.web.jsf.SpringBeanVariableResolver</variable-resolver> <variable-resolver>org.springframework.web.jsf.SpringBeanVariableResolver</variable-resolver>
... ...
@ -257,7 +257,7 @@
Configuration-wise, simply define <classname>SpringBeanFacesELResolver</classname> Configuration-wise, simply define <classname>SpringBeanFacesELResolver</classname>
in your JSF 1.2 <emphasis>faces-context.xml</emphasis> file: in your JSF 1.2 <emphasis>faces-context.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<faces-config> <programlisting language="xml"><![CDATA[<faces-config>
<application> <application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
... ...
@ -276,7 +276,7 @@
takes a <classname>FacesContext</classname> parameter rather than a takes a <classname>FacesContext</classname> parameter rather than a
<interface>ServletContext</interface> parameter. <interface>ServletContext</interface> parameter.
</para> </para>
<programlisting><![CDATA[ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());]]></programlisting> <programlisting language="java"><![CDATA[ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());]]></programlisting>
</section> </section>
</section> </section>
@ -344,12 +344,12 @@
To configure this plug-in, add the following XML to the plug-ins section near To configure this plug-in, add the following XML to the plug-ins section near
the bottom of your <emphasis>struts-config.xml</emphasis> file: the bottom of your <emphasis>struts-config.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"/>]]></programlisting> <programlisting language="xml"><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"/>]]></programlisting>
<para> <para>
The location of the context configuration files can be customized using the The location of the context configuration files can be customized using the
'<literal>contextConfigLocation</literal>' property. '<literal>contextConfigLocation</literal>' property.
</para> </para>
<programlisting><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <programlisting language="xml"><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" <set-property property="contextConfigLocation"
value="/WEB-INF/action-servlet.xml,/WEB-INF/applicationContext.xml"/> value="/WEB-INF/action-servlet.xml,/WEB-INF/applicationContext.xml"/>
</plug-in>]]></programlisting> </plug-in>]]></programlisting>
@ -389,12 +389,12 @@
action-mapping's "path" and the bean's "name". If you have the action-mapping's "path" and the bean's "name". If you have the
following in your <emphasis>struts-config.xml</emphasis> file: following in your <emphasis>struts-config.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<action path="/users" .../>]]></programlisting> <programlisting language="xml"><![CDATA[<action path="/users" .../>]]></programlisting>
<para> <para>
You must define that Action's bean with the "/users" name in You must define that Action's bean with the "/users" name in
<emphasis>action-servlet.xml</emphasis>: <emphasis>action-servlet.xml</emphasis>:
</para> </para>
<programlisting><![CDATA[<bean name="/users" .../>]]></programlisting> <programlisting language="xml"><![CDATA[<bean name="/users" .../>]]></programlisting>
<section id="struts-delegatingrequestprocessor"> <section id="struts-delegatingrequestprocessor">
<title>DelegatingRequestProcessor</title> <title>DelegatingRequestProcessor</title>
<para> <para>
@ -404,7 +404,7 @@
property in the &lt;controller&gt; element. These lines follow the property in the &lt;controller&gt; element. These lines follow the
&lt;action-mapping&gt; element. &lt;action-mapping&gt; element.
</para> </para>
<programlisting><![CDATA[<controller> <programlisting language="xml"><![CDATA[<controller>
<set-property property="processorClass" <set-property property="processorClass"
value="org.springframework.web.struts.DelegatingRequestProcessor"/> value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>]]></programlisting> </controller>]]></programlisting>
@ -414,7 +414,7 @@
you don't even need to specify a type. Both of the following snippets you don't even need to specify a type. Both of the following snippets
will work: will work:
</para> </para>
<programlisting><![CDATA[<action path="/user" type="com.whatever.struts.UserAction"/> <programlisting language="xml"><![CDATA[<action path="/user" type="com.whatever.struts.UserAction"/>
<action path="/user"/>]]></programlisting> <action path="/user"/>]]></programlisting>
<para> <para>
If you're using Struts' <emphasis>modules</emphasis> feature, If you're using Struts' <emphasis>modules</emphasis> feature,
@ -442,7 +442,7 @@
<classname>DelegatingActionProxy</classname></ulink> as the type in your <classname>DelegatingActionProxy</classname></ulink> as the type in your
action-mapping. action-mapping.
</para> </para>
<programlisting><![CDATA[<action path="/user" type="org.springframework.web.struts.DelegatingActionProxy" <programlisting language="xml"><![CDATA[<action path="/user" type="org.springframework.web.struts.DelegatingActionProxy"
name="userForm" scope="request" validate="false" parameter="method"> name="userForm" scope="request" validate="false" parameter="method">
<forward name="list" path="/userList.jsp"/> <forward name="list" path="/userList.jsp"/>
<forward name="edit" path="/userForm.jsp"/> <forward name="edit" path="/userForm.jsp"/>
@ -459,7 +459,7 @@
<classname>Action</classname> instance for each request. To activate the latter, <classname>Action</classname> instance for each request. To activate the latter,
add <emphasis>scope="prototype"</emphasis> to your Action's bean definition. add <emphasis>scope="prototype"</emphasis> to your Action's bean definition.
</para> </para>
<programlisting><![CDATA[<bean name="/user" scope="prototype" autowire="byName" <programlisting language="xml"><![CDATA[<bean name="/user" scope="prototype" autowire="byName"
class="org.example.web.UserAction"/>]]></programlisting> class="org.example.web.UserAction"/>]]></programlisting>
</section> </section>
</section> </section>
@ -480,7 +480,7 @@
convenience methods, like <emphasis>getWebApplicationContext()</emphasis>. convenience methods, like <emphasis>getWebApplicationContext()</emphasis>.
Below is an example of how you might use this in an Action: Below is an example of how you might use this in an Action:
</para> </para>
<programlisting><![CDATA[public class UserAction extends DispatchActionSupport { <programlisting language="java"><![CDATA[public class UserAction extends DispatchActionSupport {
public ActionForward execute(ActionMapping mapping, public ActionForward execute(ActionMapping mapping,
ActionForm form, ActionForm form,
@ -627,7 +627,7 @@
Assume we have the following simple Spring container definition (in the Assume we have the following simple Spring container definition (in the
ubiquitous XML format): ubiquitous XML format):
</para> </para>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd"> "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
@ -703,7 +703,7 @@
a page to get an instance of the <interfacename>UserService</interfacename>, a page to get an instance of the <interfacename>UserService</interfacename>,
for example, would be with code such as: for example, would be with code such as:
</para> </para>
<programlisting><![CDATA[WebApplicationContext appContext = WebApplicationContextUtils.getApplicationContext( <programlisting language="java"><![CDATA[WebApplicationContext appContext = WebApplicationContextUtils.getApplicationContext(
getRequestCycle().getRequestContext().getServlet().getServletContext()); getRequestCycle().getRequestContext().getServlet().getServletContext());
UserService userService = (UserService) appContext.getBean("userService"); UserService userService = (UserService) appContext.getBean("userService");
]]><lineannotation>... some code which uses UserService</lineannotation></programlisting> ]]><lineannotation>... some code which uses UserService</lineannotation></programlisting>
@ -744,7 +744,7 @@ UserService userService = (UserService) appContext.getBean("userService");
directly. One way is by defining a custom version of the Tapestry directly. One way is by defining a custom version of the Tapestry
<interfacename>IEngine</interfacename> which exposes this for us: <interfacename>IEngine</interfacename> which exposes this for us:
</para> </para>
<programlisting><![CDATA[package com.whatever.web.xportal; <programlisting language="java"><![CDATA[package com.whatever.web.xportal;
import ... import ...
@ -776,7 +776,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
instance should be used for this Tapestry application, with an entry instance should be used for this Tapestry application, with an entry
in the Tapestry application definition file. For example: in the Tapestry application definition file. For example:
</para> </para>
<programlisting><lineannotation>file: xportal.application:</lineannotation><![CDATA[ <programlisting language="xml"><lineannotation>file: xportal.application:</lineannotation><![CDATA[
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC <!DOCTYPE application PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN" "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
@ -794,7 +794,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
need out of the <interfacename>ApplicationContext</interfacename>, need out of the <interfacename>ApplicationContext</interfacename>,
and create page or component properties for them. For example: and create page or component properties for them. For example:
</para> </para>
<programlisting><![CDATA[ <property-specification name="userService" <programlisting language="xml"><![CDATA[ <property-specification name="userService"
type="com.whatever.services.service.user.UserService"> type="com.whatever.services.service.user.UserService">
global.appContext.getBean("userService") global.appContext.getBean("userService")
</property-specification> </property-specification>
@ -807,7 +807,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
initial value for the property, as a bean obtained from the context. initial value for the property, as a bean obtained from the context.
The entire page definition might look like this: The entire page definition might look like this:
</para> </para>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC <!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN" "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd"> "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
@ -857,7 +857,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
for the properties we have defined (in order to be able to for the properties we have defined (in order to be able to
access the properties). access the properties).
</para> </para>
<programlisting><![CDATA[// our UserService implementation; will come from page definition <programlisting language="java"><![CDATA[// our UserService implementation; will come from page definition
public abstract UserService getUserService(); public abstract UserService getUserService();
// our AuthenticationService implementation; will come from page definition // our AuthenticationService implementation; will come from page definition
public abstract AuthenticationService getAuthenticationService();]]></programlisting> public abstract AuthenticationService getAuthenticationService();]]></programlisting>
@ -865,7 +865,7 @@ public abstract AuthenticationService getAuthenticationService();]]></programlis
For the sake of completeness, the entire Java class, for a For the sake of completeness, the entire Java class, for a
login page in this example, might look like this: login page in this example, might look like this:
</para> </para>
<programlisting><![CDATA[package com.whatever.web.xportal.pages; <programlisting language="java"><![CDATA[package com.whatever.web.xportal.pages;
/** /**
* Allows the user to login, by providing username and password. * Allows the user to login, by providing username and password.
@ -1001,7 +1001,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende
and <literal>authenticationService</literal> objects (lots of the class and <literal>authenticationService</literal> objects (lots of the class
definition has been elided for clarity)... definition has been elided for clarity)...
</para> </para>
<programlisting><![CDATA[package com.whatever.web.xportal.pages; <programlisting language="java"><![CDATA[package com.whatever.web.xportal.pages;
public abstract class Login extends BasePage implements ErrorProperty, PageRenderListener { public abstract class Login extends BasePage implements ErrorProperty, PageRenderListener {
@ -1016,7 +1016,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende
We are almost done... all that remains is the HiveMind configuration that exposes the We are almost done... all that remains is the HiveMind configuration that exposes the
Spring container stored in the <interfacename>ServletContext</interfacename> as a Spring container stored in the <interfacename>ServletContext</interfacename> as a
HiveMind service; for example:</para> HiveMind service; for example:</para>
<programlisting><![CDATA[<?xml version="1.0"?> <programlisting language="xml"><![CDATA[<?xml version="1.0"?>
<module id="com.javaforge.tapestry.spring" version="0.1.1"> <module id="com.javaforge.tapestry.spring" version="0.1.1">
<service-point id="SpringApplicationInitializer" <service-point id="SpringApplicationInitializer"
@ -1049,7 +1049,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende
inside the <literal>.page</literal> or <literal>.jwc</literal> file inside the <literal>.page</literal> or <literal>.jwc</literal> file
for the <classname>Login</classname> page (or component): for the <classname>Login</classname> page (or component):
</para> </para>
<programlisting><![CDATA[<inject property="userService" object="spring:userService"/> <programlisting language="xml"><![CDATA[<inject property="userService" object="spring:userService"/>
<inject property="authenticationService" object="spring:authenticationService"/>]]></programlisting> <inject property="authenticationService" object="spring:authenticationService"/>]]></programlisting>
</section> </section>
</section> </section>