You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Developer <de...@fdplus.com> on 2002/07/12 04:55:59 UTC

BeanUtils.populate with native types

Apparently BeanUtils.populate chokes with native type properties.  Is there a way to handle that other than change all the Model beans attributes to use Objects?

Thank you.

Re: BeanUtils.populate with native types

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 11 Jul 2002, Developer wrote:

> Date: Thu, 11 Jul 2002 22:55:59 -0400
> From: Developer <de...@fdplus.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
>      Developer <de...@fdplus.com>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: BeanUtils.populate with native types
>
> Apparently BeanUtils.populate chokes with native type properties.  Is
> there a way to handle that other than change all the Model beans
> attributes to use Objects?
>

This should work correctly in later nightly builds of Struts 1.1 (it's
really the latest nightly builds of commons-beanutils that matters).  Can
you try that, and report back with a specific example if it is still
failing for you?

> Thank you.
>

Craig



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: BeanUtils.populate with native types

Posted by Developer <de...@fdplus.com>.
I downloaded the last night build (20020713) and I still get the same error.

java.lang.Exception: argument type mismatch
  at biz.isman.web.BaseForm.populate(BaseForm.java:164)
  at biz.isman.web.SuperDispatchAction.update(SuperDispatchAction.java:156)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:25
)
  at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
  at java.lang.reflect.Method.invoke(Method.java:324)
  at
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:
207)
 ...

Here is my BaseForm.populate method:
/**
 *
 */
public DataBean populate() throws Exception {
      try {
            if ( (this.dataBean == null) &
                  (!isBlank(getAttributeType())) )

setDataBean((DataBean)Class.forName(getAttributeType()).newInstance());
            if (this.dataBean != null)
                  BeanUtils.populate(this.dataBean, getProperties());
//line 164
      } catch (Throwable t){
            servlet.log(">>>BaseForm.populate ERROR: " + t.getMessage());
            throw new Exception(t.getMessage());
      }
      return this.dataBean;
}

DataBean is an interface which is implemented by a DataBeanImpl super class.
all the Model objects extend DataBeanImpl.
DataBeanImpl has some native types (long, int, double) as well as Date
types.

The bean I'm trying to populate has some data already and the Map
(getProperties()) has new data which needs to be fed to the dataBean.

If I update the DataBean object manually, things work fine.  I'm sure you
would also agree that the beanutils package is exactly the magic I need for
this use case.

Thank you.



----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>;
"Developer" <de...@fdplus.com>
Sent: Friday, July 12, 2002 12:03 PM
Subject: Re: BeanUtils.populate with native types


>
>
> On Thu, 11 Jul 2002, Developer wrote:
>
> > Date: Thu, 11 Jul 2002 22:55:59 -0400
> > From: Developer <de...@fdplus.com>
> > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
> >      Developer <de...@fdplus.com>
> > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > Subject: BeanUtils.populate with native types
> >
> > Apparently BeanUtils.populate chokes with native type properties.  Is
> > there a way to handle that other than change all the Model beans
> > attributes to use Objects?
> >
>
> This should work correctly in later nightly builds of Struts 1.1 (it's
> really the latest nightly builds of commons-beanutils that matters).  Can
> you try that, and report back with a specific example if it is still
> failing for you?
>
> > Thank you.
> >
>
> Craig
>
>
>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: BeanUtils.populate with native types

Posted by Robert Taylor <rt...@mulework.com>.
I had some issues with BeanUtils and native types as well but they were
fixed in the nightlies.
I think revision 1.23.

robert

> -----Original Message-----
> From: Developer [mailto:developer@fdplus.com]
> Sent: Thursday, July 11, 2002 10:56 PM
> To: Struts Users Mailing List
> Subject: BeanUtils.populate with native types
>
>
> Apparently BeanUtils.populate chokes with native type properties.
>  Is there a way to handle that other than change all the Model
> beans attributes to use Objects?
>
> Thank you.
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>