struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Taylor" <rtay...@mulework.com>
Subject RE: All The Bean Properties Are Null in the Business Tier!!! (Used BeanUtils to Convert DynaValidatorForm)
Date Wed, 07 Jan 2004 19:04:44 GMT
Have you checked to make sure that the fields you expect
actually exist in the form before calling BeanUtils.populate()?

If so, have you checked to see if the data was copied properly 
just after BeanUtils.populate()?

BeanUtils.populate() uses reflection to copy properties.
Are you usingproper JavaBeans naming convention?

Try and isolate exactly where the data is getting "lost".

I use BeanUtils.populate() all the time with DynaXXXXForms and
have no problems. Usually when I do, I find that my data member
names don't correspond.

robert

> -----Original Message-----
> From: Caroline Jen [mailto:jiapei_jen@yahoo.com]
> Sent: Wednesday, January 07, 2004 1:42 PM
> To: struts-user@jakarta.apache.org
> Subject: All The Bean Properties Are Null in the Business Tier!!! (Used
> BeanUtils to Convert DynaValidatorForm)
> 
> 
> Hi, my program compiled OKay.  When I ran the
> application, somehow, the properties of my
> DynaValidatorForm are not passed from the action class
> to the business tier and then to the data access tier.
>  Please help me taking a look at what went wrong.   
> 
> It looks that the validation worked fine: 
> 
> <form-bean
>     name="postForm"
>           
> type="org.apache.struts.validator.DynaValidatorForm">
>        <form-property
>             name="receiver"
>             type="java.lang.String"/>
>        <form-property
>             name="sender"
>             type="java.lang.String"/>
>     .....
>     .....
> </form-bean>
> because when I intentionally left several of the text
> fields blank and submitted my JSP form, an applet got
> prompted showing something in those fields are
> required.
> 
> In my action class (see below),  I used BeanUtils to
> copy all the properties of the DynaValidatorForm to a
> bean (ThreadBean): 
> 
> DynaActionForm postForm = ( DynaActionForm )form;
> ThreadBean threadBean = new ThreadBean();
> BeanUtils.copyProperties( threadBean, postForm );
> 
> I then added a number of properties with pre-defined
> values to the ThreadBean in the Action class:
> 
> Timestamp now = DateUtil.getCurrentGMTTimestamp();
> threadBean.setThreadCreationDate( now );
> threadBean.setThreadViewCount( 0 );
> 
> I then called a method in a service class
> ThreadHandler and passing threadBean as the parameter
> of that method:
> 
> ThreadHandler thandler = new ThreadHandler();
> threadID = thandler.insertThread( threadBean );
> 
> In the ThreadHandler class (see below), I first tried
> to retrieve the values of those properties from the
> ThreadBean.  I FOUND OUT ALL THOSE VALUES ARE NULL!
> 
> class ThreadHandler extends ThreadBean 
> {
>    int threadID = getThreadID();
>    String receiver = getReceiver();
>    String sender = getSender();
>    Timestamp threadCreationDate =
> getThreadCreationDate();
>    int threadViewCount = getThreadViewCount();
> 
>    public ThreadHandler() {}
> 
>    MessageDAO md = new MySQLMessageDAO();
> 
>    public int insertThread( ThreadBean threadBean )
>                             throws
> MessageDAOSysException, ObjectNotFoundException
>    {
>       md.createThread( receiver, sender,   
>                    threadCreationDate, threadViewCount
> );
> 
>       .....
>       .....
> 
>       return threadID;
>    }
> }
> 
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message