Ganesh,
Assumptions:
1) you have a form with an attribute that is a Collection (ie. List)
2) you have a getter and a setter for this attribute
3) the Collection will have a constant number of elements (in this example, the size is 5
4) the Collection contains Beans with a getShiftNumber() and setShiftNumber() method
5) you have a reset(ActionMapping mapping, HttpServletRequest request) method in your
FormBean that initializes the Collection with your NestedBeans


reset(ActionMapping mapping, HttpServletRequest request) {
        for (int i=0;i< 5;i++) {
              mtList.add(new NestedBean());
        }
    }


To populate the values in the collection, you will have a pre-load action containing code like this:
MyForm myForm = new MyForm(); // this is your FormBean
List mtList = new ArrayList();
mtList.add(new NestedBean("0")); // The NestedBean in this example has a 1 argument
// constructor that initializes the shiftNumber attribute
mtList.add(new NestedBean("1"));
mtList.add(new NestedBean("2"));
mtList.add(new NestedBean("3"));
myForm.setMtList(mtList);
request.setAttribute("theForm", myForm); // replace 'theForm' with your FormBean name from
// your struts-config file


In your jsp page use code similar to this,
<table cellspacing="2" cellpadding="3" border="1" width="100%">
<nested:iterate property="mtList" id="mtlist">
<tr valign="middle" >
<td><nested:radio property="shiftNumber" value='0'></nested:radio></td>
<td><nested:radio property="shiftNumber" value='1'></nested:radio></td>
<td><nested:radio property="shiftNumber" value='2'></nested:radio></td>
<td><nested:radio property="shiftNumber" value='3'></nested:radio></td>
</tr>
</nested:iterate>
</table>


If you follow these instructions, then you will be able to display your nested bean with the radio buttons set and also be able to submit the form and receive the collection of beans with the shiftNumber attribute set according to the user's input.

Regards,

Richard


At 08:58 PM 4/21/2004, you wrote:



Hi friends

I'm always thankful to u 4ur non-stop help towards me.

Here is a problem with <nested:readio>buttons.
Pls observer the sample code.

<nested:iterate property="mtList" id="mtlist">

<tr valign="middle" class="trcolor2">

<td><nested:radio property="shiftnumber" value='0'></nested:radio></td>
<td><nested:radio property="shiftnumber" value='1'></nested:radio></td>
<td><nested:radio property="shiftnumber" value='2'></nested:radio></td>
<td><nested:radio property="shiftnumber" value='3'></nested:radio></td>

</tr>

</nested:iterate>

Now what my intension is to pre-populate values from database to
'radio' buttons whatever value was selected among 4radio buttons which r in a
single row as a group.

i keep waiting 4u reply .

Thanks & Regards
Ganesh


Do you Yahoo!?
Yahoo! Photos: <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=23765/*http://photos.yahoo.c>High-quality 4x6 digital prints for 25¢
X-Apparently-To: [EMAIL PROTECTED] via 66.218.93.75; Wed, 21 Apr 2004 03:38:26 -0700
Return-Path: <[EMAIL PROTECTED]>
Received: from 208.185.179.12 (HELO mail.apache.org) (208.185.179.12)
by mta189.mail.scd.yahoo.com with SMTP; Wed, 21 Apr 2004 03:38:26 -0700
Received: (qmail 58091 invoked by uid 500); 21 Apr 2004 10:38:18 -0000
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
List-Subscribe: <mailto:[EMAIL PROTECTED]>
List-Help: <mailto:[EMAIL PROTECTED]>
List-Post: <mailto:[EMAIL PROTECTED]>
List-Id: "Struts Users Mailing List" <user.struts.apache.org>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Delivered-To: mailing list [EMAIL PROTECTED]
Received: (qmail 58076 invoked from network); 21 Apr 2004 10:38:18 -0000
Received: from unknown (HELO web41403.mail.yahoo.com) (66.218.93.69)
by daedalus.apache.org with SMTP; 21 Apr 2004 10:38:18 -0000
Received: from [61.11.48.57] by web41403.mail.yahoo.com via HTTP; Wed, 21 Apr 2004 03:38:18 PDT
Date: Wed, 21 Apr 2004 03:38:18 -0700 (PDT)
From: ganesh g <[EMAIL PROTECTED]>
Subject: How to pre-populate values to <nested:radio> buttons from Database
To: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="0-1579471758-1082543898=:22536"
X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
Content-Length: 504


Hi friends

I'm always thankful to u 4ur non-stop help towards me.

Here is a problem with <nested:readio>buttons.
Pls observer the sample code.

<nested:iterate property="mtList" id="mtlist">

<tr valign="middle" class="trcolor2">

<td><nested:radio property="shiftnumber" value='0'></nested:radio></td>
<td><nested:radio property="shiftnumber" value='1'></nested:radio></td>
<td><nested:radio property="shiftnumber" value='2'></nested:radio></td>
<td><nested:radio property="shiftnumber" value='3'></nested:radio></td>

</tr>

</nested:iterate>

Now what my intension is to pre-populate values from database to 'radio' buttons whatever value was selected among 4radio buttons which r in a single row as a group.

i keep waiting 4u reply .

Thanks & Regards
Ganesh



---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to