For example, imagine I read my data from an xml, but I don't know how many properties will be there, and the names of those properties. So, I cannot create a bean to that, with getters and setters.
Remember that ValueProvider is just an interface, and can be implemented in any way you want, on any POJO you want. As Daniel mentioned, BaseModel is in the legacy jar, along with a ValueProvider implementation that can use it.
If you can make any kind of a pojo with methods to get and set methods, and some way to translate your xml into data in the pojo, you can write a ValueProvider (and a ModelKeyProvider of course) that can generically access your data. Could look something like this:
Code:
interface XmlData {
String getAttr(String key);
void setAttr(String key, String value);
}
class XmlDataValueProvider implements ValueProvider<XmlData, String>{
private String attr;
public XmlDataValueProvider(String attrName) {
this.attr = attrName;
}
public String getValue(XmlData data) {
return data.getAttr(this.attr);
}
public void setValue(XmlData data, String value) {
data.setAttr(this.attr, value);
}
public String getPath() {
// this is only used to send keys to the server for sorting, etc, may not be required for you
return attr;
}
}