It's not a secret anymore!
The moose likes JSF and the fly likes Help on jvascript and validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Help on jvascript and validation" Watch "Help on jvascript and validation" New topic

Help on jvascript and validation

Anu kuriakose

Joined: Mar 13, 2011
Posts: 6
Please excuse me if i am irritating with silly questions. I am a beginner in the programming world. My problem is that from my home page on a button click an alert box has to come. This i have done with javascript, but when i do this the page validation of the home page is skipped. i want the page to be validated first and then ,only if the validation satisfies the alert box should come up. What will i do??? Please do help me....
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

I'm not sure if basic JSF can do this, but I know that RichFaces has a "oncomplete" attribute that can be fired when the action method has run and returned. This only applies to AJAX requests, since non-AJAX submits will reload the entire page, wiping out any JavaScript set up for the previous page display before it can execute.

However, the action method won't run if the builtin validators reject data.

Then again, the whole idea of a popup "data is OK" dialog is a bit suspect, since JSF should be displaying validation errors on the updated web page. So invalid data will cause error display and the action method won't fire. Valid data will cause no error display and the action will fire, and usually at that point, you'll be navigating to to a new page. Although I do have some apps that add a "record 'XYZ' updated successfully" message to the current page and redisplay it.

An IDE is no substitute for an Intelligent Developer.
subject: Help on jvascript and validation
It's not a secret anymore!