I guess you're using Spring. If you use Spring injection via an xml file, you must use inheritance:
<bean id="baseAction" class="com....BaseAction" scope="prototype"> </bean> <bean id="itemDetails" class="com....ItemDetails" scope="prototype" depends-on="baseAction"> <property name="itemId" ref="itemId"/> </bean> <bean id="saveItem" class="com....SaveItem" scope="prototype" depends-on="baseAction,itemDetails"> </bean> Cheers, J. On Tue, May 29, 2012 at 2:31 PM, Dionis Argiri <dio...@gmail.com> wrote: > Hi! > > I'm using struts 2.3.3. And I have marked following problem. When I have > some hierarchy of inheritance, then value is not automatically injected in > inherited action. Example: > > abstract class BaseAction extends ActionSupport { > ... > } > > class NewItem extends BaseAction { > ... > } > > class ItemDetails extends BaseAction { > protected BigInteger itemId; > public BigInteger getItemId(){return itemId;} > public void setItemId(BigInteger itemId){this.itemId=itemId;} > ... > } > > class SaveItem extends ItemDetails { > ... > } > > I submit form to action "SaveItem" and (surprise-surprise) value is not > injected into itemId. And I see OGNL exception, that there's no method > SaveItem.setItemId(BigInteger). > Only working work-around is to explicitly create setter in SaveItem action. > But I hate this approach, because it forces me to create stupid code. > > The same stuff is even if I try to make field public. Anyway, it's not seen > by framework and value is not injected. > > Is it a known issue? Or probably I'm just using struts2 actions somehow > strange? > > BR, > Dionis >