Title: RE: A form with valiable number of beans

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

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

Reply via email to