Hi, Is there a way to bind beans properties for another type of bean using the spring's form.select. Example:
I have a bean that needs to be updated in the view with a property called BeanB:
public class BeanA {
private BeanB bean;
private int id;
private void setId(int id){
this.id = id;
}
private int getId(){
return this.id;
}
public void setBean(BeanB bean){
this.bean = bean;
}
public BeanB getBean(){
return this.bean;
}
}
public class BeanB{
private int id;
private void setId(int id){
this.id = id;
}
private int getId(){
return this.id;
}
}
For the view I want to send a list of BeanB to be chosen from using the spring's formcontroller:
public class MyController extends SimpleFormController{
protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception {
BeanA bean = new BeanA();
//... init the bean or retrieve from db
List<BeanB> list = new ArrayList<BeanB>();
//... create list of objects
ModelAndView modelAndView = super.handleRenderRequestInternal(request, response);
modelAndView.getModel().put("beans", list);
modelAndView.getModel().put("bean", bean);
return modelAndView ;
}
}
In jsp I want to use a form.select to select the item I want to set for the BeanA from the given list, something like:
<form:select path="${bean.bean}" items="${beans}"/>
It looks like it doesn't work like this. Is there another simple solution for this?