Announcement Announcement Module
Collapse
No announcement yet.
Help transition to Spring 3 annotations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help transition to Spring 3 annotations

    I'm working with an application that was orginally developed using Spring 2.5 (not using annotations). The Spring 2.5 libraries have been replaced with the 3.1 libraries. In any new code, I want to use annotations. I understood the constructs for Spring 2.5, but am just now starting to use annotations. I can do a simple controller application, but I've run into something that I can't wrap my head around. I have a rich set of methods in the existing controllers configured with XML that extend SimpleFormController that I want to re-use. I created a new controller using annotations and extended an existing controller, but it seems the new controller is not referencing the base controller that was created. I can reference protected attributes, but they are null and I've verified the the old controller is still being constructed with valid attributes. I know that I could make the old controller an attribute of the new (composition over inheritance), but this has become a challenge. I know there has to be a way to do this I just don't know enough about the annotations to make it work. Here what I'm asking, how do I annotate MyNewController to access the BaseC attribute that is created by Spring?

    public class BaseC extends SimpleFormController{
    protected MyAttribType type; // this not null for the base
    public void doStuff() {
    }

    public void setType(MyAttribType t) {
    type = t;
    }
    }

    @Controller
    public class MyNewController extends BaseC {

    @RequestMapping(method = POST, value="execute.htm")
    public void process() {
    if (type == null) {
    System.out.println("TYPE IS NULL"); // this is what happens
    } else {
    System.out.println("TYPE NOT NULL");
    }
    }
Working...
X