You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Krehbiel <wk...@yahoo.com> on 2002/11/18 07:27:01 UTC

Question about object in struts form

Hello,
I'm new to struts and have tried looking through the
archives here as well as around the web and am unable
to find the answer to my question.  I'm guessing that
it's not possible to do what I want, but figured I'd
ask before giving up...

So, I have a class User that contains a String for
the name, and an Address object for the address (the
Address object contains more Strings, etc for city,
state, zip, address1, etc).  I have defined all the
get/set functions.

I have a form that I want to use to edit the user
info.  No problem to edit the name.  Problem is that
I also want to edit the address fields.  

So, what I was hoping to be able to do was declare
my dyna-form in struts-config to have a form-property
with name="user" and type="org.blah.blah.dao.User". 
Then in the jsp code I would refer to user.name,
user.address.city, etc.  I got this to work fine for
creating and populating the edit page.  The problem
comes about when I try to "save" the changes.  No
matter what I try I get all kinds of errors in the
BeanUtils populate.  

One that I can't seem to get around is that it seems
to want me to have a hidden type for my user object,
and when I do that it complains that it can't conver
from type String to type User.  

The other weird thing is that in the logs it gives
me the following: 
[Thread-4] DEBUG org.apache.struts.util.RequestUtils

-  -->
DynaActionForm[dynaClass=userForm,user=org.taprootfoundation.trweb.dao.User@181497d]
[Thread-4] DEBUG
org.apache.struts.action.RequestProcessor  - Storing
ActionForm bean instance in scope 'session' under
attribute key 'userForm'
[Thread-4] DEBUG
org.apache.struts.action.RequestProcessor  -
Populating bean properties from this request 
[Thread-4] DEBUG
org.apache.commons.beanutils.BeanUtils  -
BeanUtils.populate(DynaActionForm[dynaClass=userForm,user=<NULL>]

I don't understand why it has a value for user within
the userForm, and then seems to "lose" it.  Before I
made my scope session (was request before), it had
NULL throughout the logs.

Any suggestions, or examples, or statements that you
can't do what I'm trying to do are appreciated.

Thanks,
Wendy
wkrehbiel@yahoo.com


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

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