Its certainly the case with dynaforms, that life is easier just to have everything as strings including any nested beans..

<logic:iterate id="amount" name="myFormName" property="bidAmount">
        <html:text property="amount"  indexed="true" />
</logic:iterate>

I'd stick to strings, and perhaps organise things so you have a bid object that you nest in your form.

this would result you being less confused.

<logic:iterate id="bid" name="myForm" property="amount">
        <html:text name="bid" property="amount" indexed="true" />
</logic:iterate>

By your question I guess that your bid object class is part of you object model (stuff from db in this case)

If you using 1.1 here's how i'd be thinking about the problem..

<form-bean name="bidForm">
<form-property name="bid" type="java.util.ArrayList" />
[if you know how big you array is going to be define here, else just scope the form to session.


<action path="/myaction" scope="session" ..

..
a bid bean

..
public class BidBean {
        private String amount;
        
        public String getAmount() {
                return amount;
        }

        public void setAmount(String str) {
                this.amount = str;
        }
}
..

ArrayList bidList = new ArrayList();
bidList.add(new BidBean());

theForm.set("bid",bidList);

request.setAttribute("bid",bidList.toArray());

..

<logic:iterate id="b" name="formName" property="bid">
        <html:text name="b" property="amount" indexed="true" />
</logic:iterate>

..
Assuming you've an existing om and thats why you seem a little concrete in your thinking, here's where to think about bringing stuff together.
..


DynaActionForm theForm = (DynaActionForm) form;

ArrayList bidList = (ArrayList) theForm.get("bid");

for(int i = 0;i < bidList.szie();i++) {
        BidBean bid = (BidBean) bidList.get(i);
        

.. now copy the properties to your model classes. You'll need to change strings to floats etc. and set the values accordingly

}

..

when your action servlets get kinda long, you start moving this sort of thing out to your model layer.

Cheers Mark

On Sunday, October 26, 2003, at 03:01 PM, Todor Sergueev Petkov wrote:

Are you sure you can use float arrays in an ActionForm.
I think ActionForm beans accept only String values. It's up to you
to do conversion from/to Float.

Rajat Pandit wrote:
Hello mark,
This is my situtation This is an extract from my action form
private float[] bidAmount;
public float[] getBidAmount() {
return bidAmount;
}
public void setBidAmount(float[] bidAmount) {
this.bidAmount = bidAmount;
}
In my jsp I want this to store bidAmounts for different products and
hence an array implementation.
This is what I wrote in my jsp.
<html:text property='bidAmount' styleClass="flat" size="3"
indexed="true"/>
I want it to print something like this for the multiple bidAmount
<input type="text" name="bidAmount[0]" >
<input type="text" name="bidAmount[1]" >
<input type="text" name="bidAmount[2]" >
But instead thisis what iam getting.
<input type="text"
name="org.apache.struts.taglib.html.BEAN[0].bidAmount" size="3" value=""
class="flat" />
I don't know if this is right or wrong(nor do I care right now!!!) but
whichever way I need to know how to iterate the data and also in case of
an error, it should re populate the html:text with the data from the
array.
Somebody help!! :(((999999
-----Original Message-----
From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: Sunday, October 26, 2003 4:47 AM
To: Struts Users Mailing List
Subject: Re: Multiple parameters
Need to know what your validator.xml looks like and form-bean stuff in your struts-config.
Just sticking <html:radio indexed="true" .. doesn't say very much.. and just because its displayed doesn't mean its working..
So give more detail have read the documents. Forget about databases for now and just think about getting your form properties into your action.
is the form property an indexed property? How are they defined (actionForm or dynaactionform?)
On Sunday, October 26, 2003, at 05:30 AM, Rajat Pandit wrote:
Hello,
I am still stuck with the multiple parameter problem. I shall try to explain the problem again. Maybe someone could help. I have a form, which has a number of records to be displayed. A checkbox, a textbox, two radio buttons with the same name. I have the following objective.


A. perform validation for the checkbox that is selected. I need to ensure that textbox contains value greater that zero and either of the
radio buttons where selected B. I need to iterate though the list of data. Ie for the checkbox that was selected and then save the information in the database.


I have tried using <html:radio indexed="true" which seems to work, but
I
still cant figure out how to iterate though it as I will need to do that
in the validate() and execute() method.


Pls gimme some pointers or help :(((

Really really stuck!





Rajat Pandit | [EMAIL PROTECTED]
+91 612 3117606
[ Developer and Part Time Human Being]


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



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



Reply via email to