views:

123

answers:

1

Spring does not play nicely with beans that are created outside of its application context.

What's the best way in letting me design my forms using JFormDesigner but then using Spring to manage the actions of the components?

There are a few ways of integrating Spring and Swing (eg https://www.ibm.com/developerworks/java/tutorials/j-springswing/) but this approach involves you having to extend every control that you wish to use, an approach that looks like it would add a quite a lot of uneccesary overhead. Also this approach does not allow me to use JFormDesigner to model the look of my form.

I've also had a look at the Spring Rich Client Project but that doesn't look like it's migrated to Spring 3 yet, although that's looking likely to restart development soon as they have moved the project hosting to Github.

+1  A: 

I have an app which uses Swing, JFormDesigner built panels, Spring and Spring RCP. There is a view class, which extends RCP's AbstractView, for each view, which has references to both the panel (as we call it) and the actions, so it can manage them. Each view has one main panel (that can be built with JFormDesigner), which is the one that the view has a reference to. I don't know if this is the best way, but it works quite well.

The main problem that I am having is that defining simple listeners that have reference to the panel requires too much configuration if you want to make them Spring beans. And if you don't, you have to pass the reference to all needed Spring resources (panel, service interface, etc) manually, which is also a lot of work. I have partially solved this by writing a static getter for the most common Spring beans to a class that has an access to the application context.

What is the problem of configuring Spring to manage both the actions and the forms? In our app the panel has been simply defined as a property of the view in the application config, nothing special about it.

Carlos
Is this using Spring v3?
Pram
@Pram No, it's using 2.5.*. However, I don't think RCP itself is relevant in this approach, since I don't see the problem of managing the panels with Spring, as there are only one of them per view. I think it could also be done without RCP. And I must also warn you to think carefully before using RCP, as the development has not been too active over the last six years and the documentation in its current form is inadequate. I'm not sure how many alternatives are there and how much work they require, though. I revised my answer.
Carlos
Thanks for the info. I'm a bit hesitant about using RCP because of the lack of activity.I'll take a look at how the AbstractView paradigm works
Pram