This article covers a Hippo CMS version 7.7. There's an updated version available that covers our most recent release.

Spring Bridge 

A Simple Form Controller Example: Contact-SpringMVC

First, build and run the Spring Web MVC Framework integration example. This example is available in our Subversion repository: demosuite.

Next, click the Contact-SpringMVC link on the left menu of the example website (http://localhost:8080/site/preview/contact-spring). You will see a page containing a form and when you type some invalid information, e.g., wicky as email, the page will show some validation errors which were generated by the Spring Web MVC Framework. If you fill valid information it will show a success view which is defined in the Spring Web MVC configurations.

Summary

  • You need to use SpringBridgeHstComponent for a hst component class with dispatched bean name.

  • You need to configure Spring root web application context.

  • And you need to configure beans in the root web application context.

See Woonsan's nice blog about Spring mvc support (note that this is a blog for an old HST version where the example was part of the testsuite instead of demosuite).
Configure Spring root web application application context

You should define the root web application context configuration, components and its dependent beans. Client assembly configurations are not related to this feature.

The springframework managed bean injection could be used only when the hst component class is defined as * ...SpringBridgeHstComponent *.

   <sv:node sv:name="contactspringform">
       <sv:property sv:name="jcr:primaryType" sv:type="Name">
           <sv:value>hst:component</sv:value>
       </sv:property>
       <sv:property sv:name="hst:template" sv:type="String">
           <sv:value>contactspring</sv:value>
       </sv:property>
       <sv:property sv:name="hst:componentclassname" sv:type="String">
           <sv:value>org.hippoecm.hst.component.support.spring.SpringBridgeHstComponent</sv:value>
       </sv:property>
       <sv:property sv:name="hst:parameternames" sv:type="String">
           <sv:value>spring-delegated-bean</sv:value>
       </sv:property>
       <sv:property sv:name="hst:parametervalues" sv:type="String">
           <sv:value>contactBean</sv:value>
       </sv:property>
   </sv:node>

So, the real component class must be set to the above dispatching class, and your real hst component bean must be found by the spring-delegated-bean parameter. In the above example, a spring managed bean must be found by the bean name, contactBean.

By the way, the delegating component will look up the root web application context, not from the client assembly configurations. So, you should not define your hst component bean and some dependent components in the client assembly configurations. You should define the beans in your web application root context configuration.

There's an example of this in the HST demosuite. Navigate to http://localhost:8080/site/preview/contact-spring. In this example, to configure the root web application context, some spring configurations are set with /WEB-INF/applicationContext.xml.

In applicationContext.xml , the entry-point bean (id=contactBean) is defined with some dependency configurations. Please have a look at that example.

For more convenience, if SpringBridgeHstComponent cannot find the delegate bean from the root web application context, then it will look up the bean from the client component manager (if available) as a fall back. (See HSTTWO-978 for details.)