I m struggling to make this work but with no luck.
Below is sample code and when I call edit method in the jsp all values are filled, but when I want to save changes then get an exception in OGNL. Maybe stuts2 doesn t work well with generics. Any suggestion would be more than appreciated.
public abstract class ActionHelper<T> extends ActionSupport{
protected T entity;
protected Integer id;
public void setId(Integer id){
this.id=id;
}
public void setEntity(T entity){
this.entity=entity;
}
public void getEntity(T entity){
this.entity=entity;
}
public String edit(){
this.entity=fillEntity();
return "edit";
}
public String save(){
genericDao.save(entity);
}
protected abstract T fillEntity();
}
public class PersonAction extends ActionHelper<Person>{
Person fillEntity(){
return genericDao.find(id,Person.class);
}
}
<s:form action="person_save" method="post">
<s:hidden name="entity.id">
<s:textfield name="entity.name">
<s:textfield name="entity.surname">
</form>