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

added language element to programlisting for syntax highlighting

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