Browse Source

Moved REST views to View chapter.

conversation
Arjen Poutsma 16 years ago
parent
commit
b57085909c
  1. 114
      spring-framework-reference/src/rest.xml
  2. 1181
      spring-framework-reference/src/view.xml

114
spring-framework-reference/src/rest.xml

@ -38,120 +38,6 @@ @@ -38,120 +38,6 @@
configuration</link> to understand the general programming model.</para>
</section>
<section id="rest-views">
<title>Views</title>
<para>Several views were added in Spring 3 to help support creating
RESTful services. They are:</para>
<itemizedlist>
<listitem>
<para><classname>AbstractAtomFeedView</classname> - returns an Atom
feed</para>
</listitem>
<listitem>
<para><classname>AbstractRssFeedView</classname> - returns a RSS
feed</para>
</listitem>
<listitem>
<para><classname>MarshallingView</classname> - returns an XML
representation using Spring's Object to XML mapping (OXM)
functionality</para>
</listitem>
</itemizedlist>
<note>
<para>Available separately is the
<classname>JacksonJsonView</classname> included as part of the Spring
JavaScript project.</para>
</note>
<section id="rest-feedview">
<title>Feed Views</title>
<para>Both <classname>AbstractAtomFeedView</classname> and
<classname>AbstractRssFeedView</classname> inherit from the base class
<classname>AbstractFeedView</classname> and are used to provide Atom
and RSS Feed views respectfully. They are based on java.net's <ulink
url="https://rome.dev.java.net">ROME</ulink> project and are located
in the package
<literal>org.springframework.web.servlet.view.feed</literal>.</para>
<para><classname>AbstractAtomFeedView</classname> requires you to
implement the <methodname>buildFeedEntries</methodname> method and
optionally override the <methodname>buildFeedMetadata</methodname>
method (the default implementation is empty), as shown below</para>
<programlisting language="java">public class SampleContentAtomView extends AbstractAtomFeedView {
@Override
protected void buildFeedMetadata(Map&lt;String, Object&gt; model, Feed feed,
HttpServletRequest request) {
// implementation omitted
}
@Override
protected List&lt;Entry&gt; buildFeedEntries(Map&lt;String, Object&gt; model,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
// implementation omitted
}
}</programlisting>
<para>Similar requirements apply for implementing
<classname>AbstractRssFeedView</classname>, as shown below</para>
<programlisting language="java">public class SampleContentAtomView extends AbstractRssFeedView {
@Override
protected void buildFeedMetadata(Map&lt;String, Object&gt; model, Channel feed,
HttpServletRequest request) {
// implementation omitted
}
@Override
protected List&lt;Item&gt; buildFeedItems(Map&lt;String, Object&gt; model,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
// implementation omitted
}
}</programlisting>
<para>The <methodname>buildFeedItems</methodname> and
<methodname>buildFeedEntires</methodname> pass in the HTTP request in
case you need to access the Locale. The HTTP response is passed in
only for the setting of cookies or other HTTP headers. The feed will
automatically be written to the response object after the method
returns.</para>
<para>For an example of creating a Atom view please refer to Alef
Arendsen's SpringSource TeamBlog <ulink
url="http://blog.springsource.com/2009/03/16/adding-an-atom-view-to-an-application-using-springs-rest-support/">entry</ulink>.</para>
</section>
<section>
<title>XML Marshalling View</title>
<para>The <classname>MarhsallingView</classname> uses a XML
<interfacename>Marshaller</interfacename> defined in the
<classname>org.springframework.oxm</classname> package to render the
response content as XML. The object to be marshalled can be set
explicitly using <classname>MarhsallingView</classname>'s
<property>modelKey</property> bean property. Alternatively, the view
will iterate over all model properties marhsall only those types that
are supported by the <interfacename>Marshaller</interfacename>. For
more information on the functionality in the
<classname>org.springframework.oxm</classname> package refer to the
chapter <link linkend="oxm">Marshalling XML using O/X
Mappers</link>.</para>
</section>
</section>
<section id="rest-method-conversion">
<title>HTTP Method Conversion</title>

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

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save