You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Andres Montes (JIRA)" <ji...@apache.org> on 2007/09/05 17:31:35 UTC

[jira] Created: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

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.


[jira] Commented: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

Posted by "Marcello Teodori (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42450 ] 

Marcello Teodori commented on WW-2158:
--------------------------------------

it works for me if I modify the model by making the base class (BaseType) not abstract, even if it would be better not to break the existing abstract base class design...

> 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
>             Fix For: 2.0.12
>
>
> 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.


[jira] Commented: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45088#action_45088 ] 

Wes Wannemacher commented on WW-2158:
-------------------------------------

I'm gonna give the original poster about one day to clarify this one... As Don asked - if you are having a problem using reflections to analyze your class, then what do you suggest struts does? 

> 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.


[jira] Assigned: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wes Wannemacher reassigned WW-2158:
-----------------------------------

    Assignee: Wes Wannemacher

> 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
>            Assignee: Wes Wannemacher
>
> 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.


[jira] Closed: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wes Wannemacher closed WW-2158.
-------------------------------

    Resolution: Not A Problem

> 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
>            Assignee: Wes Wannemacher
>
> 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.


[jira] Updated: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ 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.


[jira] Updated: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2158:
-----------------------------

    Fix Version/s: 2.0.11

> 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
>             Fix For: 2.0.11
>
>
> 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.


[jira] Updated: (WW-2158) Incorrect binding of superclass fields when mapping from view (JSP) to Struts Actions

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2158:
-----------------------------

    Fix Version/s:     (was: 2.0.11)
                   2.0.12

> 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
>             Fix For: 2.0.12
>
>
> 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.