Im attempting to use the MVP design pattern with a Swing application in conjution with Spring IOC. In MVP the View needs to pass itself into the presenter, and I can't work out how to do this with Spring.
public class MainView implements IMainView {
private MainPresenter _presenter;
public MainView() {
_presenter = new MainPresenter(this,new MyService());
//I want something more like this
// _presenter = BeanFactory.GetBean(MainPresenter.class);
}
}
this is my config xml (incorrect)
<bean id="MainView" class="Foo.MainView"/>
<bean id="MyService" class="Foo.MyService"/>
<bean id="MainPresenter" class="Foo.MainPresenter">
<!--I want something like this, but this is creating a new instance of View, which is no good-->
<constructor-arg type="IMainView">
<ref bean="MainView"/>
</constructor-arg>
<constructor-arg type="Foo.IMyService">
<ref bean="MyService"/>
</constructor-arg>
</bean>
How do I get the view into the presenter?