提交 077d7f4b 编写于 作者: T Thomas Risberg

added language element to programlisting for syntax highlighting

上级 f4b4f28f
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
<classname>DispatcherPortlet</classname> is declared in the <classname>DispatcherPortlet</classname> is declared in the
<literal>portlet.xml</literal> of your web application:</para> <literal>portlet.xml</literal> of your web application:</para>
<programlisting><![CDATA[<portlet> <programlisting language="xml"><![CDATA[<portlet>
<portlet-name>sample</portlet-name> <portlet-name>sample</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class> <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<supports> <supports>
...@@ -353,7 +353,7 @@ ...@@ -353,7 +353,7 @@
<literal>web.xml</literal> file for your web application as <literal>web.xml</literal> file for your web application as
follows:</para> follows:</para>
<programlisting><![CDATA[<servlet> <programlisting language="xml"><![CDATA[<servlet>
<servlet-name>ViewRendererServlet</servlet-name> <servlet-name>ViewRendererServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class> <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
</servlet> </servlet>
...@@ -407,7 +407,7 @@ ...@@ -407,7 +407,7 @@
<interfacename>org.springframework.web.portlet.mvc.Controller</interfacename> <interfacename>org.springframework.web.portlet.mvc.Controller</interfacename>
interface, which is listed below.</para> interface, which is listed below.</para>
<programlisting><![CDATA[public interface Controller { <programlisting language="java"><![CDATA[public interface Controller {
/** /**
* Process the render request and return a ModelAndView object which the * Process the render request and return a ModelAndView object which the
...@@ -530,7 +530,7 @@ ...@@ -530,7 +530,7 @@
<para>Here is short example consisting of a class and a declaration <para>Here is short example consisting of a class and a declaration
in the web application context.</para> in the web application context.</para>
<programlisting><![CDATA[package samples; <programlisting language="java"><![CDATA[package samples;
import javax.portlet.RenderRequest; import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse; import javax.portlet.RenderResponse;
...@@ -647,7 +647,7 @@ public class SampleController extends AbstractController { ...@@ -647,7 +647,7 @@ public class SampleController extends AbstractController {
instantiate an existing <interfacename>Portlet</interfacename> as a instantiate an existing <interfacename>Portlet</interfacename> as a
<interfacename>Controller</interfacename> as follows:</para> <interfacename>Controller</interfacename> as follows:</para>
<programlisting><![CDATA[<bean id="myPortlet" class="org.springframework.web.portlet.mvc.PortletWrappingController"> <programlisting language="xml"><![CDATA[<bean id="myPortlet" class="org.springframework.web.portlet.mvc.PortletWrappingController">
<property name="portletClass" value="sample.MyPortlet"/> <property name="portletClass" value="sample.MyPortlet"/>
<property name="portletName" value="my-portlet"/> <property name="portletName" value="my-portlet"/>
<property name="initParameters"> <property name="initParameters">
...@@ -745,7 +745,7 @@ public class SampleController extends AbstractController { ...@@ -745,7 +745,7 @@ public class SampleController extends AbstractController {
based on the current mode of the portlet (e.g. ‘view’, ‘edit’, based on the current mode of the portlet (e.g. ‘view’, ‘edit’,
‘help’). An example:</para> ‘help’). An example:</para>
<programlisting><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <programlisting language="xml"><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="portletModeMap"> <property name="portletModeMap">
<map> <map>
<entry key="view" value-ref="viewHandler"/> <entry key="view" value-ref="viewHandler"/>
...@@ -771,7 +771,7 @@ public class SampleController extends AbstractController { ...@@ -771,7 +771,7 @@ public class SampleController extends AbstractController {
<para>The bean configuration for this mapping will look something <para>The bean configuration for this mapping will look something
like this:</para> like this:</para>
<programlisting><![CDATA[<bean class="org.springframework.web.portlet.handler.ParameterHandlerMapping”> <programlisting language="xml"><![CDATA[<bean class="org.springframework.web.portlet.handler.ParameterHandlerMapping”>
<property name="parameterMap"> <property name="parameterMap">
<map> <map>
<entry key="add" value-ref="addItemHandler"/> <entry key="add" value-ref="addItemHandler"/>
...@@ -804,7 +804,7 @@ public class SampleController extends AbstractController { ...@@ -804,7 +804,7 @@ public class SampleController extends AbstractController {
<para>The bean configuration for this mapping will look something <para>The bean configuration for this mapping will look something
like this:</para> like this:</para>
<programlisting><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> <programlisting language="xml"><![CDATA[<bean class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping">
<property name="portletModeParameterMap"> <property name="portletModeParameterMap">
<map> <map>
<entry key="view"> ]]><lineannotation>&lt;!-- 'view' portlet mode --&gt;</lineannotation><![CDATA[ <entry key="view"> ]]><lineannotation>&lt;!-- 'view' portlet mode --&gt;</lineannotation><![CDATA[
...@@ -992,7 +992,7 @@ public class SampleController extends AbstractController { ...@@ -992,7 +992,7 @@ public class SampleController extends AbstractController {
<para>The following example shows how to use the <para>The following example shows how to use the
<classname>CommonsPortletMultipartResolver</classname>:</para> <classname>CommonsPortletMultipartResolver</classname>:</para>
<programlisting><![CDATA[<bean id="portletMultipartResolver" <programlisting language="xml"><![CDATA[<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"> class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver">
]]><lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation><![CDATA[ ]]><lineannotation>&lt;!-- one of the properties available; the maximum file size in bytes --&gt;</lineannotation><![CDATA[
...@@ -1035,7 +1035,7 @@ public class SampleController extends AbstractController { ...@@ -1035,7 +1035,7 @@ public class SampleController extends AbstractController {
actually let the user upload a file, we have to create a (JSP/HTML) actually let the user upload a file, we have to create a (JSP/HTML)
form:</para> form:</para>
<programlisting><![CDATA[<h1>Please upload a file</h1> <programlisting language="xml"><![CDATA[<h1>Please upload a file</h1>
<form method="post" action="<portlet:actionURL/>" enctype="multipart/form-data"> <form method="post" action="<portlet:actionURL/>" enctype="multipart/form-data">
<input type="file" name="file"/> <input type="file" name="file"/>
<input type="submit"/> <input type="submit"/>
...@@ -1064,7 +1064,7 @@ public class SampleController extends AbstractController { ...@@ -1064,7 +1064,7 @@ public class SampleController extends AbstractController {
resolver, a mapping to a controller that will process the bean, and resolver, a mapping to a controller that will process the bean, and
the controller itself.</para> the controller itself.</para>
<programlisting><![CDATA[<bean id="portletMultipartResolver" <programlisting language="xml"><![CDATA[<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"/> class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"/>
<bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <bean class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
...@@ -1084,7 +1084,7 @@ public class SampleController extends AbstractController { ...@@ -1084,7 +1084,7 @@ public class SampleController extends AbstractController {
<para>After that, create the controller and the actual class to hold <para>After that, create the controller and the actual class to hold
the file property.</para> the file property.</para>
<programlisting><![CDATA[public class FileUploadController extends SimpleFormController { <programlisting language="java"><![CDATA[public class FileUploadController extends SimpleFormController {
public void onSubmitAction(ActionRequest request, ActionResponse response, public void onSubmitAction(ActionRequest request, ActionResponse response,
Object command, BindException errors) throws Exception { Object command, BindException errors) throws Exception {
...@@ -1136,7 +1136,7 @@ public class FileUploadBean { ...@@ -1136,7 +1136,7 @@ public class FileUploadBean {
String-typed property on a (form backing) object might look like String-typed property on a (form backing) object might look like
this:</para> this:</para>
<programlisting><![CDATA[public class FileUploadController extends SimpleFormController { <programlisting language="java"><![CDATA[public class FileUploadController extends SimpleFormController {
public void onSubmitAction(ActionRequest request, ActionResponse response, public void onSubmitAction(ActionRequest request, ActionResponse response,
Object command, BindException errors) throws Exception { Object command, BindException errors) throws Exception {
...@@ -1187,7 +1187,7 @@ public class FileUploadBean { ...@@ -1187,7 +1187,7 @@ public class FileUploadBean {
register any custom property editor because there is no type register any custom property editor because there is no type
conversion to be performed.</para> conversion to be performed.</para>
<programlisting><![CDATA[public class FileUploadController extends SimpleFormController { <programlisting language="java"><![CDATA[public class FileUploadController extends SimpleFormController {
public void onSubmitAction(ActionRequest request, ActionResponse response, public void onSubmitAction(ActionRequest request, ActionResponse response,
Object command, BindException errors) throws Exception { Object command, BindException errors) throws Exception {
...@@ -1273,7 +1273,7 @@ public class FileUploadBean { ...@@ -1273,7 +1273,7 @@ public class FileUploadBean {
and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well and/or <classname>AnnotationMethodHandlerAdapter</classname> is defined as well
- provided that you intend to use <interfacename>@RequestMapping</interfacename>.</para> - provided that you intend to use <interfacename>@RequestMapping</interfacename>.</para>
<programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans" &lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans xsi:schemaLocation="http://www.springframework.org/schema/beans
...@@ -1322,7 +1322,7 @@ public class FileUploadBean { ...@@ -1322,7 +1322,7 @@ public class FileUploadBean {
the <emphasis>spring-context</emphasis> schema as shown in the following the <emphasis>spring-context</emphasis> schema as shown in the following
XML snippet:</para> XML snippet:</para>
<programlisting>&lt;?xml version="1.0" encoding="UTF-8"?&gt; <programlisting language="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans" &lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:p="http://www.springframework.org/schema/p"
...@@ -1371,7 +1371,7 @@ public class FileUploadBean { ...@@ -1371,7 +1371,7 @@ public class FileUploadBean {
<para>The following is an example of a form controller from the <para>The following is an example of a form controller from the
PetPortal sample application using this annotation:</para> PetPortal sample application using this annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
<emphasis role="bold">@RequestMapping("EDIT")</emphasis> <emphasis role="bold">@RequestMapping("EDIT")</emphasis>
@SessionAttributes("site") @SessionAttributes("site")
public class PetSitesEditController { public class PetSitesEditController {
...@@ -1580,7 +1580,7 @@ public class PetSitesEditController { ...@@ -1580,7 +1580,7 @@ public class PetSitesEditController {
<para>The following code snippet from the PetPortal sample application <para>The following code snippet from the PetPortal sample application
shows the usage:</para> shows the usage:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("EDIT") @RequestMapping("EDIT")
@SessionAttributes("site") @SessionAttributes("site")
public class PetSitesEditController { public class PetSitesEditController {
...@@ -1636,7 +1636,7 @@ public class PetSitesEditController { ...@@ -1636,7 +1636,7 @@ public class PetSitesEditController {
<para>The following code snippet shows these two usages of this <para>The following code snippet shows these two usages of this
annotation:</para> annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("EDIT") @RequestMapping("EDIT")
@SessionAttributes("site") @SessionAttributes("site")
public class PetSitesEditController { public class PetSitesEditController {
...@@ -1676,7 +1676,7 @@ public class PetSitesEditController { ...@@ -1676,7 +1676,7 @@ public class PetSitesEditController {
<para>The following code snippet shows the usage of this <para>The following code snippet shows the usage of this
annotation:</para> annotation:</para>
<programlisting>@Controller <programlisting language="java">@Controller
@RequestMapping("EDIT") @RequestMapping("EDIT")
<emphasis role="bold">@SessionAttributes("site")</emphasis> <emphasis role="bold">@SessionAttributes("site")</emphasis>
public class PetSitesEditController { public class PetSitesEditController {
...@@ -1722,7 +1722,7 @@ public class PetSitesEditController { ...@@ -1722,7 +1722,7 @@ public class PetSitesEditController {
<classname>CustomDateEditor</classname> for all <classname>CustomDateEditor</classname> for all
<classname>java.util.Date</classname> form properties.</para> <classname>java.util.Date</classname> form properties.</para>
<programlisting>@Controller <programlisting language="java">@Controller
public class MyFormController { public class MyFormController {
<emphasis role="bold">@InitBinder</emphasis> <emphasis role="bold">@InitBinder</emphasis>
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
<para> <para>
Find below the &lt;listener/&gt; configuration: Find below the &lt;listener/&gt; configuration:
</para> </para>
<programlisting><![CDATA[<listener> <programlisting language="xml"><![CDATA[<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>]]></programlisting> </listener>]]></programlisting>
<note> <note>
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
<para> <para>
Find below the &lt;context-param/&gt; configuration: Find below the &lt;context-param/&gt; configuration:
</para> </para>
<programlisting><![CDATA[<context-param> <programlisting language="xml"><![CDATA[<context-param>
<param-name>contextConfigLocation</param-name> <param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value> <param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>]]></programlisting> </context-param>]]></programlisting>
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
<interface>ApplicationContext</interface> created by the <interface>ApplicationContext</interface> created by the
<classname>ContextLoaderListener</classname>. <classname>ContextLoaderListener</classname>.
</para> </para>
<programlisting><![CDATA[WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);]]></programlisting> <programlisting language="java"><![CDATA[WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);]]></programlisting>
<para> <para>
The <ulink url="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/context/support/WebApplicationContextUtils.html"><classname>WebApplicationContextUtils</classname></ulink> The <ulink url="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/context/support/WebApplicationContextUtils.html"><classname>WebApplicationContextUtils</classname></ulink>
class is for convenience, so you don't have to remember the name of the class is for convenience, so you don't have to remember the name of the
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
element and a <literal>&lt;variable-resolver/&gt;</literal> element within it. element and a <literal>&lt;variable-resolver/&gt;</literal> element within it.
The value of the variable resolver should reference Spring's The value of the variable resolver should reference Spring's
<classname>DelegatingVariableResolver</classname>; for example:</para> <classname>DelegatingVariableResolver</classname>; for example:</para>
<programlisting><![CDATA[<faces-config> <programlisting language="xml"><![CDATA[<faces-config>
<application> <application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver> <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
<locale-config> <locale-config>
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
file. Find below an example where <literal>#{userManager}</literal> is a bean file. Find below an example where <literal>#{userManager}</literal> is a bean
that is retrieved from the Spring 'business context'. that is retrieved from the Spring 'business context'.
</para> </para>
<programlisting><![CDATA[<managed-bean> <programlisting language="xml"><![CDATA[<managed-bean>
<managed-bean-name>userList</managed-bean-name> <managed-bean-name>userList</managed-bean-name>
<managed-bean-class>com.whatever.jsf.UserList</managed-bean-class> <managed-bean-class>com.whatever.jsf.UserList</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope> <managed-bean-scope>request</managed-bean-scope>
...@@ -235,7 +235,7 @@ ...@@ -235,7 +235,7 @@
Configuration-wise, simply define <classname>SpringBeanVariableResolver</classname> Configuration-wise, simply define <classname>SpringBeanVariableResolver</classname>
in your <emphasis>faces-context.xml</emphasis> file: in your <emphasis>faces-context.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<faces-config> <programlisting language="xml"><![CDATA[<faces-config>
<application> <application>
<variable-resolver>org.springframework.web.jsf.SpringBeanVariableResolver</variable-resolver> <variable-resolver>org.springframework.web.jsf.SpringBeanVariableResolver</variable-resolver>
... ...
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
Configuration-wise, simply define <classname>SpringBeanFacesELResolver</classname> Configuration-wise, simply define <classname>SpringBeanFacesELResolver</classname>
in your JSF 1.2 <emphasis>faces-context.xml</emphasis> file: in your JSF 1.2 <emphasis>faces-context.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<faces-config> <programlisting language="xml"><![CDATA[<faces-config>
<application> <application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
... ...
...@@ -276,7 +276,7 @@ ...@@ -276,7 +276,7 @@
takes a <classname>FacesContext</classname> parameter rather than a takes a <classname>FacesContext</classname> parameter rather than a
<interface>ServletContext</interface> parameter. <interface>ServletContext</interface> parameter.
</para> </para>
<programlisting><![CDATA[ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());]]></programlisting> <programlisting language="java"><![CDATA[ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());]]></programlisting>
</section> </section>
</section> </section>
...@@ -344,12 +344,12 @@ ...@@ -344,12 +344,12 @@
To configure this plug-in, add the following XML to the plug-ins section near To configure this plug-in, add the following XML to the plug-ins section near
the bottom of your <emphasis>struts-config.xml</emphasis> file: the bottom of your <emphasis>struts-config.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"/>]]></programlisting> <programlisting language="xml"><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"/>]]></programlisting>
<para> <para>
The location of the context configuration files can be customized using the The location of the context configuration files can be customized using the
'<literal>contextConfigLocation</literal>' property. '<literal>contextConfigLocation</literal>' property.
</para> </para>
<programlisting><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <programlisting language="xml"><![CDATA[<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" <set-property property="contextConfigLocation"
value="/WEB-INF/action-servlet.xml,/WEB-INF/applicationContext.xml"/> value="/WEB-INF/action-servlet.xml,/WEB-INF/applicationContext.xml"/>
</plug-in>]]></programlisting> </plug-in>]]></programlisting>
...@@ -389,12 +389,12 @@ ...@@ -389,12 +389,12 @@
action-mapping's "path" and the bean's "name". If you have the action-mapping's "path" and the bean's "name". If you have the
following in your <emphasis>struts-config.xml</emphasis> file: following in your <emphasis>struts-config.xml</emphasis> file:
</para> </para>
<programlisting><![CDATA[<action path="/users" .../>]]></programlisting> <programlisting language="xml"><![CDATA[<action path="/users" .../>]]></programlisting>
<para> <para>
You must define that Action's bean with the "/users" name in You must define that Action's bean with the "/users" name in
<emphasis>action-servlet.xml</emphasis>: <emphasis>action-servlet.xml</emphasis>:
</para> </para>
<programlisting><![CDATA[<bean name="/users" .../>]]></programlisting> <programlisting language="xml"><![CDATA[<bean name="/users" .../>]]></programlisting>
<section id="struts-delegatingrequestprocessor"> <section id="struts-delegatingrequestprocessor">
<title>DelegatingRequestProcessor</title> <title>DelegatingRequestProcessor</title>
<para> <para>
...@@ -404,7 +404,7 @@ ...@@ -404,7 +404,7 @@
property in the &lt;controller&gt; element. These lines follow the property in the &lt;controller&gt; element. These lines follow the
&lt;action-mapping&gt; element. &lt;action-mapping&gt; element.
</para> </para>
<programlisting><![CDATA[<controller> <programlisting language="xml"><![CDATA[<controller>
<set-property property="processorClass" <set-property property="processorClass"
value="org.springframework.web.struts.DelegatingRequestProcessor"/> value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>]]></programlisting> </controller>]]></programlisting>
...@@ -414,7 +414,7 @@ ...@@ -414,7 +414,7 @@
you don't even need to specify a type. Both of the following snippets you don't even need to specify a type. Both of the following snippets
will work: will work:
</para> </para>
<programlisting><![CDATA[<action path="/user" type="com.whatever.struts.UserAction"/> <programlisting language="xml"><![CDATA[<action path="/user" type="com.whatever.struts.UserAction"/>
<action path="/user"/>]]></programlisting> <action path="/user"/>]]></programlisting>
<para> <para>
If you're using Struts' <emphasis>modules</emphasis> feature, If you're using Struts' <emphasis>modules</emphasis> feature,
...@@ -442,7 +442,7 @@ ...@@ -442,7 +442,7 @@
<classname>DelegatingActionProxy</classname></ulink> as the type in your <classname>DelegatingActionProxy</classname></ulink> as the type in your
action-mapping. action-mapping.
</para> </para>
<programlisting><![CDATA[<action path="/user" type="org.springframework.web.struts.DelegatingActionProxy" <programlisting language="xml"><![CDATA[<action path="/user" type="org.springframework.web.struts.DelegatingActionProxy"
name="userForm" scope="request" validate="false" parameter="method"> name="userForm" scope="request" validate="false" parameter="method">
<forward name="list" path="/userList.jsp"/> <forward name="list" path="/userList.jsp"/>
<forward name="edit" path="/userForm.jsp"/> <forward name="edit" path="/userForm.jsp"/>
...@@ -459,7 +459,7 @@ ...@@ -459,7 +459,7 @@
<classname>Action</classname> instance for each request. To activate the latter, <classname>Action</classname> instance for each request. To activate the latter,
add <emphasis>scope="prototype"</emphasis> to your Action's bean definition. add <emphasis>scope="prototype"</emphasis> to your Action's bean definition.
</para> </para>
<programlisting><![CDATA[<bean name="/user" scope="prototype" autowire="byName" <programlisting language="xml"><![CDATA[<bean name="/user" scope="prototype" autowire="byName"
class="org.example.web.UserAction"/>]]></programlisting> class="org.example.web.UserAction"/>]]></programlisting>
</section> </section>
</section> </section>
...@@ -480,7 +480,7 @@ ...@@ -480,7 +480,7 @@
convenience methods, like <emphasis>getWebApplicationContext()</emphasis>. convenience methods, like <emphasis>getWebApplicationContext()</emphasis>.
Below is an example of how you might use this in an Action: Below is an example of how you might use this in an Action:
</para> </para>
<programlisting><![CDATA[public class UserAction extends DispatchActionSupport { <programlisting language="java"><![CDATA[public class UserAction extends DispatchActionSupport {
public ActionForward execute(ActionMapping mapping, public ActionForward execute(ActionMapping mapping,
ActionForm form, ActionForm form,
...@@ -627,7 +627,7 @@ ...@@ -627,7 +627,7 @@
Assume we have the following simple Spring container definition (in the Assume we have the following simple Spring container definition (in the
ubiquitous XML format): ubiquitous XML format):
</para> </para>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd"> "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
...@@ -703,7 +703,7 @@ ...@@ -703,7 +703,7 @@
a page to get an instance of the <interfacename>UserService</interfacename>, a page to get an instance of the <interfacename>UserService</interfacename>,
for example, would be with code such as: for example, would be with code such as:
</para> </para>
<programlisting><![CDATA[WebApplicationContext appContext = WebApplicationContextUtils.getApplicationContext( <programlisting language="java"><![CDATA[WebApplicationContext appContext = WebApplicationContextUtils.getApplicationContext(
getRequestCycle().getRequestContext().getServlet().getServletContext()); getRequestCycle().getRequestContext().getServlet().getServletContext());
UserService userService = (UserService) appContext.getBean("userService"); UserService userService = (UserService) appContext.getBean("userService");
]]><lineannotation>... some code which uses UserService</lineannotation></programlisting> ]]><lineannotation>... some code which uses UserService</lineannotation></programlisting>
...@@ -744,7 +744,7 @@ UserService userService = (UserService) appContext.getBean("userService"); ...@@ -744,7 +744,7 @@ UserService userService = (UserService) appContext.getBean("userService");
directly. One way is by defining a custom version of the Tapestry directly. One way is by defining a custom version of the Tapestry
<interfacename>IEngine</interfacename> which exposes this for us: <interfacename>IEngine</interfacename> which exposes this for us:
</para> </para>
<programlisting><![CDATA[package com.whatever.web.xportal; <programlisting language="java"><![CDATA[package com.whatever.web.xportal;
import ... import ...
...@@ -776,7 +776,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine { ...@@ -776,7 +776,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
instance should be used for this Tapestry application, with an entry instance should be used for this Tapestry application, with an entry
in the Tapestry application definition file. For example: in the Tapestry application definition file. For example:
</para> </para>
<programlisting><lineannotation>file: xportal.application:</lineannotation><![CDATA[ <programlisting language="xml"><lineannotation>file: xportal.application:</lineannotation><![CDATA[
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC <!DOCTYPE application PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN" "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
...@@ -794,7 +794,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine { ...@@ -794,7 +794,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
need out of the <interfacename>ApplicationContext</interfacename>, need out of the <interfacename>ApplicationContext</interfacename>,
and create page or component properties for them. For example: and create page or component properties for them. For example:
</para> </para>
<programlisting><![CDATA[ <property-specification name="userService" <programlisting language="xml"><![CDATA[ <property-specification name="userService"
type="com.whatever.services.service.user.UserService"> type="com.whatever.services.service.user.UserService">
global.appContext.getBean("userService") global.appContext.getBean("userService")
</property-specification> </property-specification>
...@@ -807,7 +807,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine { ...@@ -807,7 +807,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
initial value for the property, as a bean obtained from the context. initial value for the property, as a bean obtained from the context.
The entire page definition might look like this: The entire page definition might look like this:
</para> </para>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC <!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN" "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd"> "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
...@@ -857,7 +857,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine { ...@@ -857,7 +857,7 @@ public class MyEngine extends org.apache.tapestry.engine.BaseEngine {
for the properties we have defined (in order to be able to for the properties we have defined (in order to be able to
access the properties). access the properties).
</para> </para>
<programlisting><![CDATA[// our UserService implementation; will come from page definition <programlisting language="java"><![CDATA[// our UserService implementation; will come from page definition
public abstract UserService getUserService(); public abstract UserService getUserService();
// our AuthenticationService implementation; will come from page definition // our AuthenticationService implementation; will come from page definition
public abstract AuthenticationService getAuthenticationService();]]></programlisting> public abstract AuthenticationService getAuthenticationService();]]></programlisting>
...@@ -865,7 +865,7 @@ public abstract AuthenticationService getAuthenticationService();]]></programlis ...@@ -865,7 +865,7 @@ public abstract AuthenticationService getAuthenticationService();]]></programlis
For the sake of completeness, the entire Java class, for a For the sake of completeness, the entire Java class, for a
login page in this example, might look like this: login page in this example, might look like this:
</para> </para>
<programlisting><![CDATA[package com.whatever.web.xportal.pages; <programlisting language="java"><![CDATA[package com.whatever.web.xportal.pages;
/** /**
* Allows the user to login, by providing username and password. * Allows the user to login, by providing username and password.
...@@ -1001,7 +1001,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende ...@@ -1001,7 +1001,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende
and <literal>authenticationService</literal> objects (lots of the class and <literal>authenticationService</literal> objects (lots of the class
definition has been elided for clarity)... definition has been elided for clarity)...
</para> </para>
<programlisting><![CDATA[package com.whatever.web.xportal.pages; <programlisting language="java"><![CDATA[package com.whatever.web.xportal.pages;
public abstract class Login extends BasePage implements ErrorProperty, PageRenderListener { public abstract class Login extends BasePage implements ErrorProperty, PageRenderListener {
...@@ -1016,7 +1016,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende ...@@ -1016,7 +1016,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende
We are almost done... all that remains is the HiveMind configuration that exposes the We are almost done... all that remains is the HiveMind configuration that exposes the
Spring container stored in the <interfacename>ServletContext</interfacename> as a Spring container stored in the <interfacename>ServletContext</interfacename> as a
HiveMind service; for example:</para> HiveMind service; for example:</para>
<programlisting><![CDATA[<?xml version="1.0"?> <programlisting language="xml"><![CDATA[<?xml version="1.0"?>
<module id="com.javaforge.tapestry.spring" version="0.1.1"> <module id="com.javaforge.tapestry.spring" version="0.1.1">
<service-point id="SpringApplicationInitializer" <service-point id="SpringApplicationInitializer"
...@@ -1049,7 +1049,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende ...@@ -1049,7 +1049,7 @@ public abstract class Login extends BasePage implements ErrorProperty, PageRende
inside the <literal>.page</literal> or <literal>.jwc</literal> file inside the <literal>.page</literal> or <literal>.jwc</literal> file
for the <classname>Login</classname> page (or component): for the <classname>Login</classname> page (or component):
</para> </para>
<programlisting><![CDATA[<inject property="userService" object="spring:userService"/> <programlisting language="xml"><![CDATA[<inject property="userService" object="spring:userService"/>
<inject property="authenticationService" object="spring:authenticationService"/>]]></programlisting> <inject property="authenticationService" object="spring:authenticationService"/>]]></programlisting>
</section> </section>
</section> </section>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册