PDA

View Full Version : spring:bind binds the subclass


sjtirtha
Aug 29th, 2005, 05:58 AM
Hi,

I'm using SimpleFormController. And I want to bind an object that is defined as a subclass from another class. But I don't get the binding.

class Title{
private String name;
}

class Doc{
private Title title;
private Summary summary;
}

class Book extends Doc{
private int page;
private String author;
}

<spring:bind path="book.title.name">

all classes have getter and setter methods for its attribute.

Can spring:bind bind an attribute from its super class ?

Regards,

steve

simtin
Aug 29th, 2005, 06:42 AM
Yes, of course this is no problem. You only need to ensure that book.title is set; otherwise, a nullpointer exception will be thrown.

Simon