The Artima Developer Community
Sponsored Link

Java Buzz Forum
XDoclet Spring+Struts HowTo

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Marc Logemann

Posts: 594
Nickname: loge
Registered: Sep, 2002

Marc Logemann is founder of www.logentis.de a Java consultancy
XDoclet Spring+Struts HowTo Posted: Feb 26, 2005 7:35 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Marc Logemann.
Original Post: XDoclet Spring+Struts HowTo
Feed Title: Marc's Java Blog
Feed URL: http://www.logemann.org/day/index_java.xml
Feed Description: Java related topics for all major areas. So you will see J2ME, J2SE and J2EE issues here.
Latest Java Buzz Posts
Latest Java Buzz Posts by Marc Logemann
Latest Posts From Marc's Java Blog

Advertisement

For all those out there using Spring together with Struts, i created a small howTo regarding automatic generation of relevant files, especially the boring action-servlet-xml file which must be in synch with your struts-config.xml, at least for all Struts actions which should be injected by Spring.

Lets start with the Action class:

/**
 * Action to delete a Client
 * Date: 09.02.2005
 * Time: 15:29:15
 *
 * @author Logemann - Logentis e.K.
 * @version $Id$
 * @struts.action path="clientDelete" validate="false"
 *            type="org.springframework.web.struts.DelegatingActionProxy"
 *            name="emptyform"
 * @struts.action-forward name="back" 
 *             path="/clientManager.html" redirect="true"
 * @spring.bean name="clientDelete"
 */
public class ClientDeleteAction extends Action {

ClientManager clientManagerService;

/**
* Spring injection
*
* @param clientManagerService clientManagerService
* @spring.property ref="clientManagerService"
*/
public void setClientManagerService(ClientManager clientManagerService) {
this.clientManagerService = clientManagerService;
}
[..]


With this tags, the ant build target outlined below will create a struts-config.xml and the necessary action-servlet.xml needed by Spring. Lets see how the target looks:





classname="xdoclet.modules.spring.SpringDocletTask"
classpathref="classpath"/>


classname="xdoclet.modules.web.WebDocletTask"
classpathref="classpath"/>
















Be sure to modify the classpath definition and the destDir values of springdoclet and webdoclet to suit your needs. Right now the Spring task only searches for Actions in order to create action-servlet.xml, if you also want to create your normal service beans like ClientManagerService, you should create another springdoclet task and output things to applicationContext.xml if you like.

But this is mostly users choice, as you know, Spring supports from one to many bean definition files and its up to you how you want to have your spring xml world.

This will be created when you run the mentioned target:

(action-servlet.xml)




"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">


default-autowire="no"
default-lazy-init="false"
default-dependency-check="none"
>


name="clientDelete"
class="de.logentis.versysng.action.clientmanager.ClientDeleteAction"
>





(struts-config.xml)










path="clientDelete"
type="org.springframework.web.struts.DelegatingActionProxy"
name="emptyform"
scope="request"
unknown="false"
validate="false"
>

name="back"
path="/clientManager.html"
redirect="true"
/>



Read: XDoclet Spring+Struts HowTo

Topic: Researchers claim that your typing style can be used for authentication: Security Pipeline Previous Topic   Next Topic Topic: A neat Wiki Plugin

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use