aspose file tools *
The moose likes Struts and the fly likes clear dynavalidator form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "clear dynavalidator form" Watch "clear dynavalidator form" New topic
Author

clear dynavalidator form

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
I have dynavalidator form and I want to clear the fields on pressing clear. Below are the two options that i tried and it did not work.

The reason being(I think..).. I have a Insert screen and once submit is presssed I take them to a confirmation screen. If user presses cancel in the confirm screen, I bring them back to Insert screen(displays values previously entered). Now if user tries to press clear button ...clear does not clear the screen. why is this happening?



Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The JavaScript code you present should work if you correct a few errors. Change 'radio' to 'RADIO' (Upper Case). Also, if you're trying to clear inputs created with the <html:text> tag, you should change 'textarea' to 'TEXT'.


Merrill
Consultant, Sima Solutions
shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
the javascript works fine. But I think the clear should be done at server side. My DynaValidatorBean still holds the value even if I just clear the screen using javascript. So I have created a action class but I am not sure how to reset values of my DynaValiatorBean.

I did this in MresetAction class

dynaValidatorMForm.reset(mapping, request); it does not work.

My screen flow is
INSERT screen--->ConfirmInsert screen (If cancel presed inside confirm screen)then back to INSERT Screen (if I press clear now it does nothing)
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Are you talking about using the html:reset tag (same applies to the standard reset input tag)? If so then the functionality of that button is to reset all the fields back to the value they were when the page was displayed. Here is a thread with some info on the html:reset tag:

http://www.coderanch.com/t/55525/Struts/calling-reset-form-bean

- Brent
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The reset method of DynaActionForm sets each field to the value specified in the "initial" attribute if you also specified reset="true" for that field. Otherwise, the reset method does nothing.

Another way to do it is is just to write code in your Action class that sets a default value (i.e. blanks or zeros) in each individual field.
[ February 28, 2007: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clear dynavalidator form