Browse Source

added language element to programlisting for syntax highlighting

conversation
Thomas Risberg 16 years ago
parent
commit
077d7f4bce
  1. 98
      spring-framework-reference/src/mvc.xml
  2. 42
      spring-framework-reference/src/portlet.xml
  3. 118
      spring-framework-reference/src/view.xml
  4. 56
      spring-framework-reference/src/web-integration.xml

98
spring-framework-reference/src/mvc.xml

@ -341,7 +341,7 @@ @@ -341,7 +341,7 @@
<para>Consider the following <classname>DispatcherServlet</classname>
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-name&gt;<emphasis role="bold">golfing</emphasis>&lt;/servlet-name&gt;
@ -613,7 +613,7 @@ @@ -613,7 +613,7 @@
<interfacename>org.springframework.web.servlet.mvc.Controller</interfacename>
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
@ -731,7 +731,7 @@ @@ -731,7 +731,7 @@
consisting of a class and a declaration in the web application
context.</para>
<programlisting>package samples;
<programlisting language="java">package samples;
public class SampleController extends AbstractController {
@ -745,7 +745,7 @@ public class SampleController extends AbstractController { @@ -745,7 +745,7 @@ public class SampleController extends AbstractController {
}
}</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;/bean&gt;</programlisting>
@ -843,18 +843,18 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -843,18 +843,18 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<para>The standard signature (mirrors the
<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
that will be populated (bound) with parameters retrieved from the
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
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
that will be populated (bound) with parameters retrieved from the
@ -864,13 +864,13 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -864,13 +864,13 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
always be the final argument (fourth when a session is specified, or
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
indicating that the handler method assumes the responsibility of writing
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
type indicating that a view name translator will be responsible for
@ -878,7 +878,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -878,7 +878,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
consist of the <interfacename>Map's</interfacename> entries (see the
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
responsible for resolving method names based on the specifics of the
@ -944,13 +944,13 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -944,13 +944,13 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<classname>Exception</classname>. Here is an example signature for one
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
<classname>MultiActionController</classname> usage in conjunction with
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;
&lt;property name="methodNameResolver"&gt;
@ -966,7 +966,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -966,7 +966,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
&lt;/bean&gt;
}</programlisting>
<programlisting>public class SampleDelegate {
<programlisting language="java">public class SampleDelegate {
public ModelAndView retrieveIndex(HttpServletRequest req, HttpServletResponse resp) {
return new ModelAndView("index", "date", new Long(System.currentTimeMillis()));
@ -977,7 +977,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -977,7 +977,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<classname>PropertiesMethodNameResolver</classname> to match any number
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;
&lt;property name="mappings"&gt;
&lt;value&gt;
@ -1204,7 +1204,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -1204,7 +1204,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
appropriate form <interfacename>Controller</interfacename> as
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 name="/editaccount.form" class="org.springframework.web.servlet.mvc.SimpleFormController"&gt;
@ -1222,7 +1222,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -1222,7 +1222,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<literal>web.xml</literal> as well, to let through all the requests
ending with <literal>.form</literal>.</para>
<programlisting>&lt;web-app&gt;
<programlisting language="xml">&lt;web-app&gt;
...
&lt;servlet&gt;
&lt;servlet-name&gt;sample&lt;/servlet-name&gt;
@ -1258,7 +1258,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -1258,7 +1258,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
<classname>org.springframework.util.PathMatcher</classname> class). Here
is an example:</para>
<programlisting>&lt;web-app&gt;
<programlisting language="xml">&lt;web-app&gt;
...
&lt;servlet&gt;
&lt;servlet-name&gt;sample&lt;/servlet-name&gt;
@ -1284,7 +1284,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -1284,7 +1284,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
all requests ending with .html and <literal>.form</literal> to be
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>
&lt;bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
@ -1354,7 +1354,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -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
between 9 a.m. and 6 p.m.</para>
<programlisting>&lt;beans&gt;
<programlisting language="xml">&lt;beans&gt;
&lt;bean id="handlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
&lt;property name="interceptors"&gt;
@ -1377,7 +1377,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer @@ -1377,7 +1377,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer
&lt;/bean&gt;
&lt;beans&gt;</programlisting>
<programlisting>package samples;
<programlisting language="java">package samples;
public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
@ -1542,7 +1542,7 @@ 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
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;
&lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt;
&lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
@ -1557,7 +1557,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { @@ -1557,7 +1557,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
<para>When mixing different view technologies in a web application, you
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;
&lt;property name="basename" value="views"/&gt;
&lt;property name="defaultParentView" value="parentView"/&gt;
@ -1601,7 +1601,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { @@ -1601,7 +1601,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
Excel views (which are not supported by the
<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="prefix" value="/WEB-INF/jsp/"/&gt;
&lt;property name="suffix" value=".jsp"/&gt;
@ -1801,7 +1801,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { @@ -1801,7 +1801,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
below an example of defining a
<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;
@ -1884,7 +1884,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { @@ -1884,7 +1884,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
on the <interfacename>LocaleResolver</interfacename> that also exists in
the context).</para>
<programlisting>&lt;bean id="localeChangeInterceptor"
<programlisting language="xml">&lt;bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
&lt;property name="paramName" value="siteLanguage"/&gt;
&lt;/bean&gt;
@ -1959,7 +1959,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting> @@ -1959,7 +1959,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
fragment uses the theme defined above to customize the look and
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;head&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> @@ -2079,7 +2079,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
<para>The following example shows how to use the
<classname>CommonsMultipartResolver</classname>:</para>
<programlisting>&lt;bean id="multipartResolver"
<programlisting language="xml">&lt;bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
<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> @@ -2089,7 +2089,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
<para>This is an example using the
<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>
&lt;property name="maxUploadSize" value="100000"/&gt;
@ -2124,7 +2124,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting> @@ -2124,7 +2124,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
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>
<programlisting>&lt;html&gt;
<programlisting language="xml">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Upload a file please&lt;/title&gt;
&lt;/head&gt;
@ -2159,7 +2159,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting> @@ -2159,7 +2159,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
resolver, a url mapping to a controller that will process the bean, and
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>
&lt;bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/&gt;
@ -2183,7 +2183,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting> @@ -2183,7 +2183,7 @@ background=/themes/cool/img/coolBg.jpg</programlisting>
<para>After that, create the controller and the actual class to hold the
file property.</para>
<programlisting>public class FileUploadController extends SimpleFormController {
<programlisting language="java">public class FileUploadController extends SimpleFormController {
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors) throws ServletException, IOException {
@ -2235,7 +2235,7 @@ public class FileUploadBean { @@ -2235,7 +2235,7 @@ public class FileUploadBean {
<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>
<programlisting>public class FileUploadController extends SimpleFormController {
<programlisting language="java">public class FileUploadController extends SimpleFormController {
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors) throws ServletException, IOException {
@ -2286,7 +2286,7 @@ public class FileUploadBean { @@ -2286,7 +2286,7 @@ public class FileUploadBean {
register any custom <interfacename>PropertyEditor</interfacename>
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,
Object command, BindException errors) throws ServletException, IOException {
@ -2379,7 +2379,7 @@ public class FileUploadBean { @@ -2379,7 +2379,7 @@ public class FileUploadBean {
<interfacename>Controller</interfacename> implementation. Take especial
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) {
<lineannotation>// the implementation is not hugely important for this example...</lineannotation>
@ -2389,7 +2389,7 @@ public class FileUploadBean { @@ -2389,7 +2389,7 @@ public class FileUploadBean {
<para>Here is a snippet from the attendent Spring Web MVC configuration
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;
<lineannotation>&lt;!-- inject dependencies as required... --&gt;</lineannotation>
@ -2484,7 +2484,7 @@ public class FileUploadBean { @@ -2484,7 +2484,7 @@ public class FileUploadBean {
objects are added to the <classname>ModelAndView</classname> without any
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) {
@ -2612,7 +2612,7 @@ public class FileUploadBean { @@ -2612,7 +2612,7 @@ public class FileUploadBean {
request URLs to logical view names in a fashion that is probably best
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) {
<lineannotation>// process the request...</lineannotation>
@ -2623,7 +2623,7 @@ public class FileUploadBean { @@ -2623,7 +2623,7 @@ public class FileUploadBean {
}
}</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"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd"&gt;
&lt;beans&gt;
@ -2734,7 +2734,7 @@ public class FileUploadBean { @@ -2734,7 +2734,7 @@ public class FileUploadBean {
and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well
- 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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
@ -2784,7 +2784,7 @@ public class FileUploadBean { @@ -2784,7 +2784,7 @@ public class FileUploadBean {
the <emphasis>spring-context</emphasis> schema as shown in the following
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
@ -2832,7 +2832,7 @@ public class FileUploadBean { @@ -2832,7 +2832,7 @@ public class FileUploadBean {
<para>The following is an example of a form controller from the
PetClinic sample application using this annotation:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
<emphasis role="bold">@RequestMapping("/editPet.do")</emphasis>
@SessionAttributes("pet")
public class EditPetForm {
@ -2878,7 +2878,7 @@ public class EditPetForm { @@ -2878,7 +2878,7 @@ public class EditPetForm {
PetClinic sample application using
<classname>@RequestMapping</classname>:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
public class ClinicController {
private final Clinic clinic;
@ -3125,7 +3125,7 @@ public class ClinicController { @@ -3125,7 +3125,7 @@ public class ClinicController {
<para>The following code snippet from the PetClinic sample application
shows the usage:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
@RequestMapping("/editPet.do")
@SessionAttributes("pet")
public class EditPetForm {
@ -3182,7 +3182,7 @@ public class EditPetForm { @@ -3182,7 +3182,7 @@ public class EditPetForm {
<para>The following code snippet shows these two usages of this
annotation:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
@RequestMapping("/editPet.do")
@SessionAttributes("pet")
public class EditPetForm {
@ -3224,7 +3224,7 @@ public class EditPetForm { @@ -3224,7 +3224,7 @@ public class EditPetForm {
<para>The following code snippet shows the usage of this
annotation:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
@RequestMapping("/editPet.do")
<emphasis role="bold">@SessionAttributes("pet")</emphasis>
public class EditPetForm {
@ -3241,7 +3241,7 @@ 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>
<programlisting>JSESSIONID=415A4AC178C59DACE0B2C9CA727CDD84</programlisting>
<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) {
//...
@ -3266,7 +3266,7 @@ Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 @@ -3266,7 +3266,7 @@ Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
]]></programlisting>
<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,
<emphasis role="bold">@RequestHeader("Keep-Alive")</emphasis> long keepAlive) {
@ -3314,7 +3314,7 @@ Keep-Alive 300 @@ -3314,7 +3314,7 @@ Keep-Alive 300
<classname>CustomDateEditor</classname> for all
<classname>java.util.Date</classname> form properties.</para>
<programlisting>@Controller
<programlisting language="java">@Controller
public class MyFormController {
<emphasis role="bold">@InitBinder</emphasis>
@ -3346,7 +3346,7 @@ public class MyFormController { @@ -3346,7 +3346,7 @@ public class MyFormController {
which configures PropertyEditors required by several of the PetClinic
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="webBindingInitializer"&gt;
&lt;bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer" /&gt;

42
spring-framework-reference/src/portlet.xml

@ -140,7 +140,7 @@ @@ -140,7 +140,7 @@
<classname>DispatcherPortlet</classname> is declared in the
<literal>portlet.xml</literal> of your web application:</para>
<programlisting><![CDATA[<portlet>
<programlisting language="xml"><![CDATA[<portlet>
<portlet-name>sample</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<supports>
@ -353,7 +353,7 @@ @@ -353,7 +353,7 @@
<literal>web.xml</literal> file for your web application as
follows:</para>
<programlisting><![CDATA[<servlet>
<programlisting language="xml"><![CDATA[<servlet>
<servlet-name>ViewRendererServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
</servlet>
@ -407,7 +407,7 @@ @@ -407,7 +407,7 @@
<interfacename>org.springframework.web.portlet.mvc.Controller</interfacename>
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
@ -530,7 +530,7 @@ @@ -530,7 +530,7 @@
<para>Here is short example consisting of a class and a declaration
in the web application context.</para>
<programlisting><![CDATA[package samples;
<programlisting language="java"><![CDATA[package samples;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
@ -647,7 +647,7 @@ public class SampleController extends AbstractController { @@ -647,7 +647,7 @@ public class SampleController extends AbstractController {
instantiate an existing <interfacename>Portlet</interfacename> as a
<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="portletName" value="my-portlet"/>
<property name="initParameters">
@ -745,7 +745,7 @@ public class SampleController extends AbstractController { @@ -745,7 +745,7 @@ public class SampleController extends AbstractController {
based on the current mode of the portlet (e.g. ‘view’, ‘edit’,
‘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">
<map>
<entry key="view" value-ref="viewHandler"/>
@ -771,7 +771,7 @@ public class SampleController extends AbstractController { @@ -771,7 +771,7 @@ public class SampleController extends AbstractController {
<para>The bean configuration for this mapping will look something
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">
<map>
<entry key="add" value-ref="addItemHandler"/>
@ -804,7 +804,7 @@ public class SampleController extends AbstractController { @@ -804,7 +804,7 @@ public class SampleController extends AbstractController {
<para>The bean configuration for this mapping will look something
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">
<map>
<entry key="view"> ]]><lineannotation>&lt;!-- 'view' portlet mode --&gt;</lineannotation><![CDATA[
@ -992,7 +992,7 @@ public class SampleController extends AbstractController { @@ -992,7 +992,7 @@ public class SampleController extends AbstractController {
<para>The following example shows how to use the
<classname>CommonsPortletMultipartResolver</classname>:</para>
<programlisting><![CDATA[<bean id="portletMultipartResolver"
<programlisting language="xml"><![CDATA[<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver">
]]><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 { @@ -1035,7 +1035,7 @@ public class SampleController extends AbstractController {
actually let the user upload a file, we have to create a (JSP/HTML)
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">
<input type="file" name="file"/>
<input type="submit"/>
@ -1064,7 +1064,7 @@ public class SampleController extends AbstractController { @@ -1064,7 +1064,7 @@ public class SampleController extends AbstractController {
resolver, a mapping to a controller that will process the bean, and
the controller itself.</para>
<programlisting><![CDATA[<bean id="portletMultipartResolver"
<programlisting language="xml"><![CDATA[<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"/>
<bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
@ -1084,7 +1084,7 @@ public class SampleController extends AbstractController { @@ -1084,7 +1084,7 @@ public class SampleController extends AbstractController {
<para>After that, create the controller and the actual class to hold
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,
Object command, BindException errors) throws Exception {
@ -1136,7 +1136,7 @@ public class FileUploadBean { @@ -1136,7 +1136,7 @@ public class FileUploadBean {
String-typed property on a (form backing) object might look like
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,
Object command, BindException errors) throws Exception {
@ -1187,7 +1187,7 @@ public class FileUploadBean { @@ -1187,7 +1187,7 @@ public class FileUploadBean {
register any custom property editor because there is no type
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,
Object command, BindException errors) throws Exception {
@ -1273,7 +1273,7 @@ public class FileUploadBean { @@ -1273,7 +1273,7 @@ public class FileUploadBean {
and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well
- 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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
@ -1322,7 +1322,7 @@ public class FileUploadBean { @@ -1322,7 +1322,7 @@ public class FileUploadBean {
the <emphasis>spring-context</emphasis> schema as shown in the following
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
@ -1371,7 +1371,7 @@ public class FileUploadBean { @@ -1371,7 +1371,7 @@ public class FileUploadBean {
<para>The following is an example of a form controller from the
PetPortal sample application using this annotation:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
<emphasis role="bold">@RequestMapping("EDIT")</emphasis>
@SessionAttributes("site")
public class PetSitesEditController {
@ -1580,7 +1580,7 @@ public class PetSitesEditController { @@ -1580,7 +1580,7 @@ public class PetSitesEditController {
<para>The following code snippet from the PetPortal sample application
shows the usage:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
@RequestMapping("EDIT")
@SessionAttributes("site")
public class PetSitesEditController {
@ -1636,7 +1636,7 @@ public class PetSitesEditController { @@ -1636,7 +1636,7 @@ public class PetSitesEditController {
<para>The following code snippet shows these two usages of this
annotation:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
@RequestMapping("EDIT")
@SessionAttributes("site")
public class PetSitesEditController {
@ -1676,7 +1676,7 @@ public class PetSitesEditController { @@ -1676,7 +1676,7 @@ public class PetSitesEditController {
<para>The following code snippet shows the usage of this
annotation:</para>
<programlisting>@Controller
<programlisting language="java">@Controller
@RequestMapping("EDIT")
<emphasis role="bold">@SessionAttributes("site")</emphasis>
public class PetSitesEditController {
@ -1722,7 +1722,7 @@ public class PetSitesEditController { @@ -1722,7 +1722,7 @@ public class PetSitesEditController {
<classname>CustomDateEditor</classname> for all
<classname>java.util.Date</classname> form properties.</para>
<programlisting>@Controller
<programlisting language="java">@Controller
public class MyFormController {
<emphasis role="bold">@InitBinder</emphasis>

118
spring-framework-reference/src/view.xml

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
<classname>ResourceBundleViewResolver</classname>. Both are declared in the
<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">
<property name="basename" value="views"/>
</bean>
@ -50,7 +50,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -50,7 +50,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<classname>ResourceBundleViewResolver</classname> you can mix different types of views using
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="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
@ -115,7 +115,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -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
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
to use for the tags from this library.</para>
@ -137,7 +137,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -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> would look like:</para>
<programlisting>&lt;form:form&gt;
<programlisting language="xml">&lt;form:form&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt;
@ -163,7 +163,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -163,7 +163,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<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;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt;
@ -187,7 +187,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -187,7 +187,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
practice), then you can bind the form to the named variable like
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;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt;
@ -224,7 +224,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -224,7 +224,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
the <classname>Preferences</classname> class:</para>
</section>
<programlisting>public class Preferences {
<programlisting language="java">public class Preferences {
private boolean receiveNewsletter;
@ -259,7 +259,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -259,7 +259,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<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;tr&gt;
&lt;td&gt;Subscribe to newsletter?:&lt;/td&gt;
@ -318,7 +318,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -318,7 +318,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>Note that regardless of the approach, the same HTML structure is
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;
Quidditch: &lt;input name="preferences.interests" type="checkbox" value="Quidditch"/&gt;
@ -363,7 +363,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -363,7 +363,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
user. Below is an example of the JSP using this tag:</para>
</section>
<programlisting>&lt;form:form&gt;
<programlisting language="xml">&lt;form:form&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;Interests:&lt;/td&gt;
@ -391,7 +391,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -391,7 +391,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>A typical usage pattern will involve multiple tag instances bound
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;Male: &lt;form:radiobutton path="sex" value="M"/&gt; &lt;br/&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> @@ -415,7 +415,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
custom object where you can provide the property names for the value
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;&lt;form:radiobuttons path="sex" items="${sexOptions}"/&gt;&lt;/td&gt;
&lt;/tr&gt;</programlisting>
@ -427,7 +427,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></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
the bound value.</para>
<programlisting>&lt;tr&gt;
<programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Password:&lt;/td&gt;
&lt;td&gt;
&lt;form:password path="password" /&gt;
@ -439,7 +439,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -439,7 +439,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
shown, then set the value of the <literal>'showPassword'</literal>
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;
&lt;form:password path="password" value="^76525bvHGq" showPassword="true" /&gt;
@ -457,7 +457,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -457,7 +457,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>Let's assume a <classname>User</classname> has a list of
skills.</para>
<programlisting>&lt;tr&gt;
<programlisting language="xml">&lt;tr&gt;
&lt;td&gt;Skills:&lt;/td&gt;
&lt;td&gt;&lt;form:select path="skills" items="${skills}"/&gt;&lt;/td&gt;
&lt;/tr&gt;</programlisting>
@ -465,7 +465,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></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
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;&lt;select name="skills" multiple="true"&gt;
&lt;option value="Potions"&gt;Potions&lt;/option&gt;
@ -481,7 +481,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -481,7 +481,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>This tag renders an HTML 'option'. It sets 'selected' as
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;
&lt;form:select path="house"&gt;
@ -496,7 +496,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -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
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;
&lt;select name="house"&gt;
@ -515,7 +515,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -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
'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;
&lt;form:select path="country"&gt;
@ -528,7 +528,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -528,7 +528,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>If the <classname>User</classname> lived in the UK, the HTML
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;
&lt;select name="country"&gt;
@ -563,7 +563,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -563,7 +563,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<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;&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;
@ -577,13 +577,13 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -577,13 +577,13 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
bound value. To submit an unbound hidden value, use the HTML
<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>
<para>If we choose to submit the 'house' value as a hidden one, the HTML
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>
</section>
@ -600,7 +600,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -600,7 +600,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<classname>User</classname> class called
<classname>UserValidator</classname>.</para>
<programlisting>public class UserValidator implements Validator {
<programlisting language="java">public class UserValidator implements Validator {
public boolean supports(Class candidate) {
return User.class.isAssignableFrom(candidate);
@ -614,7 +614,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -614,7 +614,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<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;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt;
@ -641,7 +641,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -641,7 +641,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<literal>firstName</literal> and <literal>lastName</literal> fields,
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;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt;
@ -682,7 +682,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -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
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;table&gt;
&lt;tr&gt;
@ -705,7 +705,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -705,7 +705,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<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;table&gt;
&lt;tr&gt;
@ -779,7 +779,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -779,7 +779,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
using the <classname>TilesConfigurer</classname>. Have a look at the
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">
<list>
<value>/WEB-INF/defs/general.xml</value>
@ -808,7 +808,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -808,7 +808,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
<para>The <classname>UrlBasedViewResolver</classname> instantiates the given
<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"/>
</bean>]]></programlisting>
@ -821,11 +821,11 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting> @@ -821,11 +821,11 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]></programlisting>
property file containing viewnames and viewclasses the resolver can
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"/>
</bean>]]></programlisting>
<programlisting><![CDATA[...
<programlisting language="java"><![CDATA[...
welcomeView.class=org.springframework.web.servlet.view.tiles2.TilesView
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 @@ -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
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">
<list>
<value>/WEB-INF/defs/general.xml</value>
@ -927,7 +927,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp @@ -927,7 +927,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
<para>A suitable configuration is initialized by adding the relevant
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.
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.
@ -1003,7 +1003,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp @@ -1003,7 +1003,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
need this file, specify its location on the
<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;/bean&gt;</programlisting>
@ -1011,7 +1011,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp @@ -1011,7 +1011,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
the bean definition for the Velocity config bean by replacing the
"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">
<props>
<prop key="resource.loader">file</prop>
@ -1043,7 +1043,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp @@ -1043,7 +1043,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
<literal>freemarkerVariables</literal> property requires a
<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="freemarkerVariables">
<map>
@ -1104,7 +1104,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp @@ -1104,7 +1104,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
<literal>personFormV</literal> and <literal>personFormF</literal>
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;form action="" method="POST"&gt;
@ -1121,7 +1121,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp @@ -1121,7 +1121,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp
...
&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;
&lt;#import "spring.ftl" as spring /&gt;
&lt;html&gt;
@ -1389,7 +1389,7 @@ recommend sticking to 'spring' --&gt; @@ -1389,7 +1389,7 @@ recommend sticking to 'spring' --&gt;
<section id="views-form-macros-input">
<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:
#springFormInput("command.name" "")&lt;br&gt;
@ -1410,7 +1410,7 @@ recommend sticking to 'spring' --&gt; @@ -1410,7 +1410,7 @@ recommend sticking to 'spring' --&gt;
values for the attributes parameter, unlike Velocity, and the two
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>
<para>Output is shown below of the form fragment generating the name
@ -1500,7 +1500,7 @@ New York</programlisting> @@ -1500,7 +1500,7 @@ New York</programlisting>
for example, the map of codes would be created with suitable keys
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();
cityMap.put("LDN", "London");
cityMap.put("PRS", "Paris");
@ -1559,7 +1559,7 @@ New York</programlisting> @@ -1559,7 +1559,7 @@ New York</programlisting>
<para>In similar fashion, HTML escaping can be specified per
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;#-- next field will use HTML escaping --&gt;
@ -1598,7 +1598,7 @@ New York</programlisting> @@ -1598,7 +1598,7 @@ New York</programlisting>
dispatcher servlet config file contains a reference to a
<interfacename>ViewResolver</interfacename>, URL mappings and a single controller
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>
</section>
@ -1608,7 +1608,7 @@ New York</programlisting> @@ -1608,7 +1608,7 @@ New York</programlisting>
<para>The controller logic is encapsulated in a subclass of
<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,
HttpServletResponse response) throws Exception {
@ -1649,7 +1649,7 @@ New York</programlisting> @@ -1649,7 +1649,7 @@ New York</programlisting>
<methodname>createXsltSource(..)</methodname> method. The first parameter passed
to this method is our model map. Here's the complete listing of the
<classname>HomePage</classname> class in our trivial word application:</para>
<programlisting><![CDATA[
<programlisting language="java"><![CDATA[
package xslt;
]]><lineannotation>// imports omitted for brevity</lineannotation><![CDATA[
@ -1717,7 +1717,7 @@ home.root=words]]></programlisting> @@ -1717,7 +1717,7 @@ home.root=words]]></programlisting>
<filename>'home.xslt'</filename> and it lives in the war file in the
<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:output method="html" omit-xml-declaration="yes"/>
@ -1847,7 +1847,7 @@ pdf.class=pdf.HomePage</programlisting> <emphasis>If you want to start with a @@ -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
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
@ -1883,7 +1883,7 @@ public class HomePage extends AbstractExcelView { @@ -1883,7 +1883,7 @@ public class HomePage extends AbstractExcelView {
}
}</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
@ -1927,7 +1927,7 @@ public class HomePage extends AbstractExcelView { @@ -1927,7 +1927,7 @@ public class HomePage extends AbstractExcelView {
class extends
<literal>org.springframework.web.servlet.view.document.AbstractPdfView</literal>
and implements the <literal>buildPdfDocument()</literal> method as
follows.. <programlisting>package pdf;
follows.. <programlisting language="java">package pdf;
// imports omitted for brevity
@ -2012,7 +2012,7 @@ public class PDFPage extends AbstractPdfView { @@ -2012,7 +2012,7 @@ public class PDFPage extends AbstractPdfView {
<para>Typically, you will use the <classname>ResourceBundleViewResolver</classname>
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"/>
</bean>]]></programlisting>
@ -2117,7 +2117,7 @@ simpleReport.url=/WEB-INF/reports/DataSourceReport.jasper]]></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
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 {
String uri = request.getRequestURI();
@ -2208,7 +2208,7 @@ HttpServletResponse response) throws Exception { @@ -2208,7 +2208,7 @@ HttpServletResponse response) throws Exception {
locate this object in the model and treat it as the report datasource.
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();
Collection beanData = getBeanData();
model.put("myBeanData", beanData);
@ -2222,7 +2222,7 @@ HttpServletResponse response) throws Exception { @@ -2222,7 +2222,7 @@ HttpServletResponse response) throws Exception {
cases Spring will instances of <literal>Collection</literal> in a
<literal>JRBeanCollectionDataSource</literal> instance. For example:</para>
<programlisting><![CDATA[private Map getModel() {
<programlisting language="java"><![CDATA[private Map getModel() {
Map model = new HashMap();
Collection beanData = getBeanData();
Collection someData = getSomeData();
@ -2268,10 +2268,10 @@ simpleReport.reportDataKey=myBeanData]]></programlisting> @@ -2268,10 +2268,10 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
sub-reports from an external source. To do this you declare a
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>
<programlisting>&lt;subreport&gt;
<programlisting language="xml">&lt;subreport&gt;
&lt;reportElement isPrintRepeatedValues="false" x="5" y="25" width="325"
height="20" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/&gt;
&lt;subreportParameter name="City"&gt;
@ -2290,7 +2290,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting> @@ -2290,7 +2290,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
pass into the JasperReports engine as a sub-report using the
<literal>subReportUrls</literal> property:</para>
<programlisting><![CDATA[<property name="subReportUrls">
<programlisting language="xml"><![CDATA[<property name="subReportUrls">
<map>
<entry key="ProductsSubReport" value="/WEB-INF/reports/subReportChild.jrxml"/>
</map>
@ -2314,7 +2314,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting> @@ -2314,7 +2314,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
which of the parameters in your <literal>ModelAndView</literal> Spring
should convert. To do this configure the list of parameter names using
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
correspond to both the key used in your <literal>ModelAndView</literal>
and the key used in your report design file.</para>
@ -2335,7 +2335,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting> @@ -2335,7 +2335,7 @@ simpleReport.reportDataKey=myBeanData]]></programlisting>
entry should be the value you want to assign to the parameter. An
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="exporterParameters"&gt;
&lt;map&gt;

56
spring-framework-reference/src/web-integration.xml

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

Loading…
Cancel
Save