Title: RE: A form with valiable number of beans

Joe,

Struts actually gets the bean from either the request or the session.

In your action class or actionservlet create any object that you want and
add it to the request or the session.  Struts will perform a "findAttribute"
to get the object with the same name out of the request or session

What we do is make sure that the object that we add to the session has an
ArrayList of other objects. It is this ArrayList that we are iterating through.

Struts doesn't care what object is in the ArrayList, as long as it has get and
set methods.

So you should be able to create your Order Object in your java class, add an
ArrayList of OrderLines and then add the whole Order object to the request
or session.

Hope this helps.

Geoff

-----Original Message-----
From: Joe Peer [mailto:[EMAIL PROTECTED]]
Sent: Friday, 8 December 2000 3:27
To: [EMAIL PROTECTED]
Cc: Oliphant, Geoff
Subject: RE: A form with valiable number of beans


hi!

i've got another question regarding the "valiable number of beans" - problem

  i am using a similar workaround as Geoff explained.

my question acutally is: Goeff, gets your ActionForm - Bean populated
automatically by struts or do you have to set the "dynamic" properties (the
order items) by hand (this is how i am doing that) ?

thanks,
joe


At 01:00 07.12.00, you wrote:

>Lars,
>
>I assume you're trying to generate unique text names for each object of your
>bean that you are iterating through.
>
>We haven't used the struts:text tags because of this, we use the normal html
>input tag but use the struts htmlProperty tag to get the data out:
>
><struts:iterate id="order" name="currentOrderBean" property="orderLines">
><input type="text"
>         name=TXT<struts:htmlProperty name="order" property="orderNumber"/>
>         maxlength="6"
>         size="6"
>         value=<struts:htmlProperty name="order" property="orderValue"/>>
>
></struts:iterate>
>
>This will replace the values of the orderNumber and orderValue in the
>JSP when it is generated and voila - uniquely named text boxes.
>
>If you submit the form then you just have to get the parameters out of
>the request that start with TXT and you've got your primary keys.
>
>Hope this helps.
>
>Geoff
>
>-----Original Message-----
>From: Lars [<mailto:[EMAIL PROTECTED]>mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, 6 December 2000 17:55
>To: [EMAIL PROTECTED]
>Subject: A form with valiable number of beans
>
>I am trying to use Struts to create a page where I am editing an Entity
>(e.g. an order) and a variable number of sub-entities (e.g. order lines). I
>have corresponding beans in my session (an Order bean with a vector holding
>a number of OrderLine beans).
>
>I would like to have certain properties of all sub-entities open for editing
>and the page being recreated with all the values if it is submitted and the
>displayed again.
>
>How could I use the ActionForm and the tag-library to be able to use the
>automatic population of the properties of the form bean?
>
>I have tried to use the logic:iterate tag to build the list of order lines
>but stumbled on the naming of each text field. For example, the quantities
>field would have to be named "quantity1", quantity2", etc. If I use the
>form:text tag I can specify the bean and the property, but this gives me an
>identical name for all "quantity" fields. Even if I manage to uniquely name
>the fields, how can I create an ActionForm with corresponding properties to
>be set by the framework.
>
>Maybe I have to do this manually? Any suggestions how?
>
>If this has been discussed before, please point me to an approximate time
>frame.
>
>Regards,
>Lars Andersson
>
>
>
>
>================================================================================================
>IMPORTANT INFORMATION
>
>This message and any files transmitted with it are confidential and should
>be read only by those
>persons to whom it is addressed.
>If you have received this message in error, please notify us immediately
>by way of reply. Please
>also destroy and delete the message from your computer. Any unauthorised
>form of reproduction
>of this message is strictly prohibited.
>
>It is the duty of the recipient to virus scan and otherwise test the
>information provided before
>loading onto any computer system.
>SEALCORP does not warrant that the information is free of a virus or any
>other defect or error.
>
>SEALCORP is not liable for the proper and complete transmission of the
>information contained in
>this communication, nor for any delay in its receipt.
>
>Any views expressed in this message are those of the individual sender,
>except where the sender
>specifically states them to be the views of SEALCORP.
>
>================================================================================================



================================================================================================
IMPORTANT INFORMATION

This message and any files transmitted with it are confidential and should be read only by those
persons to whom it is addressed.
If you have received this message in error, please notify us immediately by way of reply. Please
also destroy and delete the message from your computer. Any unauthorised form of reproduction
of this message is strictly prohibited.

It is the duty of the recipient to virus scan and otherwise test the information provided before
loading onto any computer system.
SEALCORP does not warrant that the information is free of a virus or any other defect or error.

SEALCORP is not liable for the proper and complete transmission of the information contained in
this communication, nor for any delay in its receipt.

Any views expressed in this message are those of the individual sender, except where the sender
specifically states them to be the views of SEALCORP.

================================================================================================

Reply via email to