Struts 2
  1. Struts 2
  2. WW-3268

problem with property named "parameters" in my bean

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.7
    • Component/s: Documentation
    • Labels:
      None
    • Flags:
      Important

      Description

      I had a problem with the tag <s:select/> that did not render correctly. It ignored the properties that I wanted to use as key and value from my beans, and instead it used the toString() method of my bean. After renaming the bean class and removing all properties, and inserting one by one, I found out that the problem was due to a property named 'parameters' in my bean.
      So I guess this word is 'reserved', and there should be a warning in the tags documentation that this word cannot be used as a property in my beans, even if I don't use the property in any tag.
      There is a conflict issue with this word. And I guess there might be other words that could result in the same conflict.

        Issue Links

          Activity

          Hide
          Lukasz Lenart added a comment -

          Added additional section to Tag Syntax [1], thanks for reporting!

          [1] https://cwiki.apache.org/confluence/display/WW/Tag+Syntax#TagSyntax-Disallowedpropertynames

          Show
          Lukasz Lenart added a comment - Added additional section to Tag Syntax [1] , thanks for reporting! [1] https://cwiki.apache.org/confluence/display/WW/Tag+Syntax#TagSyntax-Disallowedpropertynames
          Hide
          Barthélémy Lorette added a comment -

          I have the same problem with the property named “application”.
          This problem has appeared since Struts 2 version 2.3.3.

          Show
          Barthélémy Lorette added a comment - I have the same problem with the property named “application”. This problem has appeared since Struts 2 version 2.3.3.
          Hide
          Pavel Kazlou added a comment -

          Tried the example with struts 2.3.1 as maven dependency (pom.xml 1212122 2011-12-08 21:07:36Z lukaszlenart) and the bug still exists

          Show
          Pavel Kazlou added a comment - Tried the example with struts 2.3.1 as maven dependency (pom.xml 1212122 2011-12-08 21:07:36Z lukaszlenart) and the bug still exists
          Hide
          JB added a comment - - edited

          Rodrigo – Thank you for catching my spelling error.

          You are correct: After renaming the property from 'paramters' to 'parameters', along with the getter and setter, I too observed the behavior you reported.

          jb

          Show
          JB added a comment - - edited Rodrigo – Thank you for catching my spelling error. You are correct: After renaming the property from 'paramters' to 'parameters', along with the getter and setter, I too observed the behavior you reported. jb
          Hide
          Rodrigo Canabrava added a comment - - edited

          You have misspelled 'parameters', in the class User. The property you created is 'paramters'. It's missing a letter 'e' between 'm' and 't'.
          That is why it worked in your test case.

          Show
          Rodrigo Canabrava added a comment - - edited You have misspelled 'parameters', in the class User. The property you created is 'paramters'. It's missing a letter 'e' between 'm' and 't'. That is why it worked in your test case.
          Hide
          JB added a comment - - edited

          I am unable to reproduce this issue. My sample Maven project is running Struts 2 version 2.2.3.

          My test IndexAction contains a collection of User bean instances. The User beans contain the following simple String properties: name and parameters.

          public class User {
          
                  private String name;
                  private String paramters;
          
                  public String getParamters() {
                          return paramters;
                  }
          
                  public void setParamters(String paramters) {
                          this.paramters = paramters;
                  }
          ...
          

          I have included a toString() method that returns the user's name.

          ...
                 @Override
                  public String toString() {
                          return "The users name is "+ this.getName();
                  }
          ...
          

          My index.jsp contains the following code-fragment:

          <s:select name="username" 
                    list="users"
                    listKey="name"
                    listValue="name" 
                    label="Select a user" />
          

          The following "Select" is rendered:

          <select name="username" id="showProblem_username">
              <option value="Jeff">Jeff</option>
              <option value="Chelley">Chelley</option>
              <option value="Maddie">Maddie</option>
              <option value="Cooper">Cooper</option>
          </select>
          

          If I missed something please let me know and I will incorporate that into my testing. Otherwise I "think" this issue may be closed. – jb

          Show
          JB added a comment - - edited I am unable to reproduce this issue. My sample Maven project is running Struts 2 version 2.2.3. My test IndexAction contains a collection of User bean instances. The User beans contain the following simple String properties: name and parameters. public class User { private String name; private String paramters; public String getParamters() { return paramters; } public void setParamters( String paramters) { this .paramters = paramters; } ... I have included a toString() method that returns the user's name. ... @Override public String toString() { return "The users name is " + this .getName(); } ... My index.jsp contains the following code-fragment: <s:select name= "username" list= "users" listKey= "name" listValue= "name" label= "Select a user" /> The following "Select" is rendered: <select name= "username" id= "showProblem_username" > <option value= "Jeff" >Jeff</option> <option value= "Chelley" >Chelley</option> <option value= "Maddie" >Maddie</option> <option value= "Cooper" >Cooper</option> </select> If I missed something please let me know and I will incorporate that into my testing. Otherwise I "think" this issue may be closed. – jb

            People

            • Assignee:
              Lukasz Lenart
              Reporter:
              Rodrigo Canabrava
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development