You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Danny Lee <ha...@yahoo.de> on 2006/03/10 12:38:42 UTC

Autosumbit before Action

Hi guys!

I'm writing an admin webinterface for a web store at the moment,
the "put-new-product" part.

SITUATION: I have some product attributes like "Information Blocks" and 
"Product Details", which are 0..n, so I'm able to delete these, or 
create new.

PROBLEM: The problem is, every time I delete or create a new detail I 
have to call something an action. When I redirect back to the refreshed
form, all the stuff admin typed in before is away :(


QUESTION: how can I autosubmit the whole form, every time bevore
the STORE-DETAIL, DELETE-DETAIL action is called? I tried a JavaScript
Sumbit on Click, but it doesn't seem to work... My temporary solution
is a warning near every critical button, but it sux :(

Maybe you guys had a similar problem... Please help!


Cheers,

Danny

P.S. I use StutsDialogs for this one... (Hi, Michael!)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Autosumbit before Action

Posted by Michael Jouravlev <jm...@gmail.com>.
On 3/10/06, Danny Lee <ha...@yahoo.de> wrote:
> Hi guys!
>
> I'm writing an admin webinterface for a web store at the moment,
> the "put-new-product" part.
>
> SITUATION: I have some product attributes like "Information Blocks" and
> "Product Details", which are 0..n, so I'm able to delete these, or
> create new.
>
> PROBLEM: The problem is, every time I delete or create a new detail I
> have to call something an action. When I redirect back to the refreshed
> form, all the stuff admin typed in before is away :(
>
>
> QUESTION: how can I autosubmit the whole form, every time bevore
> the STORE-DETAIL, DELETE-DETAIL action is called? I tried a JavaScript
> Sumbit on Click, but it doesn't seem to work... My temporary solution
> is a warning near every critical button, but it sux :(

Do you use a link for delete event? If yes, this might be a problem.
Link does not submit a form, therefore when the form is reloaded after
redirect, its content is gone.

Use a button for deletion. Stick this button in the same HTML form
that contains typed data that you want to save. When button is
activated, its respective event handler is triggered, which is what
you need. But at the same time the HTML form is submitted to the
server. Struts wil try to populate the corresponding ActionForm with
request values. Therefore, your action that handles delete event must
work with the form that receives admin data. This ActionForm must have
session scope to retain data between requests.

Of course you can also use Javascript to submit form from the link,
but you said you don't like using Javascript. Another thing, if you do
not like how pushbutton looks, you can make it look like a link with a
little CSS.

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org