commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simone Riccucci (JIRA)" <j...@apache.org>
Subject [jira] Updated: (BEANUTILS-345) BeanUtilsBean.setProperty does not handle some kind of nested properties
Date Tue, 21 Apr 2009 13:00:49 GMT

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

Simone Riccucci updated BEANUTILS-345:
--------------------------------------

    Description: 
If we have a Bean containing a two dimension array, the method setProperty of class BeanUtilsBean
does not work correctly.

Example
{code:title=MyBean.java|borderStyle=solid}
public class MyBean {

	String [][]matr =new String[][]{{"1","2"},{"3","4"}};
	
	public String[][] getMatr() {
		return matr;
	}
	public void setMatr(String[][] matr) {
		this.matr = matr;
	}
}
{code} 
When calling BeanUtilsBean.getInstance().setProperty(myBean, "matr[0][0]","Sample") the method
does not set the first element of first array.

I have patched this behaviour adding the line between comment //BEGIN PATCH and //END PATCH
to BeanUtilsBean.java
{code:borderStyle=solid}
920: // Calculate the property type
921:       if (target instanceof DynaBean) {
922:            DynaClass dynaClass = ((DynaBean) target).getDynaClass();
923:            DynaProperty dynaProperty = dynaClass.getDynaProperty(propName);
924:            if (dynaProperty == null) {
925:                return; // Skip this property setter
926:            }
927:            type = dynaProperty.getType();
928:        } else if (target instanceof Map) {
929:            type = Object.class;
930:            // BEGIN PATCH 
931:        } else if (target.getClass().isArray() && index>=0) {
932:        	type = Array.get(target, index).getClass();
933:        	// END PATCH
934:        } else {
......
.......
{code} 

  was:
If we have a Bean containing a two dimension array, the method setProperty of class BeanUtilsBean
does not work correctly.

Example
{code:title=MyBean.java|borderStyle=solid}
public class MyBean {

	String [][]matr =new String[][]{{"1","2"},{"3","4"}};
	
	public String[][] getMatr() {
		return matr;
	}
	public void setMatr(String[][] matr) {
		this.matr = matr;
	}
}
{code} 
When calling BeanUtilsBean.getInstance().setProperty(myBean, "matr[0][0]","Sample") the method
does not set the first element of first array.

I have patched this behaviour adding the line between comment //BEGIN PATCH and //END PATCH
to BeanUtilsBean.java
{code:title=borderStyle=solid}
920: // Calculate the property type
921:       if (target instanceof DynaBean) {
922:            DynaClass dynaClass = ((DynaBean) target).getDynaClass();
923:            DynaProperty dynaProperty = dynaClass.getDynaProperty(propName);
924:            if (dynaProperty == null) {
925:                return; // Skip this property setter
926:            }
927:            type = dynaProperty.getType();
928:        } else if (target instanceof Map) {
929:            type = Object.class;
930:            // BEGIN PATCH 
931:        } else if (target.getClass().isArray() && index>=0) {
932:        	type = Array.get(target, index).getClass();
933:        	// END PATCH
934:        } else {
......
.......
{code} 


> BeanUtilsBean.setProperty does not handle some kind of nested properties
> ------------------------------------------------------------------------
>
>                 Key: BEANUTILS-345
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-345
>             Project: Commons BeanUtils
>          Issue Type: Bug
>          Components: Bean / Property Utils
>    Affects Versions: 1.8.0
>         Environment: Windows XP, java 1.6
>            Reporter: Simone Riccucci
>
> If we have a Bean containing a two dimension array, the method setProperty of class BeanUtilsBean
does not work correctly.
> Example
> {code:title=MyBean.java|borderStyle=solid}
> public class MyBean {
> 	String [][]matr =new String[][]{{"1","2"},{"3","4"}};
> 	
> 	public String[][] getMatr() {
> 		return matr;
> 	}
> 	public void setMatr(String[][] matr) {
> 		this.matr = matr;
> 	}
> }
> {code} 
> When calling BeanUtilsBean.getInstance().setProperty(myBean, "matr[0][0]","Sample") the
method does not set the first element of first array.
> I have patched this behaviour adding the line between comment //BEGIN PATCH and //END
PATCH to BeanUtilsBean.java
> {code:borderStyle=solid}
> 920: // Calculate the property type
> 921:       if (target instanceof DynaBean) {
> 922:            DynaClass dynaClass = ((DynaBean) target).getDynaClass();
> 923:            DynaProperty dynaProperty = dynaClass.getDynaProperty(propName);
> 924:            if (dynaProperty == null) {
> 925:                return; // Skip this property setter
> 926:            }
> 927:            type = dynaProperty.getType();
> 928:        } else if (target instanceof Map) {
> 929:            type = Object.class;
> 930:            // BEGIN PATCH 
> 931:        } else if (target.getClass().isArray() && index>=0) {
> 932:        	type = Array.get(target, index).getClass();
> 933:        	// END PATCH
> 934:        } else {
> ......
> .......
> {code} 

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


Mime
View raw message