Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

My Cancel button is not working in struts1.2  RSS feed

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 137
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Amit Indore
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Higginson
Ranch Hand
Posts: 4864
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very helpful post.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!