RE: dynamic form action flow

2002-02-01 Thread Jeff Oberlander

I figured this out finally, thanks to the "Vectors in Form" thread today,
which turned out to be similar

It was 2 things:
1) The scope in my struts-config was "request" and should have been session.
2) Upon adding a new blank object to the ArrayList for re-display, instead
of forwarding to the editPhoneNumbers.do action, directly re-display the
jsp.


-Original Message-
From: Jeff Oberlander 
Sent: Friday, February 01, 2002 7:39 AM
To: 'Struts Users Mailing List'
Subject: RE: dynamic form action flow


I've tried going straight to the display page and then I get the new, blank
element and form, but lose the prior existing form fields (home phone).

-Original Message-
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 01, 2002 4:14 AM
To: Struts Users Mailing List
Subject: Re: dynamic form action flow


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

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




RE: dynamic form action flow

2002-02-01 Thread Jeff Oberlander

I've tried going straight to the display page and then I get the new, blank
element and form, but lose the prior existing form fields (home phone).

-Original Message-
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 01, 2002 4:14 AM
To: Struts Users Mailing List
Subject: Re: dynamic form action flow


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

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




RE: dynamic form action flow

2002-02-01 Thread Jeff Oberlander

Actually, it doesn't.  I've been through that example pretty thouroughly.
To add a new subscription, it puts up a form with only the fields for the
new subscription (a separate page).  It doesn't dynamically new form fields
to an existing page.

-Original Message-
From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 01, 2002 2:05 AM
To: 'Struts Users Mailing List'
Subject: RE: dynamic form action flow


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

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




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 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("