I'm working on a Struts2 project, in which there are some actions that contain the most of fields in common.
I have aggregated these fields in a superclass that generalizes actions and extends ActionSupport
. For each field I have created getter/setter methods.
The problem is that the framework doesn't seem to invoke setter methods if the fields are inherited.
Below some snippets of my implementation:
Struts.xml
<action name="PresaInCaricoView" class="av.pei.action.view.PresaInCaricoView">
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<result>/PresaInCarico.jsp</result>
</action>
Java Code (Important: Action invocation is from JSP form, field is from JSP)
Base action
public class LottoView extends ActionSupport implements ServletRequestAware, Preparable{
@Getter @Setter public String idLotto = null;
@Getter @Setter public String idTipoDoc = null;
@Getter @Setter public String idStatoLotto = null;
public void prepare() throws Exception { }
}
Action
public class PresaInCaricoView extends LottoView {
public String execute() {
System.out.println(idLotto);
}
}
Is there any way to implement this behavior?
Thanks in advance, Paolo