• 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

trapped in html:cancel tag ...

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have an update form with a <html:cancel> button. The cancel action will succeed in going back to the previous page if all mandatory fields are filled with valid data (validation is done on the fields). But if any of these fields are filled with invalid data, pressing the cancel button will cause the validation to be performed.

Is this associated with the fact that my validation was done in action and not in actionform?

Is it possible to place validation, which requires database access, in the validate method of the actionform class? And how should I go about doing it? Can anyone provide sample code?
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem, then i changed from struts:cancel to ordinary cancel button. But according to the struts documentation cancel performs the action that is why your validation is getting activated ie., your cancel button is trying to call the action. You can check the documentation

http://struts.apache.org/userGuide/struts-html.html#cancel
 
michelle Wang
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, Srilakshmi Vara .
But May I know what's the code of your normal button?
I only know use this:
history.go(-1)

The history.go(-1) is not stable also, if have many invalide submision, it can not work properly.
 
michelle Wang
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any one can help? I still struggling with the cancel button....
Any one can provite working sample code? Thanks!!
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michelle,

Use html:button instead of html:cancel name it with cancel and use the following javascript on onclick event of cancel button

function formCancel() {
var agree = confirm("You are about to exit this window and all the information on this page will be lost. Do you want to proceed?");
if(agree) {
window.opener.top.main.location.href = window.opener.top.main.location.href;
window.close();
} else {
return false;
}
}

I think this will help you

Srilakshmi
 
michelle Wang
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Srilakshmi Vara :
Thanks for ur help, I just tried to apply to my code, but hit this javascript error:

Char:3
Code:0
Error:'window.opener.top' is null or not an object
Sorry, I'm poor in javascript...
and btw, this line looks strange to me:
window.opener.top.main.location.href = window.opener.top.main.location.href;
Isn't it's both sides are the same?
[ June 21, 2005: Message edited by: michelle Wang ]
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you a project window and a child window The function i gave closes the child window and refreshes the project window.

This line is to refresh the project window, it is specific to my project remove this

window.opener.top.main.location.href = window.opener.top.main.location.href;


So remove the above line and try to execute the code it works.

If you still have problems, Let me know what type of action you want on clicking the cancel button.

Srilakshmi
 
michelle Wang
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Srilakshmi :
I think the code is not suitable for my case.. I only have 1 window, the first page is an search condition, then second page is a result list by the search condition, this second page has a "create new" button, When i click on the button will go to the create new page, now the "cancel" button come out, it is in the create new page, when I click "cancel" here , it should go back to the list(the second page). But now the pbm is bcs the list is retrieve from DB and based on the first page's search condition.. How to make it display again when I cancel from the third page?
Hope you understand what I mean, Thanks a lot.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic