PropertyUtils.copyProperties and DynaValidatorForm

2003-08-14 Thread jack beany
Hi All,

Trying to do a
PropertyUtils.copyProperties(DynaValidatorForm,mybean)
to copy the current values of my bean into my DynaValidatorForm and I hit a 
java.lang.NullPointerException when it tries to do this.

Problem seems to be when I check for the form parameter (ActionForm - 
Execute), and try to create one if it doesnt exist:
form = new DynaValidatorForm();
this fails to instanciate a new instance, leaving form==null.

How *should* I be passing values to DynaValidatorForm?!

Thanks
J
_
Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: PropertyUtils.copyProperties and DynaValidatorForm

2003-08-14 Thread jack beany
Hi Adam,

From: Adam Hardy [EMAIL PROTECTED]
Yes that's the way to populate the DVForm. If you need a form the easiest 
way to instantiate it is to make sure it is set in the struts-config.xml
form = new DynaValidatorForm();
Any idea why this leaves form=null?  The form I'm going to populate is 
defined in the struts config file.  Could you provide a small code snippet 
that would go in the execute method?

Thanks
J.
_
Tired of 56k? Get a FREE BT Broadband connection 
http://www.msn.co.uk/specials/btbroadband

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


Re: PropertyUtils.copyProperties and DynaValidatorForm

2003-08-14 Thread Adam Hardy
Sure. This is what I do in my action (where form is passed into execute())

DynaValidatorActionForm sectionForm = (DynaValidatorActionForm) form;
Long sectionId = new Long((String) sectionForm.get(id));
if (sectionId == null) throw new Exception(Section ID cannot be null!);
//now we try to get the data object
SectionFactory sectionFactory = new SectionFactory();
Section section = sectionFactory.getByPrimaryKey(conn, sectionId);
BeanUtils.copyProperties(sectionForm, section);
Once struts is configured OK then you will always get a form - that's 
why I don't check to see if it's null.

This is the stuff in struts-config:

  form-beans
form-bean   name=sectionForm
type=org.apache.struts.validator.DynaValidatorActionForm
  form-property name=id
 type=java.lang.String/
  form-property name=index
 type=java.lang.String/
  form-property name=title
 type=java.lang.String/
  form-property name=dateCreated
 type=java.lang.String/
  form-property name=dateDeleted
 type=java.lang.String/
/form-bean
and

actionpath=/secure/startSectionUpdate
   type=org.blacksail.linklib.section.SectionAction
   name=sectionForm
  scope=request
   validate=false
  parameter=display
  roles=user
  set-property property=secure value=false/
  forward name=finished   path=.section/
/action
Perhaps you've not matched the form name in the form def. and the 
mapping. Or perhaps you've configured the types in the form def wrong 
which could cause an exception. Just guessing. Maybe you should check 
your logs.

Good luck,
Adam
jack beany wrote:
Hi Adam,

From: Adam Hardy [EMAIL PROTECTED]
Yes that's the way to populate the DVForm. If you need a form the 
easiest way to instantiate it is to make sure it is set in the 
struts-config.xml

form = new DynaValidatorForm();


Any idea why this leaves form=null?  The form I'm going to populate is 
defined in the struts config file.  Could you provide a small code 
snippet that would go in the execute method?

Thanks
J.
_
Tired of 56k? Get a FREE BT Broadband connection 
http://www.msn.co.uk/specials/btbroadband

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

--
struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: PropertyUtils.copyProperties and DynaValidatorForm

2003-08-14 Thread Adam Hardy
Yes that's the way to populate the DVForm. If you need a form the 
easiest way to instantiate it is to make sure it is set in the 
struts-config.xml

Adam

jack beany wrote:
Hi All,

Trying to do a
PropertyUtils.copyProperties(DynaValidatorForm,mybean)
to copy the current values of my bean into my DynaValidatorForm and I 
hit a java.lang.NullPointerException when it tries to do this.

Problem seems to be when I check for the form parameter (ActionForm - 
Execute), and try to create one if it doesnt exist:
form = new DynaValidatorForm();
this fails to instanciate a new instance, leaving form==null.

How *should* I be passing values to DynaValidatorForm?!

Thanks
J
_
Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

--
struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: PropertyUtils.copyProperties and DynaActionForm concepts

2003-03-08 Thread Joseph Fifield
What about BeanUtils.copyProperties? AFAIK, PropertyUtils.copyProperties
assumes the source and destination properties are the same datatype and no
conversion is done, but BeanUtils.copyProperties handles conversions to a
different datatype using the help of ConvertUtils. Maybe this is the
problem...?

Joe

- Original Message -
From: Joao Araujo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 07, 2003 10:46 PM
Subject: PropertyUtils.copyProperties and DynaActionForm concepts


 Hi,

 Nowadays I use PropertyUtils.copyProperties to make the copy of property
from
 the form to the database Bean easier. But, I realized that I cant use it
 the same
 way with DynaActionForm. What have you guys been using in this situation.

 Ex. of using propertyUtils.
 PropertyUtils.copyProperties(device, deviceForm);


 Thanks in advance.

 Joao,


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





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



PropertyUtils.copyProperties and DynaActionForm concepts

2003-03-07 Thread Joao Araujo
Hi,

		Nowadays I use PropertyUtils.copyProperties to make the copy of property from
		the form to the database Bean easier. But, I realized that I cant use it 
the same
		way with DynaActionForm. What have you guys been using in this situation.

Ex. of using propertyUtils.
PropertyUtils.copyProperties(device, deviceForm);
		Thanks in advance.

Joao, 

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


Re: PropertyUtils.copyProperties and DynaActionForm concepts

2003-03-07 Thread Dave Newton
On Fri, 2003-03-07 at 22:46, Joao Araujo wrote:
   Nowadays I use PropertyUtils.copyProperties to make the copy of 
 property from
   the form to the database Bean easier. But, I realized that I cant use 
 it 
 the same
   way with DynaActionForm. What have you guys been using in this 
 situation.
 
   Ex. of using propertyUtils.
   PropertyUtils.copyProperties(device, deviceForm);

Um... I'm using DynaValidatorActionForms with that no problem.

Dave



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



RE: PropertyUtils.copyProperties() usage in 1.1-b2

2002-11-17 Thread Brian Topping
Craig, Rana,

thanks for your responses, hoping you guys can provide some input:

 From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
 Subject: Re: PropertyUtils.copyProperties() usage in 1.1-b2
 
  I'm trying to figure out what I am doing wrong with
  PropertyUtils.copyProperties().  From within my Action, I have:
 
  User user = bean;
  DynaActionForm regForm = (DynaActionForm) form;
  PropertyUtils.copyProperties(regForm, user);
 
  When I look at what copyProperties is doing, it's getting a
  PropertyDescriptor array from getPropertyDescriptors() with the user
  bean correctly, then it iteratively tries to see if the 
 regForm has any
  of the properties found in the user bean.  But calling
  getPropertyDescriptor(regForm, fieldname) seems to be 
 comparing the
  (correct) field names from the bean against the *structure* of the
  DynaActionForm component (i.e. the multipartRequestHandler, 
 dynaClass,
  servlet, etc), instead of the DynaFields that I set up in my
  form-bean/.
 
 
 Which CVS version number of PropertyUtils are you looking at 
 (second line
 of the sources?  The version I'm looking at, 1.32 (i.e. the current
 nightly builds), does not call getPropertyDescriptors() on a DynaBean.

K, here's what I'm seeing under PropertyUtils 1.32:

in copyProperties:

orig is neither Map nor DynaBean, so line 283 calls
getPropertyDescriptors(orig).  Then, for each readMethod in the result, line
296 has:

   String name = origDescriptors[i].getName();
   if (getPropertyDescriptor(dest, name) != null) {

But getting into getPropertyDescriptor(), line 869 calls
getPropertyDescriptors(bean).  If the dest is a DynaBean, I'm not seeing
where the instanceof DynaBean is -- it simply calls
Introspector.getBeanInfo().getPropertyDescriptors(), but the result of
getBeanInfo doesn't know anything about DynaBeans.

What am I missing here?  Rana says this is working and appreciate his input,
especially with the release notes reference (thanks!)  But tracing through
the code and triple-checking at the beans (they both have a name property),
I still can't see how this is going to work, and in practice, the destination
DynaBean is untouched.

Thanks again,

-b

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




PropertyUtils.copyProperties() usage in 1.1-b2

2002-11-16 Thread Brian Topping
Hi all, happy friday (again... :)

I'm trying to figure out what I am doing wrong with
PropertyUtils.copyProperties().  From within my Action, I have:

User user = bean;
DynaActionForm regForm = (DynaActionForm) form;
PropertyUtils.copyProperties(regForm, user);

When I look at what copyProperties is doing, it's getting a
PropertyDescriptor array from getPropertyDescriptors() with the user bean
correctly, then it iteratively tries to see if the regForm has any of the
properties found in the user bean.  But calling
getPropertyDescriptor(regForm, fieldname) seems to be comparing the
(correct) field names from the bean against the *structure* of the
DynaActionForm component (i.e. the multipartRequestHandler, dynaClass,
servlet, etc), instead of the DynaFields that I set up in my form-bean/.

I don't think nested properties are the answer, and copyProperties() is
supposed to work with DynaBean in the source, destination, both or neither.  

Any ideas?  The code seems to work fine when the source and destination are
reversed.  I'm using 1.1-b2.

Thanks a bunch,

Brian

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




PropertyUtils.copyProperties() usage in 1.1-b2

2002-11-16 Thread Brian Topping
Hi all, happy friday (again... :)

I'm trying to figure out what I am doing wrong with
PropertyUtils.copyProperties().  From within my Action, I have:

User user = bean;
DynaActionForm regForm = (DynaActionForm) form;
PropertyUtils.copyProperties(regForm, user);

When I look at what copyProperties is doing, it's getting a
PropertyDescriptor array from getPropertyDescriptors() with the user bean
correctly, then it iteratively tries to see if the regForm has any of the
properties found in the user bean.  But calling
getPropertyDescriptor(regForm, fieldname) seems to be comparing the
(correct) field names from the bean against the *structure* of the
DynaActionForm component (i.e. the multipartRequestHandler, dynaClass,
servlet, etc), instead of the DynaFields that I set up in my form-bean/.

I don't think nested properties are the answer, and copyProperties() is
supposed to work with DynaBean in the source, destination, both or neither.  

Any ideas?  The code seems to work fine when the source and destination are
reversed.  I'm using 1.1-b2.

Thanks a bunch,

Brian

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




PropertyUtils.copyProperties() usage in 1.1-b2

2002-11-15 Thread Brian Topping
Hi all, happy friday (again... :)

I'm trying to figure out what I am doing wrong with
PropertyUtils.copyProperties().  From within my Action, I have:

User user = bean;
DynaActionForm regForm = (DynaActionForm) form;
PropertyUtils.copyProperties(regForm, user);

When I look at what copyProperties is doing, it's getting a
PropertyDescriptor array from getPropertyDescriptors() with the user
bean correctly, then it iteratively tries to see if the regForm has any
of the properties found in the user bean.  But calling
getPropertyDescriptor(regForm, fieldname) seems to be comparing the
(correct) field names from the bean against the *structure* of the
DynaActionForm component (i.e. the multipartRequestHandler, dynaClass,
servlet, etc), instead of the DynaFields that I set up in my
form-bean/.

I don't think nested properties are the answer, and copyProperties() is
supposed to work with DynaBean in the source, destination, both or
neither.  

Any ideas?  The code seems to work fine when the source and destination
are reversed.  I'm using 1.1-b2.

Thanks a bunch,

Brian

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




Re: PropertyUtils.copyProperties() usage in 1.1-b2

2002-11-15 Thread Craig R. McClanahan


On Fri, 15 Nov 2002, Brian Topping wrote:

 Date: Fri, 15 Nov 2002 12:10:53 -0800 (PST)
 From: Brian Topping [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: PropertyUtils.copyProperties() usage in 1.1-b2

 Hi all, happy friday (again... :)

 I'm trying to figure out what I am doing wrong with
 PropertyUtils.copyProperties().  From within my Action, I have:

 User user = bean;
 DynaActionForm regForm = (DynaActionForm) form;
 PropertyUtils.copyProperties(regForm, user);

 When I look at what copyProperties is doing, it's getting a
 PropertyDescriptor array from getPropertyDescriptors() with the user
 bean correctly, then it iteratively tries to see if the regForm has any
 of the properties found in the user bean.  But calling
 getPropertyDescriptor(regForm, fieldname) seems to be comparing the
 (correct) field names from the bean against the *structure* of the
 DynaActionForm component (i.e. the multipartRequestHandler, dynaClass,
 servlet, etc), instead of the DynaFields that I set up in my
 form-bean/.


Which CVS version number of PropertyUtils are you looking at (second line
of the sources?  The version I'm looking at, 1.32 (i.e. the current
nightly builds), does not call getPropertyDescriptors() on a DynaBean.

 I don't think nested properties are the answer, and copyProperties() is
 supposed to work with DynaBean in the source, destination, both or
 neither.

 Any ideas?  The code seems to work fine when the source and destination
 are reversed.  I'm using 1.1-b2.


Please try a recent nightly build.  Besides bugfixes in Struts, there have
been bugfixes in the Commons packages as well.

 Thanks a bunch,

 Brian

Craig


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




RE: PropertyUtils.copyProperties() usage in 1.1-b2

2002-11-15 Thread VEDRE, RANAPRATAP REDDY

 try getting the latest version of commons-beanutils.jar from commons
project version(1.5), if u dont want to upgrade to nightly build of struts,
but use struts 1.1b2.

  In  version 1.5 of commons package, PropertyUtils works in both
directions. release notes for version 1.5 montions about this fix.

You may also want to look at BeanUtils.copyProperties(bean, bean)

-Rana


-Original Message-
From: Brian Topping [mailto:topping;spies.com]
Sent: Friday, November 15, 2002 3:11 PM
To: [EMAIL PROTECTED]
Subject: PropertyUtils.copyProperties() usage in 1.1-b2


Hi all, happy friday (again... :)

I'm trying to figure out what I am doing wrong with
PropertyUtils.copyProperties().  From within my Action, I have:

User user = bean;
DynaActionForm regForm = (DynaActionForm) form;
PropertyUtils.copyProperties(regForm, user);

When I look at what copyProperties is doing, it's getting a
PropertyDescriptor array from getPropertyDescriptors() with the user
bean correctly, then it iteratively tries to see if the regForm has any
of the properties found in the user bean.  But calling
getPropertyDescriptor(regForm, fieldname) seems to be comparing the
(correct) field names from the bean against the *structure* of the
DynaActionForm component (i.e. the multipartRequestHandler, dynaClass,
servlet, etc), instead of the DynaFields that I set up in my
form-bean/.

I don't think nested properties are the answer, and copyProperties() is
supposed to work with DynaBean in the source, destination, both or
neither.  

Any ideas?  The code seems to work fine when the source and destination
are reversed.  I'm using 1.1-b2.

Thanks a bunch,

Brian

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

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




Re: PropertyUtils.copyProperties() usage in 1.1-b2

2002-11-15 Thread Brian Topping
 
 
 
 On Fri, 15 Nov 2002, Brian Topping wrote:
 
  Date: Fri, 15 Nov 2002 12:10:53 -0800 (PST)
  From: Brian Topping [EMAIL PROTECTED]
  Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: PropertyUtils.copyProperties() usage in 1.1-b2
 
  Hi all, happy friday (again... :)
 
  I'm trying to figure out what I am doing wrong with
  PropertyUtils.copyProperties().  From within my Action, I have:
 
  User user = bean;
  DynaActionForm regForm = (DynaActionForm) form;
  PropertyUtils.copyProperties(regForm, user);
 
  When I look at what copyProperties is doing, it's getting a
  PropertyDescriptor array from getPropertyDescriptors() with the user
  bean correctly, then it iteratively tries to see if the regForm has any
  of the properties found in the user bean.  But calling
  getPropertyDescriptor(regForm, fieldname) seems to be comparing the
  (correct) field names from the bean against the *structure* of the
  DynaActionForm component (i.e. the multipartRequestHandler, dynaClass,
  servlet, etc), instead of the DynaFields that I set up in my
  form-bean/.
 
 
 Which CVS version number of PropertyUtils are you looking at (second line
 of the sources?  The version I'm looking at, 1.32 (i.e. the current
 nightly builds), does not call getPropertyDescriptors() on a DynaBean.

I was using 1.30, but the code I was looking at seems to be the same on
both 1.32 and 1.30.

  I don't think nested properties are the answer, and copyProperties() is
  supposed to work with DynaBean in the source, destination, both or
  neither.
 
  Any ideas?  The code seems to work fine when the source and destination
  are reversed.  I'm using 1.1-b2.
 
 
 Please try a recent nightly build.  Besides bugfixes in Struts, there have
 been bugfixes in the Commons packages as well.

Yes, trying that now, no luck.  I guess it sounds like a local issue,
since you probably would have recognized if I had been doing something
silly :)

I'll keep looking, it just doesn't seem to be doing an instanceof on the
dest bean anywhere in the call chain to see if it should treat the
DynaBean differently.

 
  Thanks a bunch,
 
  Brian
 
 Craig

thanks again,

-b

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




RE: PropertyUtils.copyProperties() usage in 1.1-b2 ; problem using validation with LookupDispatchAction

2002-11-15 Thread VEDRE, RANAPRATAP REDDY

 I am able to get copyProperties to work with BeanUtils and PropertyUtils
using version 1.5 of commons beanutils.

1. i am using DynaValidatorForm. 
2. i have a BeanInfoClass for my bean providing the PropertyDescriptors.

 try replacing the commons-beanutils.jar with the latest version(1.5) of
commons beanutils.

 i have one more issue, has anybody succesfully combined Validator
Framework, Dynamic Forms and LookupDispatchAction .

I am using DynaValidatorForm, but my form us not validated even if have
validate=true in my action mapping.

validation of DynaValidatorForm worked fine before using
LookupDispatchAction.

-rana.



-Original Message-
From: Brian Topping [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 15, 2002 8:16 PM
To: [EMAIL PROTECTED]
Subject: Re: PropertyUtils.copyProperties() usage in 1.1-b2


 
 
 
 On Fri, 15 Nov 2002, Brian Topping wrote:
 
  Date: Fri, 15 Nov 2002 12:10:53 -0800 (PST)
  From: Brian Topping [EMAIL PROTECTED]
  Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: PropertyUtils.copyProperties() usage in 1.1-b2
 
  Hi all, happy friday (again... :)
 
  I'm trying to figure out what I am doing wrong with
  PropertyUtils.copyProperties().  From within my Action, I have:
 
  User user = bean;
  DynaActionForm regForm = (DynaActionForm) form;
  PropertyUtils.copyProperties(regForm, user);
 
  When I look at what copyProperties is doing, it's getting a
  PropertyDescriptor array from getPropertyDescriptors() with the user
  bean correctly, then it iteratively tries to see if the regForm has any
  of the properties found in the user bean.  But calling
  getPropertyDescriptor(regForm, fieldname) seems to be comparing the
  (correct) field names from the bean against the *structure* of the
  DynaActionForm component (i.e. the multipartRequestHandler, dynaClass,
  servlet, etc), instead of the DynaFields that I set up in my
  form-bean/.
 
 
 Which CVS version number of PropertyUtils are you looking at (second line
 of the sources?  The version I'm looking at, 1.32 (i.e. the current
 nightly builds), does not call getPropertyDescriptors() on a DynaBean.

I was using 1.30, but the code I was looking at seems to be the same on
both 1.32 and 1.30.

  I don't think nested properties are the answer, and copyProperties() is
  supposed to work with DynaBean in the source, destination, both or
  neither.
 
  Any ideas?  The code seems to work fine when the source and destination
  are reversed.  I'm using 1.1-b2.
 
 
 Please try a recent nightly build.  Besides bugfixes in Struts, there have
 been bugfixes in the Commons packages as well.

Yes, trying that now, no luck.  I guess it sounds like a local issue,
since you probably would have recognized if I had been doing something
silly :)

I'll keep looking, it just doesn't seem to be doing an instanceof on the
dest bean anywhere in the call chain to see if it should treat the
DynaBean differently.

 
  Thanks a bunch,
 
  Brian
 
 Craig

thanks again,

-b

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

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




RE: PropertyUtils.copyProperties

2002-09-25 Thread Darren Hill


Help.

Can't get this to work.

I've got a 'view' object Company ... trying to populate a DynaForm?

Is that possible?

CompanyView view = service.getCompany(Integer.valueOf(1));
DynaActionForm dynaForm = (DynaActionForm) form;
System.err.println(view.getName());  --- Gives me CIBC

PropertyUtils.copyProperties(dynaForm, view);
System.err.println(dynaForm.getName());  Gives me null;

Actually, I'd love to be able to do this straight from an EJB.

Ideas?

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




PropertyUtils.copyProperties

2002-09-23 Thread Darren Hill

Help.

Can't get this to work.

I've got a 'view' object Company ... trying to populate a DynaForm?

Is that possible?

CompanyView view = service.getCompany(Integer.valueOf(1));
DynaActionForm dynaForm = (DynaActionForm) form;
System.err.println(view.getName());  --- Gives me CIBC

PropertyUtils.copyProperties(dynaForm, view);
System.err.println(dynaForm.getName());  Gives me null;

Ideas?

-Original Message-
From: Zahid Rahman [mailto:[EMAIL PROTECTED]]
Sent: September 23, 2002 3:37 PM
To: Struts Users Mailing List
Subject: Re: logging in struts


Oh look!
Mention Academia and these people get up tight.

I will correct your grammar for you.
 I 'am'  highly suspicion 'who' this character is, in fact, a bot.  He got
lucky on a .

I was never on the JSP-INTEREST list , yesterday or today.
That is your friends doing the impersonations.

I am convinced that you people who are on the  user mailing,
stay on it to impress.
Do you want to know how impressed I am ..

Calling me names in an email list just tells me that you are not only
academically challenge but when challenged  because your are academically
challenged,
you stoop to making quite cowardly remarks.

The best posting I have read so far was the one written by
Galbreath, Mark.
He wrote we wrote our own login form. Would you like to have the .java
Chapter 21 shows you how to write a login form using the struts framework.

If you point your browser at this link
www.objectworlds.com in the near future.
You will see a complete web application using the
struts framework.

I very strongly suggest that you read the philosophy  behind
Model2.
It says that Craig Mclaughlan is heading the Model2 framework,
So that anyone wishing to use it can simply
use it and not have to write your own.
-
- Original Message -
From: Eddie Bush [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, September 23, 2002 8:10 PM
Subject: Re: logging in struts


 I highly suspicion this character is, in fact, a bot.  He got lucky on a
 soundex match that came close to approximating the topic of interest.
  That's what I discount it to - nothing more.  If I'm incorrect, I
 apologize in advance.  It will take some serious convincing to make me
 believe he isn't though ...

 Hajratwala, Nayan (N.) wrote:

 Agreed that some previous posts have been pretty sketchy, but it seems to
me that in this case he may have just misunderstood the question logging in
struts to mean logging in IN struts... in which case his suggestion is
probably valid.
 
 ---
 - Nayan Hajratwala
 - Chikli Consulting LLC
 - http://www.chikli.com
 

 --
 Eddie Bush




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



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

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




Problem with PropertyUtils.copyProperties(...

2002-06-12 Thread Juan Alvarado \(Struts List\)

I am using a DynaActionForm:
form-bean name=userForm
   dynamic=true
   type=org.apache.struts.validator.DynaValidatorForm 
   form-property name=id type=java.lang.String/
   form-property name=firstName type=java.lang.String/
   form-property name=lastName type=java.lang.String/
   form-property name=dispatch type=java.lang.String/
/form-bean

I want to perform the following in my action:
 DynaActionForm f = (DynaActionForm)form;
   User user = new User();
 try{
PropertyUtils.copyProperties(user, f);
}
catch(Exception e){...}

My user object is composed as follows:
package ob.users;

public class UserDTO {

private String firstName;
private String lastName;
private Integer id;

public java.lang.String getFirstName() {
return firstName;
}
public Integer getId() {
return id;
}
public java.lang.String getLastName() {
return lastName;
}
public void setFirstName(java.lang.String value) {
firstName = value;
}
public void setId(Integer value) {
id = value;
}
public void setLastName(java.lang.String value) {
lastName = value;
}
}

And I keep on getting Error creating DTO -- java.lang.NoSuchMethodException:
Unknown property 'class'

I am relatively new using the bean utils package and I didn't find anything
in the archives. Can anyone tell me what I'm doing wrong.

Thanks in advance

**
Juan Alvarado
Internet Developer -- Manduca Management
(786)552-0504
[EMAIL PROTECTED]
AOL Instant Messenger: [EMAIL PROTECTED]


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




Re: Problem with PropertyUtils.copyProperties(...

2002-06-12 Thread Rick Reumann

Juan,

I think I made a mistake (sort of) when I shared some of this code. I
didn't realize you don't need the dispatch field (or whatever you want
to name it) in the actual DynaActionForm or an ActionForm. I notice
that the UserDTO doesn't have the dispatch member in it, so maybe the
PropertyUtils is looking for to convert that field from the
DynaActionForm? (Not sure though just a guess since I haven't used
PropertyUtils ). Try just removing the
form-property name=dispatch type=java.lang.String/
from the DyanActionForm and see what happens.

Rick


On Wednesday, June 12, 2002, 11:15:40 AM, Juan wrote:

JASL I am using a DynaActionForm: form-bean name=userForm
JASL dynamic=true
JASL type=org.apache.struts.validator.DynaValidatorForm 
JASL form-property name=id type=java.lang.String/
JASL form-property name=firstName type=java.lang.String/
JASL form-property name=lastName type=java.lang.String/
JASL form-property name=dispatch type=java.lang.String/
JASL /form-bean

JASL I want to perform the following in my action:
JASL  DynaActionForm f = (DynaActionForm)form;
JASLUser user = new User();
JASL  try{
JASL PropertyUtils.copyProperties(user, f);
JASL }
JASL catch(Exception e){...}

JASL My user object is composed as follows:
JASL package ob.users;

JASL public class UserDTO {

JASL private String firstName;
JASL private String lastName;
JASL private Integer id;

JASL public java.lang.String getFirstName() {
JASL return firstName;
JASL }
JASL public Integer getId() {
JASL return id;
JASL }
JASL public java.lang.String getLastName() {
JASL return lastName;
JASL }
JASL public void setFirstName(java.lang.String value) {
JASL firstName = value;
JASL }
JASL public void setId(Integer value) {
JASL id = value;
JASL }
JASL public void setLastName(java.lang.String value) {
JASL lastName = value;
JASL }
JASL }

JASL And I keep on getting Error creating DTO -- java.lang.NoSuchMethodException:
JASL Unknown property 'class'

JASL I am relatively new using the bean utils package and I didn't find anything
JASL in the archives. Can anyone tell me what I'm doing wrong.

JASL Thanks in advance

JASL **
JASL Juan Alvarado
JASL Internet Developer -- Manduca Management
JASL (786)552-0504
JASL [EMAIL PROTECTED]
JASL AOL Instant Messenger: [EMAIL PROTECTED]


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



-- 

Rick
mailto:[EMAIL PROTECTED]

I wish I had a dollar for every time I spent a dollar, because then,
Yahoo!, I'd have all my money back. 
  -Jack Handey


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




Re: PropertyUtils.copyProperties question...

2002-04-12 Thread Klaasjan Brand

Corneliu Rachieru wrote:
 I have a bean called adminMap(a java.util.HashMap) defined that contains the
 keys id, username, password. I also have a DynaActionForm named form
 defined in the struts-config.xml as
  
   form-bean  name=adminForm
   dynamic=true
   type=org.apache.struts.action.DynaActionForm
   form-property name=actiontype=java.lang.String/
   form-property name=id
 type=java.lang.String/
   form-property name=username
 type=java.lang.String/
   form-property name=password
 type=java.lang.String/
   /form-bean
 
 I've been trying to copy the contents of the my hashmap to the form using:
 
   PropertyUtils.copyProperties(form, adminMap);
 
 but that doesn't work (or at least it doesn't work in that form).
 However, if i copy the properties like this it works fine.
 
   ((DynaActionForm) form).set(id, adminMap.get(id));
   ((DynaActionForm) form).set(username, (String)
 adminMap.get(username));
   ((DynaActionForm) form).set(password, (String)
 adminMap.get(password));
 
 I would really like to use PropertyUtils.copyProperties since that way i can
 keep my application truly dynamic and i don't have to access any properties
 in the actual code (except for struts-config but that's ok). Am I trying to
 do something crazy here (it was my understanding that
 PropertyUtils.copyProperties supports this, but i could be wrong) ? Also,
 did anyone dynamically copy a hashmap to a DynaActionForm in any dynamic way
 ?
 

To copy from a map to a dynabean you need to use BeanUtils.populate. 
I've used it and it works. Looking through the source code for BeanUtils 
is a good idea because a lot of DynaBeans functionality is not 
implemented yet...

greets,
Klaasjan



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




RE: PropertyUtils.copyProperties question...

2002-04-12 Thread Corneliu Rachieru

Thanks for the suggestion.

BeanUtils.populate works like one my initial custom solution, but the
problem is that if my HashMap contains extra attributes that were not
defined in the DynaActionForm, attempting to set those attributes causes an
exception ( i would like them to be either ignored or added to the form). 

Any suggestions as to how this can be achieved ? (basically, i would need to
get a list/map/collection of DynaActionForm's properties (which i though i
could do with 

BeanUtils.describe(((DynaActionForm) form).getDynaClass()));

but that doesn't work ), and set each property from the hashmap
individually by checking if the key exists in the property list of the
DynaActionForm. Is it me, or is there no way of doing this ?

Thank you,
 Cornelius



To copy from a map to a dynabean you need to use BeanUtils.populate. 
I've used it and it works. Looking through the source code for BeanUtils 
is a good idea because a lot of DynaBeans functionality is not 
implemented yet...

greets,
Klaasjan

-Original Message-
From: Klaasjan Brand [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 12, 2002 3:00 AM
To: Struts Users Mailing List
Subject: Re: PropertyUtils.copyProperties question...
Importance: High


Corneliu Rachieru wrote:
 I have a bean called adminMap(a java.util.HashMap) defined that contains
the
 keys id, username, password. I also have a DynaActionForm named form
 defined in the struts-config.xml as
  
   form-bean  name=adminForm
   dynamic=true
   type=org.apache.struts.action.DynaActionForm
   form-property name=action
type=java.lang.String/
   form-property name=id
 type=java.lang.String/
   form-property name=username
 type=java.lang.String/
   form-property name=password
 type=java.lang.String/
   /form-bean
 
 I've been trying to copy the contents of the my hashmap to the form using:
 
   PropertyUtils.copyProperties(form, adminMap);
 
 but that doesn't work (or at least it doesn't work in that form).
 However, if i copy the properties like this it works fine.
 
   ((DynaActionForm) form).set(id, adminMap.get(id));
   ((DynaActionForm) form).set(username, (String)
 adminMap.get(username));
   ((DynaActionForm) form).set(password, (String)
 adminMap.get(password));
 
 I would really like to use PropertyUtils.copyProperties since that way i
can
 keep my application truly dynamic and i don't have to access any
properties
 in the actual code (except for struts-config but that's ok). Am I trying
to
 do something crazy here (it was my understanding that
 PropertyUtils.copyProperties supports this, but i could be wrong) ? Also,
 did anyone dynamically copy a hashmap to a DynaActionForm in any dynamic
way
 ?
 

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



PropertyUtils.copyProperties question...

2002-04-11 Thread Corneliu Rachieru

I have a bean called adminMap(a java.util.HashMap) defined that contains the
keys id, username, password. I also have a DynaActionForm named form
defined in the struts-config.xml as
 
form-bean  name=adminForm
dynamic=true
type=org.apache.struts.action.DynaActionForm
form-property name=actiontype=java.lang.String/
form-property name=id
type=java.lang.String/
form-property name=username
type=java.lang.String/
form-property name=password
type=java.lang.String/
/form-bean

I've been trying to copy the contents of the my hashmap to the form using:

PropertyUtils.copyProperties(form, adminMap);

but that doesn't work (or at least it doesn't work in that form).
However, if i copy the properties like this it works fine.

((DynaActionForm) form).set(id, adminMap.get(id));
((DynaActionForm) form).set(username, (String)
adminMap.get(username));
((DynaActionForm) form).set(password, (String)
adminMap.get(password));

I would really like to use PropertyUtils.copyProperties since that way i can
keep my application truly dynamic and i don't have to access any properties
in the actual code (except for struts-config but that's ok). Am I trying to
do something crazy here (it was my understanding that
PropertyUtils.copyProperties supports this, but i could be wrong) ? Also,
did anyone dynamically copy a hashmap to a DynaActionForm in any dynamic way
?

Thank you,
 Corneliu




PropertyUtils.copyProperties function

2002-02-02 Thread Henry Lu

It seems to me that PropertyUtils.copyProperties doesn't work properly.
Could anyone show me how it works? The following is my code and output:
//
  RegForm theRegForm = (RegForm)form;
  Student stdt = (Student)session.getAttribute(student);
  Address addr = (Address)session.getAttribute(address);

  if (stdt == null) {
System.out.println(\tStudent null!!!);
  }

  try {
System.out.println(\tid=+theRegForm.getId());
System.out.println(\tcity=+theRegForm.getCity());
 PropertyUtils.copyProperties(theRegForm, stdt);
 PropertyUtils.copyProperties(theRegForm, addr);

System.out.println(\tid=+stdt.getId());
System.out.println(\tcity=+addr.getCity());
  } catch (Exception e) {
System.out.println(\t+e.toString());
  }

/
output:
id=123
city=Ann Arbor
id=null
city=null


---
Henry Lu
MCITphone: (734) 936-2063
University of Michigan Medical Center   fax:   (734) 763-4372


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




using PropertyUtils.copyProperties on an entity bean

2001-11-01 Thread jelmer

Hi all,

I am running into some trouble mapping between form beans and entity
beans.
Looking through the mailarchives I found out that the best way to use
ejbs with stuts is to load and unload ejbs in the struts actions. So
that's exactly what I did.
However when trying to map the contents of the formbean to an container
managed entitybean using the propertyutils form the apache commons
project 1.1 The bean stops being persistent. 

eg. In the following example :

profile.setUsername(before);
PropertyUtils.copyProperties(profile, regform);
profile.setUsername (after);

the first setUsername is stored to the database
the propertyUtils copy the properties correctly however they are not
stored to the underlying database
any subsequent setter calls don't get stored eighter. So the username is
never set to after.

I am running resin cmp 1.03 on linux with a mysql backend.
To me this seems like a bug in the resin ejb 2 implementation. 
But I could be missing something as I don't have a lot of experience
using ejb's.
So I'd like to make sure before taking this to the folks at caucho
Does someone have an idea what could be causing this.

--
  Jelmer



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




Re: PropertyUtils.copyProperties and session forms

2001-08-01 Thread Craig R. McClanahan



On Thu, 19 Jul 2001, Matt Raible wrote:

 If I configure a form to be stored in the session for both an
 EditAction and SaveAction, should I have to do the following?
 
PropertyUtils.copyProperties(sessionForm, editForm);
 

You can do this.  Or, if the data is literally the same, you might just
consider using the same form bean for both actions.

 Thanks,
 
 Matt
 
Craig





PropertyUtils.copyProperties and session forms

2001-07-19 Thread Matt Raible



If I configure a form to be stored in the session 
for both an EditAction and SaveAction, should I have to do the 
following?

PropertyUtils.copyProperties(sessionForm,editForm);

Thanks,

Matt


PropertyUtils.copyProperties

2001-07-11 Thread Matt Raible



We have the following 
architecture/flow:

components:
List.jsp
EditAction.java
EntityForm.java (contains get/set for action, 
get/set for EntityDO)
EntityDO.java
Detail.jsp
SaveAction.java

A user clicks on a link in List.jsp to view the 
details of an item.
The EditAction servlet creates an EntityDO and puts 
it into the session and the EntityForm.

 
PropertyUtils.setNestedProperty(form, "DO", createdDO);

The Detail.jsp displays the form elements from the 
DO just fine.
The SaveAction servlet is called when the user 
submits changes from the form.
The SaveAction servlet grabs the DO from the 
session and uses the following line to copy elements from the form into the DO 
from the session

 
PropertyUtils.copyProperties(sessionDO,PropertyUtils.getNestedProperty(form,"DO"));

The problem I am having is that I want ONLY the 
elements from the form that are displayed on the screen to be copied into the 
sessionDO - HOWEVER, it is copying ALL DO attributes - and many of them are 
getting set to their default values.

What I would like is that the sessionDO retains all 
values that are not displayed in the form. The weird thing is that some 
values are retained from the session, but some are not - and the form seems to 
be resetting some values.

I hope I am doing something wrong and this can be 
fixed. My workaround in the meantime is to put all DO attributes as hidden 
fields in the form, but this seems like a real pain.

Thanks,

Matt


PropertyUtils.copyProperties

2001-04-12 Thread Fred Lo

Hi all,

I just wonder if anyone have a utility class that is perform something to 
PropertyUtils.copyProperties() but with type conversion?

The reason is that I am coding all my ActionForm with string (for validation 
concern) but the underlying objects are in their respective type, so there 
is some tedious coding that copy the properties from the form/object back 
and forth.

Any help will be appreciated.

Fred
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




RE: PropertyUtils.copyProperties

2001-04-12 Thread Cook, Levi

Hi Fred,

In its current form, its not locale-sensitive on date conversion (that could
be fixed), but it served my needs for converting previously validated
strings. It also supports going the other direction, ie., converting a Date
object to a formatted String. Support for other types could be easily added
too.


private StringConverter sc = new StringConverter();

// snippet from populating my Form
this.setBirthDate(null == contact.getBirthDate()
? null : sc.formatDate(contact.getBirthDate()));

// snippet from getting my domain object from the form
contact.setBirthDate(null == getBirthDate()
 ? null : sc.toDate(getBirthDate()));


Hope its useful,
Levi

-Original Message-
From: Fred Lo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 12, 2001 5:25 AM
To: [EMAIL PROTECTED]
Subject: PropertyUtils.copyProperties


Hi all,

I just wonder if anyone have a utility class that is perform something to 
PropertyUtils.copyProperties() but with type conversion?

The reason is that I am coding all my ActionForm with string (for validation

concern) but the underlying objects are in their respective type, so there 
is some tedious coding that copy the properties from the form/object back 
and forth.

Any help will be appreciated.

Fred
_
Get your FREE download of MSN Explorer at http://explorer.msn.com


 StringConverter.java
 StringValidator.java


PropertyUtils.copyProperties usage

2001-04-12 Thread Natra, Uday

Hi All,
Is it necessary that all the attributes of Form Beans should be strings?
Should I represent my dates also as strings??

If I use non string data types for the dates in my Model objects then how
can I use the PropertyUtils.copyProperties(formBean, Object)  method to copy
the data from my model obejct to the Form Bean??

Can any one comment on this? Ur feed back is really appreciated.

Thanks,
Uday.



PropertyUtils.copyProperties ?

2001-03-20 Thread Maya Muchnik

Hi,

If I am using PropertyUtils.copyProperties(user, info) then original bean
info must to have all properties that user bean has? If info has only 3
properties, and user has 18, copy will not work? I need to use this way,
because, for example, logon form needs only 3 properties, but user form (full
user info) has 18 properties. And only user bean has a method (function) to
check if a user is legal.

Thanks in advance.

Maya




Re: PropertyUtils.copyProperties ?

2001-03-20 Thread Maya Muchnik

Thank you, Craig. You were right. I had removed (and forgot) a hidden property,
because I cannot figure out how to replace "nested tags".

Can somebody help me to replace html:hidden property="B" value='bean:message key
="A"/'/
Do I need to use jsp:useBean ...jsp:getProperty... and bean class is
org.apache.struts.BEAN ...

Thanks,

Maya

"Craig R. McClanahan" wrote:

 On Tue, 20 Mar 2001, Maya Muchnik wrote:

  Hi,
 
  If I am using PropertyUtils.copyProperties(user, info) then original bean
  info must to have all properties that user bean has? If info has only 3
  properties, and user has 18, copy will not work? I need to use this way,
  because, for example, logon form needs only 3 properties, but user form (full
  user info) has 18 properties. And only user bean has a method (function) to
  check if a user is legal.
 

 The copyProperties() method will only copy when the property names
 match.  It will ignore any unmatching properties in the origin or
 destination beans.

  Thanks in advance.
 
  Maya
 
 

 Craig




Re: PropertyUtils.copyProperties ?

2001-03-20 Thread Craig R. McClanahan



On Tue, 20 Mar 2001, Maya Muchnik wrote:

 Hi,
 
 If I am using PropertyUtils.copyProperties(user, info) then original bean
 info must to have all properties that user bean has? If info has only 3
 properties, and user has 18, copy will not work? I need to use this way,
 because, for example, logon form needs only 3 properties, but user form (full
 user info) has 18 properties. And only user bean has a method (function) to
 check if a user is legal.
 

The copyProperties() method will only copy when the property names
match.  It will ignore any unmatching properties in the origin or
destination beans.

 Thanks in advance.
 
 Maya
 
 

Craig





PropertyUtils.copyProperties and EJB beans

2001-03-12 Thread Bryan Field-Elliot
I am trying to use copyProperties()
to copy everything FROM a standard bean, TO an enterprise javabean (entity
bean). When I do so, I get the following exception:

   Name: java.lang.IllegalArgumentExceptionMessage: object is not an instance of declaring class  Stack: java.lang.IllegalArgumentException: object is not an instance of declaring class	at java.lang.reflect.Method.invoke(Native Method)	at org.apache.struts.util.PropertyUtils.getSimpleProperty(PropertyUtils.java:591)	at org.apache.struts.util.PropertyUtils.copyProperties(PropertyUtils.java:207)	at com.reachmydoctor.ejb.patientSessionBean.createAccount(patientSessionBean.java:109)

I suspect this may have something to do with the fact that my destination,
being a remote interface, is a funky jBoss proxy class and not a standard
bean at all. Nevertheless is there any way I can get this to work? I was
really counting on this working... Otherwise I have about 65 properties to
copy by hand!

Thanks,

Bryan