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