Well, I finally figured out a solution to this problem outlined below.  Thought 
I would share it with the group in case someone else runs into this same 
problem.

The problem is somewhere between the Jakarta Commons BeanUtils in conjunction with a 
LazyValidatorForm.  Since the LazyValidatorForm class is all about being lazy (like 
me) where you don't have to define your fields unless they're associated with custom 
classes, there is a problem when you go to initialize the form with database data 
that contains null values.  I thought that since my value object had the fields 
defined as java.lang.String objects that they would be translated to that in the form 
object when using BeanUtils.copyProperties(...), but that's not always the case.  I 
had to actually use a <form-property> element in the LazyValidatorForm 
definition in the struts config file defining that the field is a String field.  This 
defeats the whole purpose for me using the LazyValidatorForm method in the first 
place.

Anyway, it fixed my problem, and it appears that I have to stop being lazy.  ;-(

--
Randy Kennedy
Software Engineer
Appriss, Inc. (Provider of the VINE Service)
10401 Linn Station Road, Suite 200
Louisville, KY  40223-3842

Web   : http://www.vineco.com, http://www.appriss.com
Email : [EMAIL PROTECTED]



Randy Kennedy wrote:


Here is a snippet from my initializing action before it goes to the form view:

...
       LazyValidatorForm ppForm = (LazyValidatorForm)form;
       ProtectedPersonLocal ppl = null;
       ProtectedPersonDTO dto = null;
       String sid = null;
             sid = request.getParameter("sid");
ppl = (ProtectedPersonLocal)EJBHelper.getLocalInstance(ProtectedPersonLocalHome.JNDI_NAME);
       dto = ppl.getProtectedPersonBySid(sid);
       BeanUtils.copyProperties(ppForm, dto);
....

The values in question are java.lang.String objects. Should be basic stuff right? I stepped through the debugger, and the LazyValidatorForm object is being set correctly for the null strings from my VO; however, when it comes to displaying the form for editing, the "null" fields contain an object reference like [EMAIL PROTECTED] If I update the form with any type of text values, it'll show correctly the next time that I go to update the data. It's only happening when there are null values involved.

Hubert Rabago wrote:

Please provide more information.  How is your form configured/written?
Are there "initial" values?  What is the type of the data from which
you're copying a value?

Hubert


On 5/20/05, Randy Kennedy <[EMAIL PROTECTED]> wrote:
Why does an object reference (e.g. [EMAIL PROTECTED]) show up in
my text fields when I prepopulate the form using Jakarta commons
BeanUtils.copyProperties(...)? The values in the database are null, and I know this has something to do with it, so I guess my real question is,
"How do I fix it?".

--
Randy Kennedy
Appriss, Inc.



--

Randy Kennedy
Software Engineer
Appriss, Inc. (Provider of the VINE Service)
10401 Linn Station Road, Suite 200
Louisville, KY  40223-3842

Web   : http://www.vineco.com, http://www.appriss.com
Email : [EMAIL PROTECTED]




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

Reply via email to