From 077d7f4bcec253a48a70ae2bc7fbe905f1b9d891 Mon Sep 17 00:00:00 2001 From: Thomas Risberg Date: Mon, 13 Apr 2009 14:27:47 +0000 Subject: [PATCH] added language element to programlisting for syntax highlighting --- spring-framework-reference/src/mvc.xml | 98 +++++++-------- spring-framework-reference/src/portlet.xml | 42 +++---- spring-framework-reference/src/view.xml | 118 +++++++++--------- .../src/web-integration.xml | 56 ++++----- 4 files changed, 157 insertions(+), 157 deletions(-) diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 5c3369b49d..4ae264f64b 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -341,7 +341,7 @@ Consider the following DispatcherServlet servlet configuration (in the 'web.xml' file.) - <web-app> + <web-app> <servlet> <servlet-name>golfing</servlet-name> @@ -613,7 +613,7 @@ org.springframework.web.servlet.mvc.Controller interface, the source code for which is listed below. - public interface Controller { + public interface Controller { /** * 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 context. - package samples; + package samples; public class SampleController extends AbstractController { @@ -745,7 +745,7 @@ public class SampleController extends AbstractController { } } - <bean id="sampleController" class="samples.SampleController"> + <bean id="sampleController" class="samples.SampleController"> <property name="cacheSeconds" value="120"/> </bean> @@ -843,18 +843,18 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer The standard signature (mirrors the Controller interface method). - public ModelAndView displayCatalog(HttpServletRequest, HttpServletResponse) + public ModelAndView displayCatalog(HttpServletRequest, HttpServletResponse) This signature accepts a Login argument that will be populated (bound) with parameters retrieved from the request. - public ModelAndView login(HttpServletRequest, HttpServletResponse, Login) + public ModelAndView login(HttpServletRequest, HttpServletResponse, Login) This signature requires that the request already have a valid session. - public ModelAndView viewCart(HttpServletRequest, HttpServletResponse, HttpSession) + public ModelAndView viewCart(HttpServletRequest, HttpServletResponse, HttpSession) This signature accepts a Product argument 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 third otherwise). - public ModelAndView updateCart(HttpServletRequest, HttpServletResponse, HttpSession, Product) + public ModelAndView updateCart(HttpServletRequest, HttpServletResponse, HttpSession, Product) This signature has a void return type indicating that the handler method assumes the responsibility of writing the response. - public void home(HttpServletRequest, HttpServletResponse) + public void home(HttpServletRequest, HttpServletResponse) This signature has a Map return 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 Map's entries (see the section entitled below). - public Map list(HttpServletRequest, HttpServletResponse) + public Map list(HttpServletRequest, HttpServletResponse) The MethodNameResolver is responsible for resolving method names based on the specifics of the @@ -944,13 +944,13 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer Exception. Here is an example signature for one such Exception handling method. - public ModelAndView processException(HttpServletRequest, HttpServletResponse, IllegalArgumentException) + public ModelAndView processException(HttpServletRequest, HttpServletResponse, IllegalArgumentException) Let's look at an example showing the delegate-style of MultiActionController usage in conjunction with the ParameterMethodNameResolver. - <bean id="paramMultiController" + <bean id="paramMultiController" class="org.springframework.web.servlet.mvc.multiaction.MultiActionController"> <property name="methodNameResolver"> @@ -966,7 +966,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer </bean> } - public class SampleDelegate { + 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 PropertiesMethodNameResolver to match any number couple of URLs to the method we defined: - <bean id="propsResolver" + <bean id="propsResolver" class="org....mvc.multiaction.PropertiesMethodNameResolver"> <property name="mappings"> <value> @@ -1204,7 +1204,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer appropriate form Controller as follows: - <beans> + <beans> <bean id="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> <bean name="/editaccount.form" class="org.springframework.web.servlet.mvc.SimpleFormController"> @@ -1222,7 +1222,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer web.xml as well, to let through all the requests ending with .form. - <web-app> + <web-app> ... <servlet> <servlet-name>sample</servlet-name> @@ -1258,7 +1258,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer org.springframework.util.PathMatcher class). Here is an example: - <web-app> + <web-app> ... <servlet> <servlet-name>sample</servlet-name> @@ -1284,7 +1284,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer all requests ending with .html and .form to be handled by the sample dispatcher servlet. - <beans> + <beans> <!-- no 'id' required, HandlerMapping beans are automatically detected by the DispatcherServlet --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> @@ -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. - <beans> + <beans> <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> @@ -1377,7 +1377,7 @@ public [ModelAndView | Map | void] anyMeaningfulName(HttpServletRequest, HttpSer </bean> <beans> - package samples; + package samples; 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. - <bean id="viewResolver" + <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> @@ -1557,7 +1557,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { When mixing different view technologies in a web application, you can use the ResourceBundleViewResolver: - <bean id="viewResolver" + <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <property name="basename" value="views"/> <property name="defaultParentView" value="parentView"/> @@ -1601,7 +1601,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { Excel views (which are not supported by the InternalResourceViewResolver): - <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> + <bean id="jspViewResolver" 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"/> @@ -1801,7 +1801,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { below an example of defining a CookieLocaleResolver. - <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"> + <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"> <property name="cookieName" value="clientlanguage"/> @@ -1884,7 +1884,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { on the LocaleResolver that also exists in the context). - <bean id="localeChangeInterceptor" + <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="siteLanguage"/> </bean> @@ -1959,7 +1959,7 @@ background=/themes/cool/img/coolBg.jpg fragment uses the theme defined above to customize the look and feel: - <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> + <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <html> <head> <link rel="stylesheet" href="<spring:theme code="styleSheet"/>" type="text/css"/> @@ -2079,7 +2079,7 @@ background=/themes/cool/img/coolBg.jpg The following example shows how to use the CommonsMultipartResolver: - <bean id="multipartResolver" + <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- one of the properties available; the maximum file size in bytes --> @@ -2089,7 +2089,7 @@ background=/themes/cool/img/coolBg.jpg This is an example using the CosMultipartResolver: - <bean id="multipartResolver" class="org.springframework.web.multipart.cos.CosMultipartResolver"> + <bean id="multipartResolver" class="org.springframework.web.multipart.cos.CosMultipartResolver"> <!-- one of the properties available; the maximum file size in bytes --> <property name="maxUploadSize" value="100000"/> @@ -2124,7 +2124,7 @@ background=/themes/cool/img/coolBg.jpg Spring bind the file onto your form (backing object). To actually let the user upload a file, we have to create a (HTML) form: - <html> + <html> <head> <title>Upload a file please</title> </head> @@ -2159,7 +2159,7 @@ background=/themes/cool/img/coolBg.jpg resolver, a url mapping to a controller that will process the bean, and the controller itself. - <beans> + <beans> <!-- lets use the Commons-based implementation of the MultipartResolver interface --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/> @@ -2183,7 +2183,7 @@ background=/themes/cool/img/coolBg.jpg After that, create the controller and the actual class to hold the file property. - public class FileUploadController extends SimpleFormController { + 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 { An equivalent example in which a file is bound straight to a String-typed property on a (form backing) object might look like: - public class FileUploadController extends SimpleFormController { + 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 { register any custom PropertyEditor because there is no type conversion to be performed. - public class FileUploadController extends SimpleFormController { + 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 { Controller implementation. Take especial notice of the name of the class. - public class ViewShoppingCartController implements Controller { + public class ViewShoppingCartController implements Controller { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { // the implementation is not hugely important for this example... @@ -2389,7 +2389,7 @@ public class FileUploadBean { Here is a snippet from the attendent Spring Web MVC configuration file... - <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> + <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> <bean id="viewShoppingCart" class="x.y.z.ViewShoppingCartController"> <!-- inject dependencies as required... --> @@ -2484,7 +2484,7 @@ public class FileUploadBean { objects are added to the ModelAndView without any associated name being specified. - public class DisplayShoppingCartController implements Controller { + public class DisplayShoppingCartController implements Controller { 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 explained by recourse to an example. - public class RegistrationController implements Controller { + public class RegistrationController implements Controller { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { // process the request... @@ -2623,7 +2623,7 @@ public class FileUploadBean { } } - <?xml version="1.0" encoding="UTF-8"?> + <?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"> <beans> @@ -2734,7 +2734,7 @@ public class FileUploadBean { and/or AnnotationMethodHandlerAdapter is defined as well - provided that you intend to use @RequestMapping. - <?xml version="1.0" encoding="UTF-8"?> + <?xml version="1.0" encoding="UTF-8"?> <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 { the spring-context schema as shown in the following XML snippet: - <?xml version="1.0" encoding="UTF-8"?> + <?xml version="1.0" encoding="UTF-8"?> <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 { The following is an example of a form controller from the PetClinic sample application using this annotation: - @Controller + @Controller @RequestMapping("/editPet.do") @SessionAttributes("pet") public class EditPetForm { @@ -2878,7 +2878,7 @@ public class EditPetForm { PetClinic sample application using @RequestMapping: - @Controller + @Controller public class ClinicController { private final Clinic clinic; @@ -3125,7 +3125,7 @@ public class ClinicController { The following code snippet from the PetClinic sample application shows the usage: - @Controller + @Controller @RequestMapping("/editPet.do") @SessionAttributes("pet") public class EditPetForm { @@ -3182,7 +3182,7 @@ public class EditPetForm { The following code snippet shows these two usages of this annotation: - @Controller + @Controller @RequestMapping("/editPet.do") @SessionAttributes("pet") public class EditPetForm { @@ -3224,7 +3224,7 @@ public class EditPetForm { The following code snippet shows the usage of this annotation: - @Controller + @Controller @RequestMapping("/editPet.do") @SessionAttributes("pet") public class EditPetForm { @@ -3241,7 +3241,7 @@ public class EditPetForm { Let us consider that the following cookie has been received with an http request: JSESSIONID=415A4AC178C59DACE0B2C9CA727CDD84 The following code sample allows you to easily get the value of the "JSESSIONID"cookie: - @RequestMapping("/displayHeaderInfo.do") + @RequestMapping("/displayHeaderInfo.do") public void displayHeaderInfo(@CookieValue("JSESSIONID") String cookie) { //... @@ -3266,7 +3266,7 @@ Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 ]]> The following code sample allows you to easily get the value of the "Accept-Encoding" and "Keep-Alive" headers: - @RequestMapping("/displayHeaderInfo.do") + @RequestMapping("/displayHeaderInfo.do") public void displayHeaderInfo(@RequestHeader("Accept-Encoding") String encoding, @RequestHeader("Keep-Alive") long keepAlive) { @@ -3314,7 +3314,7 @@ Keep-Alive 300 CustomDateEditor for all java.util.Date form properties. - @Controller + @Controller public class MyFormController { @InitBinder @@ -3346,7 +3346,7 @@ public class MyFormController { which configures PropertyEditors required by several of the PetClinic controllers. - <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> + <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="cacheSeconds" value="0" /> <property name="webBindingInitializer"> <bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer" /> diff --git a/spring-framework-reference/src/portlet.xml b/spring-framework-reference/src/portlet.xml index 57df1bed24..8fdca5371f 100644 --- a/spring-framework-reference/src/portlet.xml +++ b/spring-framework-reference/src/portlet.xml @@ -140,7 +140,7 @@ DispatcherPortlet is declared in the portlet.xml of your web application: - + sample org.springframework.web.portlet.DispatcherPortlet @@ -353,7 +353,7 @@ web.xml file for your web application as follows: - + ViewRendererServlet org.springframework.web.servlet.ViewRendererServlet @@ -407,7 +407,7 @@ org.springframework.web.portlet.mvc.Controller interface, which is listed below. - Here is short example consisting of a class and a declaration in the web application context. - Portlet as a Controller as follows: - + @@ -745,7 +745,7 @@ public class SampleController extends AbstractController { based on the current mode of the portlet (e.g. ‘view’, ‘edit’, ‘help’). An example: - + @@ -771,7 +771,7 @@ public class SampleController extends AbstractController { The bean configuration for this mapping will look something like this: - + @@ -804,7 +804,7 @@ public class SampleController extends AbstractController { The bean configuration for this mapping will look something like this: - + ]]><!-- 'view' portlet mode -->The following example shows how to use the CommonsPortletMultipartResolver: - ]]><!-- one of the properties available; the maximum file size in bytes --> - Please upload a file + Please upload a file
@@ -1064,7 +1064,7 @@ public class SampleController extends AbstractController { resolver, a mapping to a controller that will process the bean, and the controller itself. - @@ -1084,7 +1084,7 @@ public class SampleController extends AbstractController { After that, create the controller and the actual class to hold the file property. - - - AnnotationMethodHandlerAdapter is defined as well - provided that you intend to use @RequestMapping. - <?xml version="1.0" encoding="UTF-8"?> + <?xml version="1.0" encoding="UTF-8"?> <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 { the spring-context schema as shown in the following XML snippet: - <?xml version="1.0" encoding="UTF-8"?> + <?xml version="1.0" encoding="UTF-8"?> <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 { The following is an example of a form controller from the PetPortal sample application using this annotation: - @Controller + @Controller @RequestMapping("EDIT") @SessionAttributes("site") public class PetSitesEditController { @@ -1580,7 +1580,7 @@ public class PetSitesEditController { The following code snippet from the PetPortal sample application shows the usage: - @Controller + @Controller @RequestMapping("EDIT") @SessionAttributes("site") public class PetSitesEditController { @@ -1636,7 +1636,7 @@ public class PetSitesEditController { The following code snippet shows these two usages of this annotation: - @Controller + @Controller @RequestMapping("EDIT") @SessionAttributes("site") public class PetSitesEditController { @@ -1676,7 +1676,7 @@ public class PetSitesEditController { The following code snippet shows the usage of this annotation: - @Controller + @Controller @RequestMapping("EDIT") @SessionAttributes("site") public class PetSitesEditController { @@ -1722,7 +1722,7 @@ public class PetSitesEditController { CustomDateEditor for all java.util.Date form properties. - @Controller + @Controller public class MyFormController { @InitBinder diff --git a/spring-framework-reference/src/view.xml b/spring-framework-reference/src/view.xml index 626792f37d..ba4ab4f427 100644 --- a/spring-framework-reference/src/view.xml +++ b/spring-framework-reference/src/view.xml @@ -33,7 +33,7 @@ ResourceBundleViewResolver. Both are declared in the WebApplicationContext: - <!-- the ResourceBundleViewResolver --><!-- the ResourceBundleViewResolver --> @@ -50,7 +50,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> ResourceBundleViewResolver you can mix different types of views using only one resolver. - + @@ -115,7 +115,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> To use the tags from this library, add the following directive to the top of your JSP page: - <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> + <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> ... where form is the tag name prefix you want to use for the tags from this library. @@ -137,7 +137,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> form.jsp. Below is an example of what form.jsp would look like: - <form:form> + <form:form> <table> <tr> <td>First Name:</td> @@ -163,7 +163,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> The generated HTML looks like a standard form: - <form method="POST"> + <form method="POST"> <table> <tr> <td>First Name:</td> @@ -187,7 +187,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> practice), then you can bind the form to the named variable like so: - <form:form commandName="user"> + <form:form commandName="user"> <table> <tr> <td>First Name:</td> @@ -224,7 +224,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> the Preferences class: - public class Preferences { + public class Preferences { private boolean receiveNewsletter; @@ -259,7 +259,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> The form.jsp would look like: - <form:form> + <form:form> <table> <tr> <td>Subscribe to newsletter?:</td> @@ -318,7 +318,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> Note that regardless of the approach, the same HTML structure is generated. Below is an HTML snippet of some checkboxes: - <tr> + <tr> <td>Interests:</td> <td> Quidditch: <input name="preferences.interests" type="checkbox" value="Quidditch"/> @@ -363,7 +363,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> user. Below is an example of the JSP using this tag: - <form:form> + <form:form> <table> <tr> <td>Interests:</td> @@ -391,7 +391,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> A typical usage pattern will involve multiple tag instances bound to the same property but with different values. - <tr> + <tr> <td>Sex:</td> <td>Male: <form:radiobutton path="sex" value="M"/> <br/> Female: <form:radiobutton path="sex" value="F"/> </td> @@ -415,7 +415,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> custom object where you can provide the property names for the value using "itemValue" and the label using "itemLabel". - <tr> + <tr> <td>Sex:</td> <td><form:radiobuttons path="sex" items="${sexOptions}"/></td> </tr> @@ -427,7 +427,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> This tag renders an HTML 'input' tag with type 'password' using the bound value. - <tr> + <tr> <td>Password:</td> <td> <form:password path="password" /> @@ -439,7 +439,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> shown, then set the value of the 'showPassword' attribute to true, like so. - <tr> + <tr> <td>Password:</td> <td> <form:password path="password" value="^76525bvHGq" showPassword="true" /> @@ -457,7 +457,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> Let's assume a User has a list of skills. - <tr> + <tr> <td>Skills:</td> <td><form:select path="skills" items="${skills}"/></td> </tr> @@ -465,7 +465,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> If the User's skill were in Herbology, the HTML source of the 'Skills' row would look like: - <tr> + <tr> <td>Skills:</td> <td><select name="skills" multiple="true"> <option value="Potions">Potions</option> @@ -481,7 +481,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> This tag renders an HTML 'option'. It sets 'selected' as appropriate based on the bound value. - <tr> + <tr> <td>House:</td> <td> <form:select path="house"> @@ -496,7 +496,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> If the User's house was in Gryffindor, the HTML source of the 'House' row would look like: - <tr> + <tr> <td>House:</td> <td> <select name="house"> @@ -515,7 +515,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> This tag renders a list of HTML 'option' tags. It sets the 'selected' attribute as appropriate based on the bound value. - <tr> + <tr> <td>Country:</td> <td> <form:select path="country"> @@ -528,7 +528,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> If the User lived in the UK, the HTML source of the 'Country' row would look like: - <tr> + <tr> <td>Country:</td> <td> <select name="country"> @@ -563,7 +563,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> This tag renders an HTML 'textarea'. - <tr> + <tr> <td>Notes:</td> <td><form:textarea path="notes" rows="3" cols="20" /></td> <td><form:errors path="notes" /></td> @@ -577,13 +577,13 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> bound value. To submit an unbound hidden value, use the HTML input tag with type 'hidden'. - <form:hidden path="house" /> + <form:hidden path="house" /> If we choose to submit the 'house' value as a hidden one, the HTML would look like: - <input name="house" type="hidden" value="Gryffindor"/> + <input name="house" type="hidden" value="Gryffindor"/> @@ -600,7 +600,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> User class called UserValidator. - public class UserValidator implements Validator { + 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]]> The form.jsp would look like: - <form:form> + <form:form> <table> <tr> <td>First Name:</td> @@ -641,7 +641,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> firstName and lastName fields, this is what the HTML would look like: - <form method="POST"> + <form method="POST"> <table> <tr> <td>First Name:</td> @@ -682,7 +682,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> The example below will display a list of errors at the top of the page, followed by field-specific errors next to the fields: - <form:form> + <form:form> <form:errors path="*" cssClass="errorBox" /> <table> <tr> @@ -705,7 +705,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> The HTML would look like: - <form method="POST"> + <form method="POST"> <span name="*.errors" class="errorBox">Field is required.<br/>Field is required.</span> <table> <tr> @@ -779,7 +779,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> using the TilesConfigurer. Have a look at the following piece of example ApplicationContext configuration: - + /WEB-INF/defs/general.xml @@ -808,7 +808,7 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> The UrlBasedViewResolver instantiates the given viewClass for each view it has to resolve. - + ]]> @@ -821,11 +821,11 @@ productList.url=/WEB-INF/jsp/productlist.jsp]]> property file containing viewnames and viewclasses the resolver can use: - + ]]> - (this is the name of a Tiles definition) - + /WEB-INF/defs/general.xml @@ -927,7 +927,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp A suitable configuration is initialized by adding the relevant configurer bean definition to your '*-servlet.xml' as shown below: - <!-- + <!-- 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 need this file, specify its location on the VelocityConfigurer bean definition above. - <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> + <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="configLocation value="/WEB-INF/velocity.properties"/> </bean> @@ -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. - + file @@ -1043,7 +1043,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp freemarkerVariables property requires a java.util.Map. - + @@ -1104,7 +1104,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp personFormV and personFormF views configured earlier; - <!-- velocity macros are automatically available --> + <!-- velocity macros are automatically available --> <html> ... <form action="" method="POST"> @@ -1121,7 +1121,7 @@ findOwnersForm.url=/WEB-INF/jsp/findOwners.jsp ... </html> - <!-- freemarker macros have to be imported into a namespace. We strongly + <!-- freemarker macros have to be imported into a namespace. We strongly recommend sticking to 'spring' --> <#import "spring.ftl" as spring /> <html> @@ -1389,7 +1389,7 @@ recommend sticking to 'spring' -->
Input Fields - <!-- the Name field example from above using form macros in VTL --> + <!-- the Name field example from above using form macros in VTL --> ... Name: #springFormInput("command.name" "")<br> @@ -1410,7 +1410,7 @@ recommend sticking to 'spring' --> values for the attributes parameter, unlike Velocity, and the two macro calls above could be expressed as follows in FTL: - <@spring.formInput "command.name"/> + <@spring.formInput "command.name"/> <@spring.showErrors "<br>"/> Output is shown below of the form fragment generating the name @@ -1500,7 +1500,7 @@ New York for example, the map of codes would be created with suitable keys like the example below. - protected Map referenceData(HttpServletRequest request) throws Exception { + 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 In similar fashion, HTML escaping can be specified per field: - <#-- until this point, default HTML escaping is used --> + <#-- until this point, default HTML escaping is used --> <#assign htmlEscape = true in spring> <#-- next field will use HTML escaping --> @@ -1598,7 +1598,7 @@ New York dispatcher servlet config file contains a reference to a ViewResolver, URL mappings and a single controller bean... - ]]> + ]]> ... that encapsulates our word generation logic.
@@ -1608,7 +1608,7 @@ New York
The controller logic is encapsulated in a subclass of AbstractController, with the handler method being defined like so... - createXsltSource(..) method. The first parameter passed to this method is our model map. Here's the complete listing of the HomePage class in our trivial word application: - // imports omitted for brevity 'home.xslt' and it lives in the war file in the 'WEB-INF/xsl' directory. - + @@ -1847,7 +1847,7 @@ pdf.class=pdf.HomePage If you want to start with a 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.. package excel; + column of a new spreadsheet.. package excel; // imports omitted for brevity @@ -1883,7 +1883,7 @@ public class HomePage extends AbstractExcelView { } } - And this a view generating the same Excel file, now using JExcelApi: package excel; + And this a view generating the same Excel file, now using JExcelApi: package excel; // imports omitted for brevity @@ -1927,7 +1927,7 @@ public class HomePage extends AbstractExcelView { class extends org.springframework.web.servlet.view.document.AbstractPdfView and implements the buildPdfDocument() method as - follows.. package pdf; + follows.. package pdf; // imports omitted for brevity @@ -2012,7 +2012,7 @@ public class PDFPage extends AbstractPdfView { Typically, you will use the ResourceBundleViewResolver to map view names to view classes and files in a properties file. - + ]]> @@ -2117,7 +2117,7 @@ simpleReport.url=/WEB-INF/reports/DataSourceReport.jasper]]> entry to your model with the formay key as the key and the mapping key as the value, for example: - - Collection in a JRBeanCollectionDataSource instance. For example: - sub-reports from an external source. To do this you declare a parameter in your report file like so: - ]]> + ]]> Then, you define your sub-report to use this sub-report parameter: - <subreport> + <subreport> <reportElement isPrintRepeatedValues="false" x="5" y="25" width="325" height="20" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/> <subreportParameter name="City"> @@ -2290,7 +2290,7 @@ simpleReport.reportDataKey=myBeanData]]> pass into the JasperReports engine as a sub-report using the subReportUrls property: - + @@ -2314,7 +2314,7 @@ simpleReport.reportDataKey=myBeanData]]> which of the parameters in your ModelAndView Spring should convert. To do this configure the list of parameter names using the subReportDataKeys property of the your chosen - view class: <property name="subReportDataKeys" + view class: <property name="subReportDataKeys" value="SubReportData"/> Here, the key you supply MUST correspond to both the key used in your ModelAndView and the key used in your report design file. @@ -2335,7 +2335,7 @@ simpleReport.reportDataKey=myBeanData]]> entry should be the value you want to assign to the parameter. An example of this is shown below: - <bean id="htmlReport" class="org.springframework.web.servlet.view.jasperreports.JasperReportsHtmlView"> + <bean id="htmlReport" class="org.springframework.web.servlet.view.jasperreports.JasperReportsHtmlView"> <property name="url" value="/WEB-INF/reports/simpleReport.jrxml"/> <property name="exporterParameters"> <map> diff --git a/spring-framework-reference/src/web-integration.xml b/spring-framework-reference/src/web-integration.xml index d67de6fe4f..6e842f858c 100644 --- a/spring-framework-reference/src/web-integration.xml +++ b/spring-framework-reference/src/web-integration.xml @@ -88,7 +88,7 @@ Find below the <listener/> configuration: - + org.springframework.web.context.ContextLoaderListener ]]> @@ -102,7 +102,7 @@ Find below the <context-param/> configuration: - + contextConfigLocation /WEB-INF/applicationContext*.xml ]]> @@ -121,7 +121,7 @@ ApplicationContext created by the ContextLoaderListener. - + The WebApplicationContextUtils class is for convenience, so you don't have to remember the name of the @@ -188,7 +188,7 @@ element and a <variable-resolver/> element within it. The value of the variable resolver should reference Spring's DelegatingVariableResolver; for example: - + org.springframework.web.jsf.DelegatingVariableResolver @@ -210,7 +210,7 @@ file. Find below an example where #{userManager} is a bean that is retrieved from the Spring 'business context'. - + userList com.whatever.jsf.UserList request @@ -235,7 +235,7 @@ Configuration-wise, simply define SpringBeanVariableResolver in your faces-context.xml file: - + org.springframework.web.jsf.SpringBeanVariableResolver ... @@ -257,7 +257,7 @@ Configuration-wise, simply define SpringBeanFacesELResolver in your JSF 1.2 faces-context.xml file: - + org.springframework.web.jsf.el.SpringBeanFacesELResolver ... @@ -276,7 +276,7 @@ takes a FacesContext parameter rather than a ServletContext parameter. - + @@ -344,12 +344,12 @@ To configure this plug-in, add the following XML to the plug-ins section near the bottom of your struts-config.xml file: - ]]> + ]]> The location of the context configuration files can be customized using the 'contextConfigLocation' property. - + ]]> @@ -389,12 +389,12 @@ action-mapping's "path" and the bean's "name". If you have the following in your struts-config.xml file: - ]]> + ]]> You must define that Action's bean with the "/users" name in action-servlet.xml: - ]]> + ]]>
DelegatingRequestProcessor @@ -404,7 +404,7 @@ property in the <controller> element. These lines follow the <action-mapping> element. - + ]]> @@ -414,7 +414,7 @@ you don't even need to specify a type. Both of the following snippets will work: - + ]]> If you're using Struts' modules feature, @@ -442,7 +442,7 @@ DelegatingActionProxy as the type in your action-mapping. - @@ -459,7 +459,7 @@ Action instance for each request. To activate the latter, add scope="prototype" to your Action's bean definition. - ]]>
@@ -480,7 +480,7 @@ convenience methods, like getWebApplicationContext(). Below is an example of how you might use this in an Action: - - + @@ -703,7 +703,7 @@ a page to get an instance of the UserService, for example, would be with code such as: - ... some code which uses UserService @@ -744,7 +744,7 @@ UserService userService = (UserService) appContext.getBean("userService"); directly. One way is by defining a custom version of the Tapestry IEngine which exposes this for us: - - file: xportal.application:file: xportal.application: ApplicationContext, and create page or component properties for them. For example: - global.appContext.getBean("userService") @@ -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: - + @@ -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). - @@ -865,7 +865,7 @@ public abstract AuthenticationService getAuthenticationService();]]> - authenticationService objects (lots of the class definition has been elided for clarity)... - ServletContext as a HiveMind service; for example: - + .page or .jwc file for the Login page (or component): - + ]]> -- GitLab