Re: Populating complex java objects in forms

2002-03-11 Thread keithBacon


--- Jon Ferguson [EMAIL PROTECTED] wrote:
 Do you have the appropriate setXXX() method on the customer for name?
 Jon
 
 Charlesworth, Chico wrote:
 
  Hi,
 
  If I've got a complex java object (i.e Customer) in the Form class, I can
  then read off this object in the jsp page, but when submitting to the
 Action
  class the Customer object is null.
 
  The jsp would look like:
  html:form action=/updateCustomer
  Customer Name: html:text property=customer.name/
  br
  a href=javascript:document.forms[0].submit();Update
 Customer/a
  /html:form
 
  So this would display the current customer name, but if I change the
  customer name and then hit the submit link, I find the customer instance is
  now null in the updateCustomer action class.
 
  Am I doing something wrong, or is it not possible to populate complex java
  objects in the jsp form using struts?
 
  Cheers,
  Chico.
 
  --
  The content of this e-mail is confidential, may contain privileged material
  and is intended solely for the recipient(s) named above. If you receive
 this
  in error, please notify Software AG immediately and delete this e-mail.
 
  Software AG (UK) Limited
  Registered in England  Wales 1310740
  Registered Office: Hudson House, Hudson Way,
  Pride Park, Derby DE24 8HS
 
  --
  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]


=
~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

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




RE: Populating complex java objects in forms - PROBLEM SOLVED, BUT IS THIS A BUG IN STRUTS?

2002-03-11 Thread Alex Paransky

There is no way in struts to populate the complex JAVA object with data
simply from a submit form.  If you pre-initialize your complex object then
the submit form will be able to populate customer.name,
customer.address.line1, customer.address.zip but ONLY if you have these in
your form as valid properties.

The method setCustomer(Customer c) or Customer getCustomer() will never be
called because there is no such representation of a customer on the page.
Because your form has a scope of request, it goes away after the request is
complete.  So, when you first show the customer on the screen, I presume,
the Customer object is somehow found and populated and put into the form.
At this point, the request is done and over with.  The Customer object that
you have created has been lost.  When the user hits the submit button, a new
request is created.  Since this new request is calling on the action which
requires a form, a NEW form is created with a NEW Customer member.  If you
initialized the customer to a new Customer(), then struts is able to match
properties and put customer.name in to your customer name or
customer.address.city in to the proper field, but it's NOT the same Customer
object (pointer wise) that you have initially found.

So, if you have other properties in the Customer object which are NOT shown
on the page, then they will be reset to what ever they are when you do an
initial new Customer.

If you want to keep the same form, there are two things you can do:

1. Change the scope from request to session.  This will keep the original
form that you created, and since the original customer object that you have
found and populated in to the form.  Using this method, however, will
probably require that your submit action, removes the data from the session.
Otherwise, your session would contain variables which are no longer used
(bad use of resources).

2. Pre-initialize the customer and all the objects inside of the customer
just like you already did.  This will populate the fields on your .jsp form
back into the customer object, but not all the fields of the customer.  Only
those which are directly used on the form.

These are the options I can think of.

Hope this helps.

-
-AP_
See my profile at
http://www.myprofiles.com/member/view.do?profileId=128


-Original Message-
From: Charlesworth, Chico [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 08, 2002 2:41 AM
To: 'Struts Users Mailing List'
Subject: RE: Populating complex java objects in forms - PROBLEM SOLVED,
BUT IS THIS A BUG IN STRUTS?



I've found that my problem is that my Customer instance was not initialized
in the Form class, but I wouldn't have thought this should be necessary in
Struts. This then also means that any other complex java objects within
customer would need to be instantiated (i.e. Address) and so on if Address
had other complex java objects.

So it works fine if in the form I define:
Customer customer = new Customer();

Also, if I invoke an Action class and create a new instance of customer in
the Customer form and then forward to the customer jsp, it displays the new
instance values ok, but it still doesn't work when submitting the form if
the Customer instance in the form is not instantiated (customer is null
again).

Chico.

-Original Message-
From: Jon Ferguson [mailto:[EMAIL PROTECTED]]
Sent: 08 March 2002 09:12
To: Struts Users Mailing List
Subject: Re: Populating complex java objects in forms

Do you have the appropriate setXXX() method on the customer for name?
Jon

Charlesworth, Chico wrote:

 Hi,

 If I've got a complex java object (i.e Customer) in the Form class, I can
 then read off this object in the jsp page, but when submitting to the
Action
 class the Customer object is null.

 The jsp would look like:
 html:form action=/updateCustomer
 Customer Name: html:text property=customer.name/
 br
 a href=javascript:document.forms[0].submit();Update
Customer/a
 /html:form

 So this would display the current customer name, but if I change the
 customer name and then hit the submit link, I find the customer instance
is
 now null in the updateCustomer action class.

 Am I doing something wrong, or is it not possible to populate complex java
 objects in the jsp form using struts?

 Cheers,
 Chico.

 --
 The content of this e-mail is confidential, may contain privileged
material
 and is intended solely for the recipient(s) named above. If you receive
this
 in error, please notify Software AG immediately and delete this e-mail.

 Software AG (UK) Limited
 Registered in England  Wales 1310740
 Registered Office: Hudson House, Hudson Way,
 Pride Park, Derby DE24 8HS

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


--
The content of this e-mail is confidential, may contain privileged material
and is intended solely for the recipient(s) named above. If you receive this
in error, please notify Software AG

Re: Populating complex java objects in forms

2002-03-08 Thread Jon Ferguson

Do you have the appropriate setXXX() method on the customer for name?
Jon

Charlesworth, Chico wrote:

 Hi,

 If I've got a complex java object (i.e Customer) in the Form class, I can
 then read off this object in the jsp page, but when submitting to the Action
 class the Customer object is null.

 The jsp would look like:
 html:form action=/updateCustomer
 Customer Name: html:text property=customer.name/
 br
 a href=javascript:document.forms[0].submit();Update Customer/a
 /html:form

 So this would display the current customer name, but if I change the
 customer name and then hit the submit link, I find the customer instance is
 now null in the updateCustomer action class.

 Am I doing something wrong, or is it not possible to populate complex java
 objects in the jsp form using struts?

 Cheers,
 Chico.

 --
 The content of this e-mail is confidential, may contain privileged material
 and is intended solely for the recipient(s) named above. If you receive this
 in error, please notify Software AG immediately and delete this e-mail.

 Software AG (UK) Limited
 Registered in England  Wales 1310740
 Registered Office: Hudson House, Hudson Way,
 Pride Park, Derby DE24 8HS

 --
 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]


Populating complex java objects in forms

2002-03-07 Thread Charlesworth, Chico


Hi,

If I've got a complex java object (i.e Customer) in the Form class, I can
then read off this object in the jsp page, but when submitting to the Action
class the Customer object is null.

The jsp would look like:
html:form action=/updateCustomer
Customer Name: html:text property=customer.name/
br
a href=javascript:document.forms[0].submit();Update Customer/a
/html:form

So this would display the current customer name, but if I change the
customer name and then hit the submit link, I find the customer instance is
now null in the updateCustomer action class.

Am I doing something wrong, or is it not possible to populate complex java
objects in the jsp form using struts?

Cheers,
Chico.


-- 
The content of this e-mail is confidential, may contain privileged material
and is intended solely for the recipient(s) named above. If you receive this
in error, please notify Software AG immediately and delete this e-mail.

Software AG (UK) Limited
Registered in England  Wales 1310740
Registered Office: Hudson House, Hudson Way,
Pride Park, Derby DE24 8HS

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




RE: Populating complex java objects in forms

2002-03-07 Thread Ronald Haring

yes you can do that but do you have a getCustomer() and setCustomer() method
in your formbean?

Gr
Ronald 

 -Original Message-
 From: Charlesworth, Chico [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 07, 2002 5:56 PM
 To: 'Struts Users Mailing List'
 Subject: Populating complex java objects in forms
 
 
 
 Hi,
 
 If I've got a complex java object (i.e Customer) in the Form 
 class, I can
 then read off this object in the jsp page, but when 
 submitting to the Action
 class the Customer object is null.
 
 The jsp would look like:
 html:form action=/updateCustomer
   Customer Name: html:text property=customer.name/
   br
   a href=javascript:document.forms[0].submit();Update 
 Customer/a
 /html:form
 
 So this would display the current customer name, but if I change the
 customer name and then hit the submit link, I find the 
 customer instance is
 now null in the updateCustomer action class.
 
 Am I doing something wrong, or is it not possible to populate 
 complex java
 objects in the jsp form using struts?
 
 Cheers,
 Chico.
 
 
 -- 
 The content of this e-mail is confidential, may contain 
 privileged material
 and is intended solely for the recipient(s) named above. If 
 you receive this
 in error, please notify Software AG immediately and delete 
 this e-mail.
 
 Software AG (UK) Limited
 Registered in England  Wales 1310740
 Registered Office: Hudson House, Hudson Way,
 Pride Park, Derby DE24 8HS
 
 --
 To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]


Furore B.V.
Rijswijkstraat 175-8
Postbus 9204
1006 AE Amsterdam
tel. (020) 346 71 71
fax. (020) 346 71 77


---
The information transmitted is intended only for the person
or entity to which it is addressed and may contain confidential
and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other
than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material
from any computer

---




RE: Populating complex java objects in forms

2002-03-07 Thread Charlesworth, Chico


ive got my getter and setter methods in my formbean ...

any other ideas?
chico

-Original Message-
From: Ronald Haring [mailto:[EMAIL PROTECTED]] 
Sent: 07 March 2002 17:04
To: 'Struts Users Mailing List'
Subject: RE: Populating complex java objects in forms

yes you can do that but do you have a getCustomer() and setCustomer() method
in your formbean?

Gr
Ronald 

 -Original Message-
 From: Charlesworth, Chico [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 07, 2002 5:56 PM
 To: 'Struts Users Mailing List'
 Subject: Populating complex java objects in forms
 
 
 
 Hi,
 
 If I've got a complex java object (i.e Customer) in the Form 
 class, I can
 then read off this object in the jsp page, but when 
 submitting to the Action
 class the Customer object is null.
 
 The jsp would look like:
 html:form action=/updateCustomer
   Customer Name: html:text property=customer.name/
   br
   a href=javascript:document.forms[0].submit();Update 
 Customer/a
 /html:form
 
 So this would display the current customer name, but if I change the
 customer name and then hit the submit link, I find the 
 customer instance is
 now null in the updateCustomer action class.
 
 Am I doing something wrong, or is it not possible to populate 
 complex java
 objects in the jsp form using struts?
 
 Cheers,
 Chico.
 
 
 -- 
 The content of this e-mail is confidential, may contain 
 privileged material
 and is intended solely for the recipient(s) named above. If 
 you receive this
 in error, please notify Software AG immediately and delete 
 this e-mail.
 
 Software AG (UK) Limited
 Registered in England  Wales 1310740
 Registered Office: Hudson House, Hudson Way,
 Pride Park, Derby DE24 8HS
 
 --
 To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]


Furore B.V.
Rijswijkstraat 175-8
Postbus 9204
1006 AE Amsterdam
tel. (020) 346 71 71
fax. (020) 346 71 77


---
The information transmitted is intended only for the person
or entity to which it is addressed and may contain confidential
and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other
than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material
from any computer

---


-- 
The content of this e-mail is confidential, may contain privileged material
and is intended solely for the recipient(s) named above. If you receive this
in error, please notify Software AG immediately and delete this e-mail.

Software AG (UK) Limited
Registered in England  Wales 1310740
Registered Office: Hudson House, Hudson Way,
Pride Park, Derby DE24 8HS

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




RE: Populating complex java objects in forms

2002-03-07 Thread Charlesworth, Chico


The scope is request, which should be ok, and other form fields that are
Strings or String Arrays are populated ok, but not complex objects like
Customer.

Any other suggestions?

-Original Message-
From: Oliver Reflé [mailto:[EMAIL PROTECTED]] 
Sent: 07 March 2002 17:10
To: Struts Users Mailing List
Subject: AW: Populating complex java objects in forms

maybe check the scope of your form beans, maybe the one in the form is held
in the session, and the one your action is expection should be in the
request.
If that happens struts generates a new form bean which is empty.

-Ursprüngliche Nachricht-
Von: Charlesworth, Chico [mailto:[EMAIL PROTECTED]]
Gesendet: Donnerstag, 7. März 2002 18:08
An: 'Struts Users Mailing List'
Betreff: RE: Populating complex java objects in forms



ive got my getter and setter methods in my formbean ...

any other ideas?
chico

-Original Message-
From: Ronald Haring [mailto:[EMAIL PROTECTED]]
Sent: 07 March 2002 17:04
To: 'Struts Users Mailing List'
Subject: RE: Populating complex java objects in forms

yes you can do that but do you have a getCustomer() and setCustomer() method
in your formbean?

Gr
Ronald

 -Original Message-
 From: Charlesworth, Chico [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 07, 2002 5:56 PM
 To: 'Struts Users Mailing List'
 Subject: Populating complex java objects in forms



 Hi,

 If I've got a complex java object (i.e Customer) in the Form
 class, I can
 then read off this object in the jsp page, but when
 submitting to the Action
 class the Customer object is null.

 The jsp would look like:
 html:form action=/updateCustomer
   Customer Name: html:text property=customer.name/
   br
   a href=javascript:document.forms[0].submit();Update
 Customer/a
 /html:form

 So this would display the current customer name, but if I change the
 customer name and then hit the submit link, I find the
 customer instance is
 now null in the updateCustomer action class.

 Am I doing something wrong, or is it not possible to populate
 complex java
 objects in the jsp form using struts?

 Cheers,
 Chico.


 --
 The content of this e-mail is confidential, may contain
 privileged material
 and is intended solely for the recipient(s) named above. If
 you receive this
 in error, please notify Software AG immediately and delete
 this e-mail.

 Software AG (UK) Limited
 Registered in England  Wales 1310740
 Registered Office: Hudson House, Hudson Way,
 Pride Park, Derby DE24 8HS

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


Furore B.V.
Rijswijkstraat 175-8
Postbus 9204
1006 AE Amsterdam
tel. (020) 346 71 71
fax. (020) 346 71 77


---
The information transmitted is intended only for the person
or entity to which it is addressed and may contain confidential
and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other
than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material
from any computer

---


--
The content of this e-mail is confidential, may contain privileged material
and is intended solely for the recipient(s) named above. If you receive this
in error, please notify Software AG immediately and delete this e-mail.

Software AG (UK) Limited
Registered in England  Wales 1310740
Registered Office: Hudson House, Hudson Way,
Pride Park, Derby DE24 8HS

--
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]

-- 
The content of this e-mail is confidential, may contain privileged material
and is intended solely for the recipient(s) named above. If you receive this
in error, please notify Software AG immediately and delete this e-mail.

Software AG (UK) Limited
Registered in England  Wales 1310740
Registered Office: Hudson House, Hudson Way,
Pride Park, Derby DE24 8HS

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