[ 
https://issues.apache.org/struts/browse/WW-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Don Brown updated WW-2158:
--------------------------

    Fix Version/s:     (was: 2.1.2)

I'm not sure I understand the problem.  If pure reflection isn't showing the 
field as you would expect, what else could Struts do?

> Incorrect binding of superclass fields when mapping from view (JSP) to Struts 
> Actions
> -------------------------------------------------------------------------------------
>
>                 Key: WW-2158
>                 URL: https://issues.apache.org/struts/browse/WW-2158
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.9
>            Reporter: Andres Montes
>
> When inherited classes are used as attributes of Struts Actions the binding 
> of parameters from view to actions is not working properly. In fact, 
> reflection is not able to map attributes from superclass, they are ignored, 
> and mapped as not found on the retrieved result. For example:
> public abstract class BaseType implements Serializable {
>     Long id;
>     // getters and setters ...
> }
> public class TypeA extends BaseType implements Serializable {
>     String name;
>     // getters and setters ...
> }
> public class Item implements Serializable {
>     String name;
>     TypeA itemType;
>     // getters and setters ...
> }
> public class ItemCrudAction extends ActionSupport implements Preparable {
>      private Item myItem;
>      // getters and setters ...
>      // methods to populate data into view ...
> public void execute() {
>     // Retrieve attribute from View (JSP):
>    Item itemFromView = getMyItem(); // --> Here the compiler, through 
> reflection, shows the following attributes:
>    // name (of type String) -correct-
>    // Relationship attribute TypeA with the following attributes:
>    //            From superclass BaseType: id (of type String[1] instead of 
> Long) - incorrect-
>    // I guess this is because it can't find the attribute on the class
>    //           From class TypeA: name (of type String) - correct-
> }
> // item.jsp
> // ...
>    <s:textfield key="myitem.name" size="50" maxlength="2/>
>    // Combobox with values of type TypeA
>    // listOfValuesOfTypeA are filled from ItemCrudAction
>    <s:select key="myItem.itemType.id" list="listOfValuesOfTypeA" 
> headerKey="-1" headerValue="-- Select value --" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to