Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-97

[beanutils] Problems on indexed property with JDK 1.4

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6
    • 1.8.0
    • None
    • None
    • Operating System: other
      Platform: Other

    • 28358

    Description

      I'm experiencing problems porting an existing struts 1.1 application on JDK 1.4.
      Debugging the code, i have seen that the problem occur in getIndexedProperty,
      because on jdk 1.3.1_02 return an instance of IndexedPropertyDescriptor while
      in jdk 1.4.1_02 not!
      To use indexed property on struts, whe declare 2 methods on the ActionForm: one
      that return the entire list and one that return an indexed element

      A simple class that reproduce the problem is:

      public class FooForm extends ValidatorForm

      { protected List childs = new ArrayList(0); ... }

      public List getChilds()

      { return childs; }

      public ChildsBean getChilds(int index) {
      if (index + 1 > childs.size()) {
      for (int i = childs.size(); i < index + 1; i++)

      { childs.add(new ChildsBean()); }

      }
      return (ChildsBean) childs.get(index);
      }

      ....
      }

      and the problem occur when i preload the forms values using a code like this

      for (int j = 0; j < newChilds.size(); j++) {
      BeanUtils.copyProperties(PropertyUtils.getIndexedProperty
      (valBean,"childs",j), newChilds.get(j));
      }

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--BeanUtilsBeanIndexed.txt
          1.0 kB
          Niall Pemberton
        2. ASF.LICENSE.NOT.GRANTED--butc.diff
          1 kB
          Wendy Smoak
        3. ASF.LICENSE.NOT.GRANTED--IndexedBean.java
          0.6 kB
          Wendy Smoak
        4. ASF.LICENSE.NOT.GRANTED--IndexedBean.java
          0.6 kB
          Wendy Smoak
        5. ASF.LICENSE.NOT.GRANTED--IndexedPropertyTestCase.java
          15 kB
          Niall Pemberton
        6. ASF.LICENSE.NOT.GRANTED--IndexedTestBean.java
          2 kB
          Niall Pemberton
        7. ASF.LICENSE.NOT.GRANTED--PropertyUtilsBeanJDK.txt
          5 kB
          Niall Pemberton
        8. ASF.LICENSE.NOT.GRANTED--PropertyUtilsTestBean.java
          2 kB
          Joseph Lad Germuska
        9. ASF.LICENSE.NOT.GRANTED--PropertyUtilsTestBean.java
          2 kB
          Joseph Lad Germuska

        Activity

          People

            Unassigned Unassigned
            franco.caponi@tin.it Franco Caponi
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: