Hi! I am having a very strange problem with struts 2. I am newbie to Struts 2 so maybe it is a simple thing I misunderstood. I have an abstract class (enterprise) and 4 subclasses. I want to perform CRUD operations on them and since all the properties are common to all the subclasses I've decided to use only one form and one action for all of them. The problem is that I cannot use in the form the reference to the abstract class Enterprise since when I create a new entry the bean instantiation fails as Enterprise is an abstract class and I didnt want to create 4 forms either so I came up with the following
In the form page to get the type of the company that I am editing and using logic tags to create a variable holding the name of the proper instance..: <s:if test="typeCompany.equalsIgnoreCase('CUSTOMER')"> <s:set name="companyType" value="%{'customer'}/> .... and then I try to use the proper name in the form tags like that: <s:textfield name="%{companyType}.name" value="%{%{companyType}.name}"/> and this shows nothing as value If instead I use the following <s:textfield name="%{companyType}.name" value="%{companyType.name}"/> I get the string customer.name as value But now if I use the key field like this: <s:textfield key="%{companyType.name}" name="%{companyType}.name" /> Then it works just fine, It renders the value that customer.name holds. I would like to use value rather than key because I don't want to create more resource bundles for localization since enterprise.name suits to the 4 subclasses. I hope I managed to explain my issue clearly. Any help is highly appreciated. Thank you! Óscar