You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Oguz Kologlu <oz...@optushome.com.au> on 2002/11/04 08:07:53 UTC

Clearing a form problem - bug or by design?

Hi all,

I know this question has been asked before - I think i know the reason why
some people are having issues clearing a form - the same as I am.

I don't know if the "problem" is really a bug, by design or if I'm going
about it the wrong way but it has been driving me nuts - ( update: I've
found a solution but read on if you have a better idea)

Brief Description:
When a form is submitted I save the actionform data to a DB, clear the
actionform and forward to the same page ready for more data ( a sort of
"Save and New" function ).

When the actionform is redisplayed the form data "magically" re-appears.
I've had a look at the struts source and it is re-populating the form from
the request data in org.apache.struts.util.RequestUtils.populate( ... ). Is
there any way to NOT repopulate the form?

There is no problem if I forward to another page and come back to it but
that's not really what I want. Am I going about this the wrong way or is
there a simple ( or difficult ) solution.

Simple Solution: set redirect to true:

      <forward
        name="newAction"
        path="/struts/newForm.do"
        redirect="true" />

If there is a better solution I would love to know since I would rather not
have to redirect!!!

Thanks
Oz


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Upload problem

Posted by Shunli Yang <sh...@yahoo.com>.
Hi,
I'm using Struts1.1b to work on upload application.
Documents can be uploaded successfully to the File
system. But I can't view uploaded documents like xls,
power-point files properly.  
Any body has similar problem?

Thax in advance!

Shunli

__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Clearing a form problem - bug or by design?

Posted by Joe Latty <jo...@team2media.com>.
Perhaps a call to the reset method in the ActionForm.

Joe

-----Original Message-----
From: Oguz Kologlu [mailto:ozkologlu@optushome.com.au]
Sent: Monday, 4 November 2002 5:08 PM
To: Struts-User
Subject: Clearing a form problem - bug or by design?


Hi all,

I know this question has been asked before - I think i know the reason why
some people are having issues clearing a form - the same as I am.

I don't know if the "problem" is really a bug, by design or if I'm going
about it the wrong way but it has been driving me nuts - ( update: I've
found a solution but read on if you have a better idea)

Brief Description:
When a form is submitted I save the actionform data to a DB, clear the
actionform and forward to the same page ready for more data ( a sort of
"Save and New" function ).

When the actionform is redisplayed the form data "magically" re-appears.
I've had a look at the struts source and it is re-populating the form from
the request data in org.apache.struts.util.RequestUtils.populate( ... ). Is
there any way to NOT repopulate the form?

There is no problem if I forward to another page and come back to it but
that's not really what I want. Am I going about this the wrong way or is
there a simple ( or difficult ) solution.

Simple Solution: set redirect to true:

      <forward
        name="newAction"
        path="/struts/newForm.do"
        redirect="true" />

If there is a better solution I would love to know since I would rather not
have to redirect!!!

Thanks
Oz


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Clearing a form problem - bug or by design?

Posted by James Mitchell <jm...@telocity.com>.
This is an interesting problem.

Most people find out about the 're-populating the form from the request'
issue as a result of action chaining, but this may not be the case for you.
Even if it is, this solution should solve it for both cases.

At some point in your action (or last action if chaining) after you've
finished getting the data from your formbean, create a new instance or call
reset on the existing one.
Assuming either:
    1. you've provided an appropriate reset method
      or
    2. you are using any of the Dynamic forms

Then be sure to save it under the same name and scope as your form is
expecting (as configured).

If you don't do this, then Struts will create a new form and populate it
from the request (which conveniently has those same values from the original
post).  The exception to this is if you use redirect="true", which is what
you are seeing.



James Mitchell
Software Engineer/Struts Evangelist
http://www.open-tools.org

"Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former."
- Albert Einstein (1879-1955)


> -----Original Message-----
> From: Oguz Kologlu [mailto:ozkologlu@optushome.com.au]
> Sent: Monday, November 04, 2002 2:08 AM
> To: Struts-User
> Subject: Clearing a form problem - bug or by design?
>
>
> Hi all,
>
> I know this question has been asked before - I think i know the reason why
> some people are having issues clearing a form - the same as I am.
>
> I don't know if the "problem" is really a bug, by design or if I'm going
> about it the wrong way but it has been driving me nuts - ( update: I've
> found a solution but read on if you have a better idea)
>
> Brief Description:
> When a form is submitted I save the actionform data to a DB, clear the
> actionform and forward to the same page ready for more data ( a sort of
> "Save and New" function ).
>
> When the actionform is redisplayed the form data "magically" re-appears.
> I've had a look at the struts source and it is re-populating the form from
> the request data in org.apache.struts.util.RequestUtils.populate(
> ... ). Is
> there any way to NOT repopulate the form?
>
> There is no problem if I forward to another page and come back to it but
> that's not really what I want. Am I going about this the wrong way or is
> there a simple ( or difficult ) solution.
>
> Simple Solution: set redirect to true:
>
>       <forward
>         name="newAction"
>         path="/struts/newForm.do"
>         redirect="true" />
>
> If there is a better solution I would love to know since I would
> rather not
> have to redirect!!!
>
> Thanks
> Oz
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>