• 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

Implementing clear button in struts

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a jsp where some of the fields like "submitted date" have default values populated in the jsp. When the user clicks on the CLEAR button all the fields shd be cleared and the default fields shd be populated with teh default values.

I understand this can be implemented using a javascript function. But a session variable also has to be removed from the session scope on clicking this CLEAR button. Pls let me know how this can be implemented.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One possible solution would be to use the <html:cancel> button. This button performs a submit, but does not call validation.

Once the form has been submitted, in your Action class you would call the superclass' isCancelled() method to determine whether the cancel button was pressed or not. If it was, you can do whatever you need to do to make the page appear as you want it to appear and to remove the session attribute.

If you're using Struts 1.2.9 or above, you will also have to add cancellable="true" to your action mapping.
[ March 05, 2007: Message edited by: Merrill Higginson ]
 
Sunitha Mudidani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

But iam stuck in using the <html:cancel> button.
Iam using jdeveloper studioo version 10.1.3
Iam not sure which version of struts it is using.

When iam clicking on the CANCEL button no effect is taking place.
These are the changes that i have done.

1) In the JSP



2)In the struts-config.xml, added the below line in <action..> tag



3) In the Action class, the corresponding code is,

Also Iam getting an exception :





Pls let me know how to proceed

Thanks,
Sunitha
 
Sunitha Mudidani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The struts version being used in JdeveloperStudioVersion 10.1.3 is struts 1.1 So I removed the cancellable property and the exception is gone.

But the clear button implementation is not getting invoked.

Waiting for suggestions...
 
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
Did you specify a property attribute in your <html:cancel> tag? If so, remove it. This will cause the isCancelled() method not to work.
 
Sunitha Mudidani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.. I didnot use property attribute in <html:cancel>
 
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
Please be more clear about what is happening. Is the execute of the action class being called when the cancel button is pressed? if so, is the value returned by isCancelled(request) false?
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic