Re: problem with indexed property and logic:iterate

2005-06-14 Thread Nitesh

Just passing you a solution I had got from the user list earlier

Nitesh

- Original Message - 
From: "John Fitzpatrick" <[EMAIL PROTECTED]>

To: "Struts Users Mailing List" 
Sent: Friday, June 03, 2005 6:06 PM
Subject: Re: Problem using indexed properties and validator framework



In the struts-config.xml:

   
   
   


   
   
 
   


In EditUsersAction.java execute method

   // get collection of users from the database
   Collection users = getUserBeans ();

   // put collection into form as an array for editing
   form.set ( "users", users.toArray ( new UserBean[0] ) );

In editUsers.jsp

   
   
   

In the produced HTML:

   

If you need to client side validation, you'll probably need to write your
own JSP to deal with the element above.

As for using validate.xml to validate on the server side. I've never tried
it with arrays, I just iterate over them in the validate (...) method of 
the

form, like so:

   UserBean users[] = (UserBean[]) form.get ( "users" );
   for ( int i = 0; i < users.length; i++ ) {
   // check on the attributes of UserBean users[i]
   }

Hope that example clears it up for you.

John



On 20050603 5:05 AM, "Nitesh" <[EMAIL PROTECTED]> wrote:


Thanks for the answer John...

Could you give me an example as to how we pre populate the array?

Regards,
Nitesh
- Original Message -
From: "John Fitzpatrick" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Thursday, June 02, 2005 6:00 PM
Subject: Re: Problem using indexed properties and validator framework




For an Array in a DynaForm property, you can either set the size in the
form-property descriptor or, in the case of a session form, pre-populate
the
Array in your action with the number of elements you desire.





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



problem with indexed property and logic:iterate

2005-06-14 Thread Marco Mistroni
Hello all,
I have a DynaActionForm with two properties of type  String[],
one named priorities and the other named owner

I am having problem in displaying their value in my jsp using
logic:iterate

My JSP is as follows


   

   
 

 
1
2
3
4
5
   
  

 



somehow I cannot set the value of both owners and priorities for each
line..

anyone could help?  Unfortunately I cannot use JSTL  so if someone
could point out what I am doing wrong...

thanx in advance and regards
marco 


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