Re: dynamic form action flow

2002-02-01 Thread Ted Husted

> SavePhoneNumberAction.java --> editPhoneNumbers.do

It may be that this is looking up the original phone number again. 

If so, this is also where the recyling message could be coming into it. 

Do you want to go back through the edit action, or straight to the
display page?

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


Jeff Oberlander wrote:
> 
> Ok, I've wasted an embarrassing amount of time on this and would appreciate
> any help.  Its night now and no progress has been made.  This is another
> action flow question.  Maybe there is a sample somewhere that does this?  I
> apologize that this is long.
> 
> I have an action form that contains an ArrayList of items (lets say phone
> numbers). The form allows me to edit existing numbers or add new ones.
> When I go to the editPhoneNumbers.jsp page, it displays all of my phone
> numbers based on the ArrayList with a button to add another and a button to
> save the form. I start with a single phone number - e.g. my home number. If
> you hit "add", the form should be re-displayed with 2 phone number fields -
> my home one, and a new blank one - both editable.
> 
> This is the action flow I currently have:
> 
> editPhoneNumbers.do --> EditPhoneNumberAction.java (input is PhoneNumberForm
> - containing an ArrayList of numbers) - this loads my current phone numbers
> from the data store into the form.
> 
> EditPhoneNumberAction --> editPhoneNumber.jsp - this displays the form.
> 
> editPhoneNumber.jsp --> SavePhoneNumberAction.java (action = add | save)
> 
> SavePhoneNumberAction.java - if the action is add, I add an empty
> PhoneNumber object to the ActionForm ArrayList, then I want to redisplay the
> form with the original item, and the blank new one.
> 
> SavePhoneNumberAction.java --> editPhoneNumbers.do
> 
> Loop is complete.
> I thought this would be as simple as adding a new item to the ArrayList in
> the form and forwarding on the original form.  It doesn't work.  I keep
> getting back (in the display) only my home phone number (the original form
> without the new object)  I suspect it is related to this log message:
> "Recycling existing ActionForm bean instance of class ".  Another
> interesting point is even though I explicitly set the action property of the
> form in SavePhoneNumberAction, it always comes into EditPhoneNumberAction as
> null.
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: dynamic form action flow

2002-02-01 Thread Jon.Ridgway

Hi Jeff,

The struts-example.war app does just this, except it uses subscriptions
instead of phone numbers. It's part of the struts download, under webapps.

Jon.

-Original Message-
From: Jeff Oberlander [mailto:[EMAIL PROTECTED]] 
Sent: 01 February 2002 06:08
To: '[EMAIL PROTECTED]'
Subject: dynamic form action flow

Ok, I've wasted an embarrassing amount of time on this and would appreciate
any help.  Its night now and no progress has been made.  This is another
action flow question.  Maybe there is a sample somewhere that does this?  I
apologize that this is long.  

I have an action form that contains an ArrayList of items (lets say phone
numbers). The form allows me to edit existing numbers or add new ones.
When I go to the editPhoneNumbers.jsp page, it displays all of my phone
numbers based on the ArrayList with a button to add another and a button to
save the form. I start with a single phone number - e.g. my home number. If
you hit "add", the form should be re-displayed with 2 phone number fields -
my home one, and a new blank one - both editable.  

This is the action flow I currently have:

editPhoneNumbers.do --> EditPhoneNumberAction.java (input is PhoneNumberForm
- containing an ArrayList of numbers) - this loads my current phone numbers
from the data store into the form.

EditPhoneNumberAction --> editPhoneNumber.jsp - this displays the form.

editPhoneNumber.jsp --> SavePhoneNumberAction.java (action = add | save)

SavePhoneNumberAction.java - if the action is add, I add an empty
PhoneNumber object to the ActionForm ArrayList, then I want to redisplay the
form with the original item, and the blank new one.

SavePhoneNumberAction.java --> editPhoneNumbers.do

Loop is complete.
I thought this would be as simple as adding a new item to the ArrayList in
the form and forwarding on the original form.  It doesn't work.  I keep
getting back (in the display) only my home phone number (the original form
without the new object)  I suspect it is related to this log message:
"Recycling existing ActionForm bean instance of class ".  Another
interesting point is even though I explicitly set the action property of the
form in SavePhoneNumberAction, it always comes into EditPhoneNumberAction as
null.








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

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




dynamic form action flow

2002-01-31 Thread Jeff Oberlander

Ok, I've wasted an embarrassing amount of time on this and would appreciate
any help.  Its night now and no progress has been made.  This is another
action flow question.  Maybe there is a sample somewhere that does this?  I
apologize that this is long.  

I have an action form that contains an ArrayList of items (lets say phone
numbers). The form allows me to edit existing numbers or add new ones.
When I go to the editPhoneNumbers.jsp page, it displays all of my phone
numbers based on the ArrayList with a button to add another and a button to
save the form. I start with a single phone number - e.g. my home number. If
you hit "add", the form should be re-displayed with 2 phone number fields -
my home one, and a new blank one - both editable.  

This is the action flow I currently have:

editPhoneNumbers.do --> EditPhoneNumberAction.java (input is PhoneNumberForm
- containing an ArrayList of numbers) - this loads my current phone numbers
from the data store into the form.

EditPhoneNumberAction --> editPhoneNumber.jsp - this displays the form.

editPhoneNumber.jsp --> SavePhoneNumberAction.java (action = add | save)

SavePhoneNumberAction.java - if the action is add, I add an empty
PhoneNumber object to the ActionForm ArrayList, then I want to redisplay the
form with the original item, and the blank new one.

SavePhoneNumberAction.java --> editPhoneNumbers.do

Loop is complete.
I thought this would be as simple as adding a new item to the ArrayList in
the form and forwarding on the original form.  It doesn't work.  I keep
getting back (in the display) only my home phone number (the original form
without the new object)  I suspect it is related to this log message:
"Recycling existing ActionForm bean instance of class ".  Another
interesting point is even though I explicitly set the action property of the
form in SavePhoneNumberAction, it always comes into EditPhoneNumberAction as
null.








--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Dynamic Form Beans?

2001-09-06 Thread Tuscano, Stephen

Hi John,

  Are you able to slove this problem?if so, Can you help me out?

Stephen.


> -Original Message-
> From: John Townsend [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 8:19 PM
> To:   [EMAIL PROTECTED]; 'Luis Olivares'
> Subject:  RE: Dynamic Form Beans?
> 
> The one idea that I had was to create a new subclass of ActionForm
> called ActionDataForm. This form would have get and put methods that use
> keys instead of the usual pattern of numerous getters/setters. 
>  
> 
> For the process of saving form data, we could add a new override to
> RequestUtils.processPopulate(..) which would take an ActionDataForm
> instead of an ActionForm as its form instance. Then we would implement
> this method to use get and put with keys instead of getters/setters.
> 
> One problem: I don't know how the populate works from the other side
> (meaning when you want to prepopulate a form based on the contents of a
> JavaBean in the session, etc.). I imagine that logic is contained in the
> HTML tag libraries or some other tag library.
> 
> I guess what I am wondering is that since a number of people have run
> into this and needed a solution I assumed that there might already be a
> solution to this problem. If not, maybe we can find a solution and then
> submit a patch to Struts for 1.1 or something.
> 
> Anyone else have any thoughts on this?
> 
> -- John Townsend
> 
> PS. One thing I just thought of: I wonder if there is a JavaBeans
> solution to this problem? If there is, that might be a better way to go.
> 
> 
> -Original Message-
> From: Luis Olivares [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, August 29, 2001 11:28 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Dynamic Form Beans?
> 
> I have the same 'problem'.
> 
> I would like to be able to create a form dynamically depending on the
> structure of a table (I used to do this with 'plain' JSP).
> Any ideas?
> 
> Regards.
>Luis Olivares.
>[EMAIL PROTECTED]
>--
>   "Intelligence is the ability to avoid doing
>work, yet getting the work done"
>   --Linus Torvalds--
> 
> - Original Message -
> From: "John Townsend" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 29, 2001 12:54 PM
> Subject: Dynamic Form Beans?
> 
> 
> > I am working on a project where is would be nice to have the ability
> to
> > define a dynamic form bean (i.e. a form bean where the fields are
> > defined at runtime). The most obvious (but perhaps not the best)
> > solution to this problem would be if the ActionServlet could handle
> > saving data in a form bean that was a hashtable.
> >
> > Has someone else run into this problem and come up with a solution?
> >
> > Thanks,
> > -- John Townsend
> >



RE: Dynamic Form Beans?

2001-08-30 Thread Rey Francois

One part of the solution is to use the MappedProperty feature recently added
to the jakarta-commons bean-utils.
The original submission is in this message:
http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03005.html

It has been integrated into the commons source, as indicated by this
message:
http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03596.html

Also look at this message for a bug that needs to be fixed (hopefully the
patch will be committed soon):
http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03897.html

Other relevant messages are referenced in this one:
http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03429.html


Hope this helps,

Fr.

-Original Message-
From: John Townsend [mailto:[EMAIL PROTECTED]]
Sent: 29 August 2001 19:54
To: [EMAIL PROTECTED]
Subject: Dynamic Form Beans?


I am working on a project where is would be nice to have the ability to
define a dynamic form bean (i.e. a form bean where the fields are
defined at runtime). The most obvious (but perhaps not the best)
solution to this problem would be if the ActionServlet could handle
saving data in a form bean that was a hashtable. 

Has someone else run into this problem and come up with a solution? 

Thanks,
-- John Townsend
 


The information in this email is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorised. If you are not
an intended recipient, you must not read, use or disseminate the
information contained in the email.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Capco.

http://www.capco.com
***




Re: Dynamic Form Beans?

2001-08-29 Thread martin . cooper

On the input side, it sounds like what you want is a map that is basically a
copy of the map usually used internally by the servlet container to
represent parameters. If you don't mind having copies in the map of what's
also in any explicit form bean fields, you could just use this at the top of
the reset() method in your form bean (or a base class).

HashMap map = new HashMap(); // Actually, this would be an instance
variable
for (Enumeration e = request.getParameterNames(); e.hasMoreElements();)
{
String name = (String)e.nextElement();
map.put(name, request.getParameterValues(name));
}

The output side is a little different because the Struts tags are set up to
look only for explicit fields. There's been at least one proposal for
changing that, though.

However, this is what I refer to as an "uncontrolled" dynamic form bean.
More interesting would be a "controlled" dynamic form bean, where the valid
fields are actually controlled externally, rather than being at the whim of
the request (or other code). But then, that's a bunch more work. :-)

--
Martin Cooper


- Original Message -
From: "John Townsend" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "'Luis Olivares'"
<[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 12:19 PM
Subject: RE: Dynamic Form Beans?


> The one idea that I had was to create a new subclass of ActionForm
> called ActionDataForm. This form would have get and put methods that use
> keys instead of the usual pattern of numerous getters/setters.
>
>
> For the process of saving form data, we could add a new override to
> RequestUtils.processPopulate(..) which would take an ActionDataForm
> instead of an ActionForm as its form instance. Then we would implement
> this method to use get and put with keys instead of getters/setters.
>
> One problem: I don't know how the populate works from the other side
> (meaning when you want to prepopulate a form based on the contents of a
> JavaBean in the session, etc.). I imagine that logic is contained in the
> HTML tag libraries or some other tag library.
>
> I guess what I am wondering is that since a number of people have run
> into this and needed a solution I assumed that there might already be a
> solution to this problem. If not, maybe we can find a solution and then
> submit a patch to Struts for 1.1 or something.
>
> Anyone else have any thoughts on this?
>
> -- John Townsend
>
> PS. One thing I just thought of: I wonder if there is a JavaBeans
> solution to this problem? If there is, that might be a better way to go.
>
>
> -Original Message-
> From: Luis Olivares [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 11:28 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Dynamic Form Beans?
>
> I have the same 'problem'.
>
> I would like to be able to create a form dynamically depending on the
> structure of a table (I used to do this with 'plain' JSP).
> Any ideas?
>
> Regards.
>Luis Olivares.
>[EMAIL PROTECTED]
>--
>   "Intelligence is the ability to avoid doing
>work, yet getting the work done"
>   --Linus Torvalds--
>
> - Original Message -
> From: "John Townsend" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 29, 2001 12:54 PM
> Subject: Dynamic Form Beans?
>
>
> > I am working on a project where is would be nice to have the ability
> to
> > define a dynamic form bean (i.e. a form bean where the fields are
> > defined at runtime). The most obvious (but perhaps not the best)
> > solution to this problem would be if the ActionServlet could handle
> > saving data in a form bean that was a hashtable.
> >
> > Has someone else run into this problem and come up with a solution?
> >
> > Thanks,
> > -- John Townsend
> >
>





Re: Dynamic Form Beans?

2001-08-29 Thread Sastry Varanasi

I have the same problem too, and I'm sure there are many more like us. I 
believe this is a problem struts has not addressed yet. Fortunately, they 
are working on Dynamic form generation feature for struts1.1. I don't know 
when it is going to be ready!!

Here is a work-around: Make your JSPs without using FormBeans (you should 
have your won Java classes to dynamically generate the form), and extract 
input parameters from request in your action and stuff them into a 
Hashtable for further processing. However, someone should clarify if this 
approach violates struts recommended architecture.

I would definitely like to see a better solution. I have posted similar 
questions earlier on this topic, but I have got no response.

Sastry.

At 01:27 PM 8/29/2001 -0500, you wrote:
>I have the same 'problem'.
>
>I would like to be able to create a form dynamically depending on the
>structure of a table (I used to do this with 'plain' JSP).
>Any ideas?
>
>Regards.
>Luis Olivares.
>[EMAIL PROTECTED]
>--
>   "Intelligence is the ability to avoid doing
>work, yet getting the work done"
>   --Linus Torvalds--
>
>- Original Message -
>From: "John Townsend" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, August 29, 2001 12:54 PM
>Subject: Dynamic Form Beans?
>
>
> > I am working on a project where is would be nice to have the ability to
> > define a dynamic form bean (i.e. a form bean where the fields are
> > defined at runtime). The most obvious (but perhaps not the best)
> > solution to this problem would be if the ActionServlet could handle
> > saving data in a form bean that was a hashtable.
> >
> > Has someone else run into this problem and come up with a solution?
> >
> > Thanks,
> > -- John Townsend
> >


Sastry Varanasi
Tel : 408-526-6278
INSMBU, Cisco Systems





RE: Dynamic Form Beans?

2001-08-29 Thread John Townsend

The one idea that I had was to create a new subclass of ActionForm
called ActionDataForm. This form would have get and put methods that use
keys instead of the usual pattern of numerous getters/setters. 
 

For the process of saving form data, we could add a new override to
RequestUtils.processPopulate(..) which would take an ActionDataForm
instead of an ActionForm as its form instance. Then we would implement
this method to use get and put with keys instead of getters/setters.

One problem: I don't know how the populate works from the other side
(meaning when you want to prepopulate a form based on the contents of a
JavaBean in the session, etc.). I imagine that logic is contained in the
HTML tag libraries or some other tag library.

I guess what I am wondering is that since a number of people have run
into this and needed a solution I assumed that there might already be a
solution to this problem. If not, maybe we can find a solution and then
submit a patch to Struts for 1.1 or something.

Anyone else have any thoughts on this?

-- John Townsend

PS. One thing I just thought of: I wonder if there is a JavaBeans
solution to this problem? If there is, that might be a better way to go.


-Original Message-
From: Luis Olivares [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, August 29, 2001 11:28 AM
To: [EMAIL PROTECTED]
Subject: Re: Dynamic Form Beans?

I have the same 'problem'.

I would like to be able to create a form dynamically depending on the
structure of a table (I used to do this with 'plain' JSP).
Any ideas?

Regards.
   Luis Olivares.
   [EMAIL PROTECTED]
   --
  "Intelligence is the ability to avoid doing
   work, yet getting the work done"
  --Linus Torvalds--

- Original Message -
From: "John Townsend" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 12:54 PM
Subject: Dynamic Form Beans?


> I am working on a project where is would be nice to have the ability
to
> define a dynamic form bean (i.e. a form bean where the fields are
> defined at runtime). The most obvious (but perhaps not the best)
> solution to this problem would be if the ActionServlet could handle
> saving data in a form bean that was a hashtable.
>
> Has someone else run into this problem and come up with a solution?
>
> Thanks,
> -- John Townsend
>




RE: Dynamic Form Beans?

2001-08-29 Thread Thinh Doan

I heard Struts 1.1 will address this issue.  In the mean time, I too am
interested to a working solution.

Thanks,

Thinh

-Original Message-
From: Luis Olivares [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 29, 2001 1:28 PM
To: [EMAIL PROTECTED]
Subject: Re: Dynamic Form Beans?


I have the same 'problem'.

I would like to be able to create a form dynamically depending on the
structure of a table (I used to do this with 'plain' JSP).
Any ideas?

Regards.
   Luis Olivares.
   [EMAIL PROTECTED]
   --
  "Intelligence is the ability to avoid doing
   work, yet getting the work done"
  --Linus Torvalds--

- Original Message -
From: "John Townsend" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 12:54 PM
Subject: Dynamic Form Beans?


> I am working on a project where is would be nice to have the ability to
> define a dynamic form bean (i.e. a form bean where the fields are
> defined at runtime). The most obvious (but perhaps not the best)
> solution to this problem would be if the ActionServlet could handle
> saving data in a form bean that was a hashtable.
>
> Has someone else run into this problem and come up with a solution?
>
> Thanks,
> -- John Townsend
>




Re: Dynamic Form Beans?

2001-08-29 Thread Luis Olivares

I have the same 'problem'.

I would like to be able to create a form dynamically depending on the
structure of a table (I used to do this with 'plain' JSP).
Any ideas?

Regards.
   Luis Olivares.
   [EMAIL PROTECTED]
   --
  "Intelligence is the ability to avoid doing
   work, yet getting the work done"
  --Linus Torvalds--

- Original Message -
From: "John Townsend" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 12:54 PM
Subject: Dynamic Form Beans?


> I am working on a project where is would be nice to have the ability to
> define a dynamic form bean (i.e. a form bean where the fields are
> defined at runtime). The most obvious (but perhaps not the best)
> solution to this problem would be if the ActionServlet could handle
> saving data in a form bean that was a hashtable.
>
> Has someone else run into this problem and come up with a solution?
>
> Thanks,
> -- John Townsend
>




Dynamic Form Beans?

2001-08-29 Thread John Townsend

I am working on a project where is would be nice to have the ability to
define a dynamic form bean (i.e. a form bean where the fields are
defined at runtime). The most obvious (but perhaps not the best)
solution to this problem would be if the ActionServlet could handle
saving data in a form bean that was a hashtable. 

Has someone else run into this problem and come up with a solution? 

Thanks,
-- John Townsend
 




Dynamic form generation.

2001-08-20 Thread Sastry Varanasi

I am trying to use dynamically generated forms with Struts. Since the form 
is dynamic I will not know the form fields until runtime. How do I define 
my FormActionbean in this case? Is there a  way to circumvent the 
requirement of having a Bean for holding the form data? Can anyone help me 
out with some ideas on this?

Thanks,
Sastry.

Sastry Varanasi
Tel : 408-526-6278
INSMBU, Cisco Systems





RE: Problem with dynamic form elements

2001-05-17 Thread Niall Pemberton

There are quite a few messages in the archive about this:

   http://www.mail-archive.com/struts-user%40jakarta.apache.org/

A couple of messages from a recent thread:

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg07656.html
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg07767.html

Niall

> -Original Message-
> From: Prior, Simon [mailto:[EMAIL PROTECTED]]
> Sent: 17 May 2001 12:50
> To: '[EMAIL PROTECTED]'
> Subject: Problem with dynamic form elements
> Importance: High
>
>
> Hi Guys,
>
> I have a question about dynamic form elements that I was hoping someone
> could answer.
>
> Basically, I have a page I populate with elements from a database
> where the
> number of entries is unknown.
>
> For each of the rows retrieved, I extract some information and create an
> entry in a table on the page.  Each of the rows has a text box associated
> with it - also generated dynamically.  An Iterator tag is used to
> create the
> rows in the table and hence an index for each of the text box elements.
>
> My question is this, when I enter information into the text boxes, I would
> like this reflected onto my actionform automatically by Struts.  However,
> because I don't know how many text boxes will be present on the page, I
> can't provide set methods for each one.
>
> So how is it done?
>
> Thanks in advance,
>
> Simon.
>




Problem with dynamic form elements

2001-05-17 Thread Prior, Simon

Hi Guys,

I have a question about dynamic form elements that I was hoping someone
could answer.

Basically, I have a page I populate with elements from a database where the
number of entries is unknown.

For each of the rows retrieved, I extract some information and create an
entry in a table on the page.  Each of the rows has a text box associated
with it - also generated dynamically.  An Iterator tag is used to create the
rows in the table and hence an index for each of the text box elements.

My question is this, when I enter information into the text boxes, I would
like this reflected onto my actionform automatically by Struts.  However,
because I don't know how many text boxes will be present on the page, I
can't provide set methods for each one.

So how is it done?

Thanks in advance,

Simon.



RE: Dynamic form elements

2001-04-06 Thread Niall Pemberton

I believe this is on the todo list for version 1.1.

Previous Related Threads which talk about the same thing are:

form question
<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05210.html>

<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05216.html>

<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05231.html>
logic:iterate and form controls, revisited
<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg02128.html>

<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg04316.html>

<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg02145.html>
 and form input fields

<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg01662.html>

<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg01646.html>

<http://www.mail-archive.com/struts-user@jakarta.apache.org/msg01417.html>


Personally I would like a solution that doesn't involve scriptlets in my
JSP's and the only way I see to achieve this currently is by making my own
copies of the Tags and modifying them.

Niall


> -Original Message-
> From: Yuriy Zubarev [mailto:[EMAIL PROTECTED]]
> Sent: 06 April 2001 21:38
> To: [EMAIL PROTECTED]
> Subject: Dynamic form elements
>
>
> Hello Friends,
>
> Does anyone know if there is a standart scheme for dealing with form
> elements that are created dynamicly? For intance I iterate against a bean,
> creating a table of its properties and for each row I need to have a text
> element (checkbox, combobox, whatever). The problem is to give to those
> elemennts distinctive names which relate to row ID and get Struts to copy
> the contents of such a form to a bean after submitting.
>
> Thank you for your time.
>
> Best of luck,
> Yuriy Zubarev
>
>
> ___
> Do You Yahoo!?
> Get your free @yahoo.ca address at http://mail.yahoo.ca
>




Dynamic form elements

2001-04-06 Thread Yuriy Zubarev

Hello Friends,

Does anyone know if there is a standart scheme for dealing with form
elements that are created dynamicly? For intance I iterate against a bean,
creating a table of its properties and for each row I need to have a text
element (checkbox, combobox, whatever). The problem is to give to those
elemennts distinctive names which relate to row ID and get Struts to copy
the contents of such a form to a bean after submitting.

Thank you for your time.

Best of luck,
Yuriy Zubarev


___
Do You Yahoo!?
Get your free @yahoo.ca address at http://mail.yahoo.ca



Re: Dynamic form action?

2001-01-31 Thread Craig R. McClanahan

Peter Alfors wrote:

> Currently, we do not use the  tag.
> I haven't had a chance to look into them yet.
>
> I would think that the action attribute would not be required, but maybe there
> is a good reason for it to be?
> Someone with more experience with the  tags will have to help you there.
> Anyone?
>

The action attribute is used for two things:
* Create the destination hyperlink to submit to (which
  you don't need in this scenario)
* To look up the corresponding ActionMapping entry
  and, from there, determine what form bean to use.
  This information is used by all the nested field tags.

If you don't need either of these features, you probably don't need the
 tag.

> Pete
>

Craig





Re: Dynamic form action?

2001-01-29 Thread Peter Alfors

In order to use  forwards (that depend on the user action), wouldn't you
need some sort of router action class.  Would all the pages then call this
class and set some flag to notify it which action to take?


Ted Husted wrote:

> On 1/29/2001 at 3:12 PM Tom Janofsky wrote:
> >Or would a Struts guru care to make a case for what I want to do not
> being a best practice?
>
> I tucked this away for a FAQ .
>
> In addition to the controller and JavaScript approaches, Craig has also
>
> suggested using an ActionForward:
>
> 
>
> details below.
>
> *** REPLY SEPARATOR  ***
>
> On 1/12/2001 at 5:32 PM De Smet Koen wrote:
>
> Dear all,
>
> I've been investigation a little about how to call different actions
> from 1
> form with multiple buttons. Here's a possible solution, what do you
> think
> about it and/or do you see any possible problems?
>
> The way I did it was to add a Dispatcher class, which is called from
> the
> form, and which will call the correct action depending on which button
> has
> been pressed.
>
>   name="customForm"
>  type="custom.CustomForm">
>
> 
> 
>
> We give each button a name, starting with SUBMIT_xxx. This xxx will be
> the
> name of the mapping we will have to use for the action to be called.
>
> ***Little remark: Make always sure that when having more then 1 form
> with
> multiple buttons, to give the action and actionForm in the 
> tag a
> different name, and in struts-config make sure that there are 2
> different
> mappings, with 2 different names and 2 different actionForms, but both
> going
> to the same Digester class which always controls the forwards to Action
> Classes.
>
> In this dispatcher class you can retrieve the button pressed, by going
> through the request parameters, and then extracting the name of the
> mapping
> from the parameter. (SUBMIT_ButOneAction.do becomes ButOneAction)
>
> The next step is to find the Action instance that has been created by
> the
> ActionServlet for a mapping. The problem here is that the "actions"
> HashMap,
> stored in the ActionServlet, has been defined as protected, so the way
> to
> solve this is to create an own ActionServlet, with a getAction()
> function
> which will return the correct action.
>
> Now, you can call the perform() method on this action, which will
> return an
> ActionForward. (You can also go via struts-config and find the correct
> mapping, like you normally would do with only one button, but my way of
> working, calling the perform() method directly, is -I believe- faster,
> so
> better performance).
>
> Your comments please! Who sees any problems?
>
>
> Thanks,
>
> Koen
>
> P.S.: When I asked some weeks ago how to solve the problem of multiple
> buttons in 1 form, people suggested to use JavaScript. We tried that
> and it
> works, but the bad thing is you still rely on the JavaScript
> interpretation
> on the clientside and in the way I suggested above, it's more JSP /
> Struts
> related.
>
> *** REPLY SEPARATOR  ***
>
> Crag McClanahan writes:
>
> The proposed approach is one way to deal with the "different actions
> for one
> form" issue, and I cannot see any particular problems with it.  To deal
> with
> getting the correct action, how about setting up ActionForward entries
> that
> correspond to other actions instead of JSP pages?
>
> 
>
> This would "loop back" to the controller servlet and execute the
> alternative
> action for you.
>
> An alternative strategy would be to use client-side JavaScript to
> change the
> submit destination (on the underlying HTML form) at run time.  If you
> go this
> way, you will want to make sure that all the actions you might send the
> form to
> take the same ActionForm bean (or at least beans with the same set of
> properties).
>
> *** REPLY SEPARATOR  ***
>
> On 1/29/2001 at 3:12 PM Tom Janofsky wrote:
>
> Hi:
>
> I'm relatively new to Struts and I'm trying to figure out if there's an
> easy way to do the following.
>
> I'm trying to solve a classic Add/Edit/Delete problem, and I want to
> know if there is a way to dynamically change the action that the form
> is
> posting to, based on an attribute of the bean.  I want to do this
> because I want to be able to have the following architecture:
>
> [1 JSP view]
>|-addAction -> (forwards to view)
>|-editAction -> (forwards to view)
>|-deleteAction -> (forwards to view)
>
> All of which use the same form bean, and all forward back to the same
> view, which has a different button and differnt target (action) if
> adding or editing.
>
> I've written one jsp that does the add, a form bean that has all the
> fields, and 3 actions that add, edit and delete.  Add is easy, it's the
> action of the form, delete is easy, it keys off links in the jsp, but
> I'd like to use the same jsp for the edit screen, but change the url
> the
> form is posting to (to the edit action) and also change the buttons.
>
> In servlet world, this was:
>
> if (action.equlas("add")){
>

Re: Dynamic form action?

2001-01-29 Thread Ted Husted

On 1/29/2001 at 3:12 PM Tom Janofsky wrote:
>Or would a Struts guru care to make a case for what I want to do not
being a best practice?

I tucked this away for a FAQ . 

In addition to the controller and JavaScript approaches, Craig has also

suggested using an ActionForward:



details below.

*** REPLY SEPARATOR  ***

On 1/12/2001 at 5:32 PM De Smet Koen wrote:

Dear all,
 
I've been investigation a little about how to call different actions
from 1
form with multiple buttons. Here's a possible solution, what do you
think
about it and/or do you see any possible problems?
 
The way I did it was to add a Dispatcher class, which is called from
the
form, and which will call the correct action depending on which button
has
been pressed. 
 
 
 


 
We give each button a name, starting with SUBMIT_xxx. This xxx will be
the
name of the mapping we will have to use for the action to be called. 
 
***Little remark: Make always sure that when having more then 1 form
with
multiple buttons, to give the action and actionForm in the 
tag a
different name, and in struts-config make sure that there are 2
different
mappings, with 2 different names and 2 different actionForms, but both
going
to the same Digester class which always controls the forwards to Action
Classes. 
 
In this dispatcher class you can retrieve the button pressed, by going
through the request parameters, and then extracting the name of the
mapping
from the parameter. (SUBMIT_ButOneAction.do becomes ButOneAction)
 
The next step is to find the Action instance that has been created by
the
ActionServlet for a mapping. The problem here is that the "actions"
HashMap,
stored in the ActionServlet, has been defined as protected, so the way
to
solve this is to create an own ActionServlet, with a getAction()
function
which will return the correct action.
 
Now, you can call the perform() method on this action, which will
return an
ActionForward. (You can also go via struts-config and find the correct
mapping, like you normally would do with only one button, but my way of
working, calling the perform() method directly, is -I believe- faster,
so
better performance).
 
Your comments please! Who sees any problems?
 
 
Thanks,
 
Koen
 
P.S.: When I asked some weeks ago how to solve the problem of multiple
buttons in 1 form, people suggested to use JavaScript. We tried that
and it
works, but the bad thing is you still rely on the JavaScript
interpretation
on the clientside and in the way I suggested above, it's more JSP /
Struts
related.
 
*** REPLY SEPARATOR  ***

Crag McClanahan writes:

The proposed approach is one way to deal with the "different actions
for one
form" issue, and I cannot see any particular problems with it.  To deal
with
getting the correct action, how about setting up ActionForward entries
that
correspond to other actions instead of JSP pages?



This would "loop back" to the controller servlet and execute the
alternative
action for you.

An alternative strategy would be to use client-side JavaScript to
change the
submit destination (on the underlying HTML form) at run time.  If you
go this
way, you will want to make sure that all the actions you might send the
form to
take the same ActionForm bean (or at least beans with the same set of
properties).


*** REPLY SEPARATOR  ***

On 1/29/2001 at 3:12 PM Tom Janofsky wrote:

Hi:

I'm relatively new to Struts and I'm trying to figure out if there's an
easy way to do the following.  

I'm trying to solve a classic Add/Edit/Delete problem, and I want to
know if there is a way to dynamically change the action that the form
is
posting to, based on an attribute of the bean.  I want to do this
because I want to be able to have the following architecture:

[1 JSP view]
   |-addAction -> (forwards to view)
   |-editAction -> (forwards to view)
   |-deleteAction -> (forwards to view)

All of which use the same form bean, and all forward back to the same
view, which has a different button and differnt target (action) if
adding or editing.

I've written one jsp that does the add, a form bean that has all the
fields, and 3 actions that add, edit and delete.  Add is easy, it's the
action of the form, delete is easy, it keys off links in the jsp, but
I'd like to use the same jsp for the edit screen, but change the url
the
form is posting to (to the edit action) and also change the buttons.

In servlet world, this was:

if (action.equlas("add")){
out.println("");
else {//edit
out.println("http://www.husted.com/about/struts/





Re: Dynamic form action?

2001-01-29 Thread Peter Alfors

Currently, we do not use the  tag.
I haven't had a chance to look into them yet.

I would think that the action attribute would not be required, but maybe there
is a good reason for it to be?
Someone with more experience with the  tags will have to help you there.
Anyone?

Pete

Tom Janofsky wrote:

> Then do I take it that you don't use the  tag?  Or is there a
> way to make it happy with no action?  I tried setting the action to be
> non-existent (no action attribute), or null (action = "null"), but both
> blow up on load because the corresponding mapping isn't found in the
>  in struts-config.xml.  Or do you just put a dummy
> entry in there?
>
> --tom
>
> Peter Alfors wrote:
> >
> > We chose to use one Action class per user action as well.  To do this, we
> > use javascript to switch the form action.  Our buttons call a generic
> > javascript function (that we have as a javascript import file) that simply
> > sets the form action.  The method requires the form, and action to call as
> > parameters.
> > This allows up to use one JSP page for viewing, editing, and adding it we
> > would like.
> >
> > JavaScript:
> > 
> > function performAction(theForm, theAction) {
> >   theForm.action = theAction;
> >   theForm.submit(theForm);
> > }
> >
> > Page button:
> > 
> > onClick="performAction(document.myForm, 'MyAction.do')
> >
> > As a default, we do not set an action in the form tag on any of our pages.
> > Each button is responsible for setting the action that it would like to
> > initiate.
> >
> > HTH,
> > Pete
> >
> > Tom Janofsky wrote:
> >
> > > Hi:
> > >
> > > I'm relatively new to Struts and I'm trying to figure out if there's an
> > > easy way to do the following.
> > >
> > > I'm trying to solve a classic Add/Edit/Delete problem, and I want to
> > > know if there is a way to dynamically change the action that the form is
> > > posting to, based on an attribute of the bean.  I want to do this
> > > because I want to be able to have the following architecture:
> > >
> > > [1 JSP view]
> > >|-addAction -> (forwards to view)
> > >|-editAction -> (forwards to view)
> > >|-deleteAction -> (forwards to view)
> > >
> > > All of which use the same form bean, and all forward back to the same
> > > view, which has a different button and differnt target (action) if
> > > adding or editing.
> > >
> > > I've written one jsp that does the add, a form bean that has all the
> > > fields, and 3 actions that add, edit and delete.  Add is easy, it's the
> > > action of the form, delete is easy, it keys off links in the jsp, but
> > > I'd like to use the same jsp for the edit screen, but change the url the
> > > form is posting to (to the edit action) and also change the buttons.
> > >
> > > In servlet world, this was:
> > >
> > > if (action.equlas("add")){
> > > out.println("");
> > > else {//edit
> > > out.println(" > > }
> > >
> > > and similarly for the buttons.
> > >
> > > I've been through the example app looking for this might have worked,
> > > but it doesn't really seem to work that way (i.e., EditSubscription
> > > looks at the hidden field does create or edit, and Save does save, or
> > > delete, also based on the action field.)
> > >
> > > I'd rather not embed checking the action in the the "Action" class (this
> > > being the bane of heavy controller servlets past, but I want to go with
> > > one "Action" per user action.  One alternative (based off an example dug
> > > out of the archives) seems to be another "Controller"
> > > action, which looks at the action field in the bean, and picks, and
> > > destination based off that, but I don't like that, because that seems
> > > like the very type of problem Struts is trying to solve.
> > >
> > > Or would a Struts guru care to make a case for what I want to do not
> > > being a best practice?
> > >
> > > --tom janofsky


begin:vcard 
n:;
x-mozilla-html:FALSE
org:http://www.irista.com/logo/irista.gif">Bringing Vision to Your Supply Chain
adr:;;
version:2.1
end:vcard



Re: Dynamic form action?

2001-01-29 Thread Tom Janofsky


Then do I take it that you don't use the  tag?  Or is there a
way to make it happy with no action?  I tried setting the action to be
non-existent (no action attribute), or null (action = "null"), but both
blow up on load because the corresponding mapping isn't found in the
 in struts-config.xml.  Or do you just put a dummy
entry in there?

--tom

Peter Alfors wrote:
> 
> We chose to use one Action class per user action as well.  To do this, we
> use javascript to switch the form action.  Our buttons call a generic
> javascript function (that we have as a javascript import file) that simply
> sets the form action.  The method requires the form, and action to call as
> parameters.
> This allows up to use one JSP page for viewing, editing, and adding it we
> would like.
> 
> JavaScript:
> 
> function performAction(theForm, theAction) {
>   theForm.action = theAction;
>   theForm.submit(theForm);
> }
> 
> Page button:
> 
> onClick="performAction(document.myForm, 'MyAction.do')
> 
> As a default, we do not set an action in the form tag on any of our pages.
> Each button is responsible for setting the action that it would like to
> initiate.
> 
> HTH,
> Pete
> 
> Tom Janofsky wrote:
> 
> > Hi:
> >
> > I'm relatively new to Struts and I'm trying to figure out if there's an
> > easy way to do the following.
> >
> > I'm trying to solve a classic Add/Edit/Delete problem, and I want to
> > know if there is a way to dynamically change the action that the form is
> > posting to, based on an attribute of the bean.  I want to do this
> > because I want to be able to have the following architecture:
> >
> > [1 JSP view]
> >|-addAction -> (forwards to view)
> >|-editAction -> (forwards to view)
> >|-deleteAction -> (forwards to view)
> >
> > All of which use the same form bean, and all forward back to the same
> > view, which has a different button and differnt target (action) if
> > adding or editing.
> >
> > I've written one jsp that does the add, a form bean that has all the
> > fields, and 3 actions that add, edit and delete.  Add is easy, it's the
> > action of the form, delete is easy, it keys off links in the jsp, but
> > I'd like to use the same jsp for the edit screen, but change the url the
> > form is posting to (to the edit action) and also change the buttons.
> >
> > In servlet world, this was:
> >
> > if (action.equlas("add")){
> > out.println("");
> > else {//edit
> > out.println(" > }
> >
> > and similarly for the buttons.
> >
> > I've been through the example app looking for this might have worked,
> > but it doesn't really seem to work that way (i.e., EditSubscription
> > looks at the hidden field does create or edit, and Save does save, or
> > delete, also based on the action field.)
> >
> > I'd rather not embed checking the action in the the "Action" class (this
> > being the bane of heavy controller servlets past, but I want to go with
> > one "Action" per user action.  One alternative (based off an example dug
> > out of the archives) seems to be another "Controller"
> > action, which looks at the action field in the bean, and picks, and
> > destination based off that, but I don't like that, because that seems
> > like the very type of problem Struts is trying to solve.
> >
> > Or would a Struts guru care to make a case for what I want to do not
> > being a best practice?
> >
> > --tom janofsky



Re: Dynamic form action?

2001-01-29 Thread Peter Alfors

We chose to use one Action class per user action as well.  To do this, we
use javascript to switch the form action.  Our buttons call a generic
javascript function (that we have as a javascript import file) that simply
sets the form action.  The method requires the form, and action to call as
parameters.
This allows up to use one JSP page for viewing, editing, and adding it we
would like.

JavaScript:

function performAction(theForm, theAction) {
  theForm.action = theAction;
  theForm.submit(theForm);
}


Page button:

onClick="performAction(document.myForm, 'MyAction.do')

As a default, we do not set an action in the form tag on any of our pages.
Each button is responsible for setting the action that it would like to
initiate.

HTH,
Pete


Tom Janofsky wrote:

> Hi:
>
> I'm relatively new to Struts and I'm trying to figure out if there's an
> easy way to do the following.
>
> I'm trying to solve a classic Add/Edit/Delete problem, and I want to
> know if there is a way to dynamically change the action that the form is
> posting to, based on an attribute of the bean.  I want to do this
> because I want to be able to have the following architecture:
>
> [1 JSP view]
>|-addAction -> (forwards to view)
>|-editAction -> (forwards to view)
>|-deleteAction -> (forwards to view)
>
> All of which use the same form bean, and all forward back to the same
> view, which has a different button and differnt target (action) if
> adding or editing.
>
> I've written one jsp that does the add, a form bean that has all the
> fields, and 3 actions that add, edit and delete.  Add is easy, it's the
> action of the form, delete is easy, it keys off links in the jsp, but
> I'd like to use the same jsp for the edit screen, but change the url the
> form is posting to (to the edit action) and also change the buttons.
>
> In servlet world, this was:
>
> if (action.equlas("add")){
> out.println("");
> else {//edit
> out.println(" }
>
> and similarly for the buttons.
>
> I've been through the example app looking for this might have worked,
> but it doesn't really seem to work that way (i.e., EditSubscription
> looks at the hidden field does create or edit, and Save does save, or
> delete, also based on the action field.)
>
> I'd rather not embed checking the action in the the "Action" class (this
> being the bane of heavy controller servlets past, but I want to go with
> one "Action" per user action.  One alternative (based off an example dug
> out of the archives) seems to be another "Controller"
> action, which looks at the action field in the bean, and picks, and
> destination based off that, but I don't like that, because that seems
> like the very type of problem Struts is trying to solve.
>
> Or would a Struts guru care to make a case for what I want to do not
> being a best practice?
>
> --tom janofsky


begin:vcard 
n:;
x-mozilla-html:FALSE
org:http://www.irista.com/logo/irista.gif">Bringing Vision to Your Supply Chain
adr:;;
version:2.1
end:vcard



Dynamic form action?

2001-01-29 Thread Tom Janofsky


Hi:

I'm relatively new to Struts and I'm trying to figure out if there's an
easy way to do the following.  

I'm trying to solve a classic Add/Edit/Delete problem, and I want to
know if there is a way to dynamically change the action that the form is
posting to, based on an attribute of the bean.  I want to do this
because I want to be able to have the following architecture:

[1 JSP view]
   |-addAction -> (forwards to view)
   |-editAction -> (forwards to view)
   |-deleteAction -> (forwards to view)

All of which use the same form bean, and all forward back to the same
view, which has a different button and differnt target (action) if
adding or editing.

I've written one jsp that does the add, a form bean that has all the
fields, and 3 actions that add, edit and delete.  Add is easy, it's the
action of the form, delete is easy, it keys off links in the jsp, but
I'd like to use the same jsp for the edit screen, but change the url the
form is posting to (to the edit action) and also change the buttons.

In servlet world, this was:

if (action.equlas("add")){
out.println("");
else {//edit
out.println("


Does struts have a Dynamic Form.

2000-12-19 Thread Johan Compagner

Hi,

Let's say i want to make something so that i can edit database tables.
I don't want to write for every database table that must be editiable a special jsp 
page.

For every database table i have a Java Mapping Object.
Not all Columns are editable, only the specified ones.

DynamicForm form = new DynamicForm()
form.setDatabaseObject(javaMappingObject);
form.setEditableColumns(String[])

When the user presses submit i can validate the form in the perfom()
and get the updated database object back so that i can update the database.

does struts have something like this?

Johan Compagner






Re: Dynamic form

2000-12-14 Thread Craig R. McClanahan

Wong Kok Wai wrote:

> What's the recommended way to implement a dynamic form
> using Struts? Typical scenario: an address book for
> email where the number of contacts varies. No problem
> with renderering the form in the JSP but how do I
> associate the " instance of the ActionForm?
>

Struts 1.0 does not really address the issue of dynamic forms -- it is more
focused on "static forms where the names of the request parameters, and thus the
names of the corresponding properties on your ActionForm bean, are known.

Elegant support for dynamic forms will be a focus area for Struts 1.1.

>
> TIA!
>

Craig McClanahan





Dynamic form

2000-12-13 Thread Wong Kok Wai

What's the recommended way to implement a dynamic form
using Struts? Typical scenario: an address book for
email where the number of contacts varies. No problem
with renderering the form in the JSP but how do I
associate the "http://shopping.yahoo.com/



Re: Dynamic form and checkboxes

2000-10-19 Thread Pierre Métras

Thanks. I drop a look at the source of MultiboxTag but I can't understand
how to use it (must I include it in an  tag?), and it seems it has
never been used in struts example or test suite. Has someone already used
it?

Pierre

- Original Message -
From: "Aur Gal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 19, 2000 1:28 PM
Subject: RE: Dynamic form and checkboxes


> I'm not sure but I think in this case you would use the struts:multibox.
>
> -Original Message-
> From: Pierre [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 19, 2000 12:15 PM
> To: [EMAIL PROTECTED]
> Subject: Dynamic form and checkboxes
>
>
> Subject: Dynamic form and checkboxes
>
> Hi,
>
> I forgot to follow the 'dynamic form' thread when the subject was hot, and
> now I can't retrieve the posts to pick some ideas...
>
> Here is my 'dynamic form' problem. I must create a form with a collection
of
> checkboxes to allow the user to choose various options. The checkboxes
will
> be generated by an application tag, the number and types depending on the
> user
> profile.
>
> How can I have a dynamical ActionForm class to manage all these
checkboxes?
> Should I create a *big* class with all setOptionNNN/getOptionNNN
functions,
> in
> order to support all checkboxes combination or can I write generic get/set
> functions using indexed properties? Or is there a better alternative...
>
> Thanks for any hint.
> Pierre Metras
>




<    1   2