• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

clear dynavalidator form

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?



 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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'.
 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

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

- Brent
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic