[ 
http://issues.apache.org/jira/browse/BEANUTILS-97?page=comments#action_12416859 
] 

Alexandru Sirbu commented on BEANUTILS-97:
------------------------------------------

(In reply to comment #18)
If you have a Bean with a property foo:List<foo1>  with 4 Methods getFoo() 
getFoo(index) setFoo() setFoo(index, newFoo1) jdk 1.5_06 will not return an 
IndexedPropertyDescriptor so the method getFoo(index) will never be called

To fix this I observed that if you made the change that Niall Pemberton
(comment #18) has exposed, in the PropertyUtilsBean class, then you can write 
only 3 methods getFoo() getFoo(index) setFoo(index,newFoo1) without getting an 
error.After that jdk1.5_06 will recognize your property like an 
indexedProperty and getFoo(index) will be called to fill in your form after a 
submit (Struts).



> [beanutils] Problems on indexed property with JDK 1.4
> -----------------------------------------------------
>
>          Key: BEANUTILS-97
>          URL: http://issues.apache.org/jira/browse/BEANUTILS-97
>      Project: Commons BeanUtils
>         Type: Bug

>     Versions: 1.6 Final
>  Environment: Operating System: other
> Platform: Other
>     Reporter: Franco Caponi
>  Attachments: BeanUtilsBeanIndexed.txt, IndexedBean.java, IndexedBean.java, 
> IndexedPropertyTestCase.java, IndexedTestBean.java, PropertyUtilsBeanJDK.txt, 
> PropertyUtilsTestBean.java, PropertyUtilsTestBean.java, butc.diff
>
> 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));
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to