Re: How to create form rows dynamically

2005-06-29 Thread Nitesh

Probably you should try using the validator framework for validation.
you could avoid using the custom form in case you just use it for 
validation.

You could add in your validations into the validation-rules and use it.

Make sure your form has sesion scope.
That apart, Im not sure why you don't get the updated values...


Nitesh


- Original Message - 
From: "Ciaran Hanley" <[EMAIL PROTECTED]>

To: "'Struts User Mailing List'" 
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, June 28, 2005 7:23 PM
Subject: Re: How to create form rows dynamically


Hi,

I followed the example you attached and it seemed to have worked except when
I submit the form I cannot get at the form values.

For example when I submit the form if the newAmnt text box gets a new value
of say 10.00, the value on the server side is still returned as 0.00 (the
original value).

Would you know what might cause this? I am using a form which extends
DynaActionForm so I can use the validation method.

-Original Message-
From: Nitesh [mailto:[EMAIL PROTECTED]
Sent: 23 June 2005 10:50
To: Struts Users Mailing List
Subject: Re: How to create form rows dynamically

Attaching the answer John had given me for indexed properties.
Hope this would help...


- Original Message - 
From: "Ciaran Hanley" <[EMAIL PROTECTED]>

To: "'Struts User Mailing List'" 
Sent: Thursday, June 23, 2005 3:01 PM
Subject: How to create form rows dynamically



Can somebody help me or propose a solution to the following please.



I wish to create a form dynamically. Depending on the business logic there
could be 0 to N rows in the form. I tried to use a form with an array of
strings and use the indexed="true" setting in the html:text boxes but as I
was not following any example I ran into problems and didn't have any
guide
as to where I was going wrong.



I also need to iterate over a bean containing information which
corresponds
to the form as the form boxes are being displayed.



Say if there is 3 rows required, it should ok like the following.



Payment Old AmntNew Amnt  Date

1   35  [45]  [12/12/04]

2   35  [45]  [12/01/05]

3   35  [45]  [12/02/05]



Where [] represents a html:text box.



I am also unsure as to how to access these values when I get to the
form/action classes.



Any help would be much appreciated!












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



Re: How to create form rows dynamically

2005-06-28 Thread Ciaran Hanley
Hi,

I followed the example you attached and it seemed to have worked except when
I submit the form I cannot get at the form values.

For example when I submit the form if the newAmnt text box gets a new value
of say 10.00, the value on the server side is still returned as 0.00 (the
original value).

Would you know what might cause this? I am using a form which extends
DynaActionForm so I can use the validation method.

-Original Message-
From: Nitesh [mailto:[EMAIL PROTECTED] 
Sent: 23 June 2005 10:50
To: Struts Users Mailing List
Subject: Re: How to create form rows dynamically

Attaching the answer John had given me for indexed properties.
Hope this would help...


- Original Message - 
From: "Ciaran Hanley" <[EMAIL PROTECTED]>
To: "'Struts User Mailing List'" 
Sent: Thursday, June 23, 2005 3:01 PM
Subject: How to create form rows dynamically


> Can somebody help me or propose a solution to the following please.
>
>
>
> I wish to create a form dynamically. Depending on the business logic there
> could be 0 to N rows in the form. I tried to use a form with an array of
> strings and use the indexed="true" setting in the html:text boxes but as I
> was not following any example I ran into problems and didn't have any 
> guide
> as to where I was going wrong.
>
>
>
> I also need to iterate over a bean containing information which 
> corresponds
> to the form as the form boxes are being displayed.
>
>
>
> Say if there is 3 rows required, it should ok like the following.
>
>
>
> Payment Old AmntNew Amnt  Date
>
> 1   35  [45]  [12/12/04]
>
> 2   35  [45]  [12/01/05]
>
> 3   35  [45]  [12/02/05]
>
>
>
> Where [] represents a html:text box.
>
>
>
> I am also unsure as to how to access these values when I get to the
> form/action classes.
>
>
>
> Any help would be much appreciated!
>
>
>
> 
--- Begin Message ---
Title: Re: Problem using indexed properties and validator framework






In the struts-config.xml:


    

    

    



    

    

  path="/application/EditUsers"

  type="application.EditUsersAction"

  name="EditUsersForm"

  scope="session"

    >

  

    name="success"

    path="editUsers.jsp"

    redirect="false"

  />

    



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]




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

Re: How to create form rows dynamically

2005-06-23 Thread Michael Jouravlev
On 6/23/05, Ciaran Hanley <[EMAIL PROTECTED]> wrote:
> Can somebody help me or propose a solution to the following please.
> 
> I wish to create a form dynamically. Depending on the business logic there
> could be 0 to N rows in the form.
...
> I also need to iterate over a bean containing information which corresponds
> to the form as the form boxes are being displayed.
...
> I am also unsure as to how to access these values when I get to the
> form/action classes.

Adding to other replies: would you care to take a look at CRUDAction.
It does not display the list by itself, but sample code contains the
helper action which displays the list and all needed buttons for CRUD
operations: http://struts.sourceforge.net/strutsdialogs/crudaction.html
The item list is displayed using array list of items.
You can download it here:
http://sourceforge.net/project/showfiles.php?group_id=49385&release_id=336852

Michael.

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



Re: How to create form rows dynamically

2005-06-23 Thread Stéphane Zuckerman

Ciaran Hanley a écrit :

Can somebody help me or propose a solution to the following please.

 


I wish to create a form dynamically. Depending on the business logic there
could be 0 to N rows in the form. I tried to use a form with an array of
strings and use the indexed="true" setting in the html:text boxes but as I
was not following any example I ran into problems and didn't have any guide
as to where I was going wrong.

 


I also need to iterate over a bean containing information which corresponds
to the form as the form boxes are being displayed.

 


Say if there is 3 rows required, it should ok like the following.

 


Payment Old AmntNew Amnt  Date

1   35  [45]  [12/12/04]

2   35  [45]  [12/01/05]

3   35  [45]  [12/02/05]

 


Where [] represents a html:text box.

 


I am also unsure as to how to access these values when I get to the
form/action classes.

 


Any help would be much appreciated!


There are a few ways to do that. The most obvious (according to me) 
would be to have a "Billing" (for instance) class, with all the 
attributes that suit you, then :


- use a lazy list (go to 
http://wiki.apache.org/struts/StrutsCatalogLazyList for more information 
about them) to store them. The use of LazyList instead of "classical" 
List (with ArrayList) is all about indexes : when you start from the 
server and you display the items stored in your list, all is fine.


(something like :









)

But when the user clicks on the submit button, a horrible thing happens 
: IndexOutOfBoundException (because a new List is instanciated from the 
server side - the old one has been lost as it is a new request - and 
currently, something like formList.get(0) returns null, which isn't what 
Struts expected). So you have to make some mechanism to return an object 
(preferably of the right kind) so Struts remains happy. Hence the LazyLists.


--
Stéphane Zuckerman

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



Re: How to create form rows dynamically

2005-06-23 Thread Nitesh

Attaching the answer John had given me for indexed properties.
Hope this would help...


- Original Message - 
From: "Ciaran Hanley" <[EMAIL PROTECTED]>

To: "'Struts User Mailing List'" 
Sent: Thursday, June 23, 2005 3:01 PM
Subject: How to create form rows dynamically



Can somebody help me or propose a solution to the following please.



I wish to create a form dynamically. Depending on the business logic there
could be 0 to N rows in the form. I tried to use a form with an array of
strings and use the indexed="true" setting in the html:text boxes but as I
was not following any example I ran into problems and didn't have any 
guide

as to where I was going wrong.



I also need to iterate over a bean containing information which 
corresponds

to the form as the form boxes are being displayed.



Say if there is 3 rows required, it should ok like the following.



Payment Old AmntNew Amnt  Date

1   35  [45]  [12/12/04]

2   35  [45]  [12/01/05]

3   35  [45]  [12/02/05]



Where [] represents a html:text box.



I am also unsure as to how to access these values when I get to the
form/action classes.



Any help would be much appreciated!




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


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

RE: How to create form rows dynamically

2005-06-23 Thread Abhinav Bhatnagar

I had the same question some time back and I used this :

http://struts.apache.org/userGuide/building_controller.html

refer section "4.3.2 Map-backed ActionForms"

Regards,
Abhinav

-Original Message-
From: Ciaran Hanley [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 23, 2005 3:02 PM
To: 'Struts User Mailing List'
Subject: How to create form rows dynamically

Can somebody help me or propose a solution to the following please.



I wish to create a form dynamically. Depending on the business logic
there
could be 0 to N rows in the form. I tried to use a form with an array of
strings and use the indexed="true" setting in the html:text boxes but as
I
was not following any example I ran into problems and didn't have any
guide
as to where I was going wrong.



I also need to iterate over a bean containing information which
corresponds
to the form as the form boxes are being displayed.



Say if there is 3 rows required, it should ok like the following.



Payment Old AmntNew Amnt  Date

1   35  [45]  [12/12/04]

2   35  [45]  [12/01/05]

3   35  [45]  [12/02/05]



Where [] represents a html:text box.



I am also unsure as to how to access these values when I get to the
form/action classes.



Any help would be much appreciated!




 CAUTION - Disclaimer *
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not to copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful. This e-mail may contain viruses. 
Infosys has taken every reasonable precaution to minimize this risk, but is not 
liable for any damage you may sustain as a result of any virus in this e-mail. 
You should carry out your own virus checks before opening the e-mail or 
attachment. Infosys reserves the right to monitor and review the content of all 
messages sent to or from this e-mail address. Messages sent to or from this 
e-mail address may be stored on the Infosys e-mail system.
***INFOSYS End of Disclaimer INFOSYS***

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