Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing clear button in struts

 
Sunitha Mudidani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic