aspose file tools*
The moose likes Struts and the fly likes My Cancel button is not working in struts1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "My Cancel button is not working in struts1.2" Watch "My Cancel button is not working in struts1.2" New topic
Author

My Cancel button is not working in struts1.2

Amit Indore
Ranch Hand

Joined: Jun 20, 2008
Posts: 31
Hello All,

I am new in struts.I have a problem,my cancel button is not working.

Actually, I have two button in jsp page. one is <html:submit/> and another is
<html:cancel/>.my submit button is working fine .

But when i click on cancel button is working same like submit but i want to go
Input page on click on cancel.(means without doing anything go to input jsp )

please help me.
Sidharth Pallai
Ranch Hand

Joined: Apr 21, 2008
Posts: 134

Originally posted by Amit Indore:
Hello All,

I am new in struts.I have a problem,my cancel button is not working.

Actually, I have two button in jsp page. one is <html:submit/> and another is
<html:cancel/>.my submit button is working fine .

But when i click on cancel button is working same like submit but i want to go
Input page on click on cancel.(means without doing anything go to input jsp )

please help me.


Struts cancel works different from other buttons.You can check isCancelled() in Action class for boolean return when it is being pressed.Based on return you can forward to your desired page by configuring mapping.findForward with the URL corresponding to your desired page.


Thanks & Regards
Sidharth Pallai
Amit Indore
Ranch Hand

Joined: Jun 20, 2008
Posts: 31
Originally posted by Sidharth Pallai:


Struts cancel works different from other buttons.You can check isCancelled() in Action class for boolean return when it is being pressed.Based on return you can forward to your desired page by configuring mapping.findForward with the URL corresponding to your desired page.


How can i use isCancelled() in Action class for boolean return.please forward whole Action class or code.

Thanks
Amit Jain
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

hi Amit,

in struts 1.1 --- it will work fine ..

in struts 1.2.9--- you have to add
------------------------
isCancellable="true"
-------------------------- in action attribute(struts-config.xml)
Amit Indore
Ranch Hand

Joined: Jun 20, 2008
Posts: 31
Sir, I am using struts_1_0_2. i put isCancellable="true" in Action mapping but it gives Error.Please sir help me, i am not able to solve the problem.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
As seetharaman already mentioned, you don't need to add cancellable="true" to the action mapping for a Struts 1.0 or 1.1 application. The cancel button will work fine without it. This attribute was not added until Struts 1.2.9.


Merrill
Consultant, Sima Solutions
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The org.apache.struts.action.Action class that your Action class extends has an isCancelled() method. If you call this method in your Action class, you can tell whether or not the cancel button was pressed, and if so, take some action. Example:
<blockquote>code:
<pre name="code" class="core">if (isCancelled()) {
return mapping.findForward("cancelled");
} else {
// do some validation or other logic
return mapping.findForward("success");
}
</pre>
</blockquote>
Amit Indore
Ranch Hand

Joined: Jun 20, 2008
Posts: 31
Originally posted by Merrill Higginson:
The org.apache.struts.action.Action class that your Action class extends has an isCancelled() method. If you call this method in your Action class, you can tell whether or not the cancel button was pressed, and if so, take some action. Example:
<blockquote><font size="1" face="Verdana, Arial">code:</font><hr><pre name="code" class="core"><font size="2">if (isCancelled()) {
return mapping.findForward("cancelled");
} else {
// do some validation or other logic
return mapping.findForward("success");
}</font></pre><hr></blockquote>



Thank you sir, It is working.
pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 323

Very helpful post.


Thanks,
Pramod
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My Cancel button is not working in struts1.2