This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Help on jvascript and validation" Watch "Help on jvascript and validation" New topic
Author

Help on jvascript and validation

Anu kuriakose
Greenhorn

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: 15952
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
jQuery in Action, 2nd edition
 
subject: Help on jvascript and validation
 
Similar Threads
Need help for Check Box Validation in struts1.2 without using javascript
Action class error problem
Alert Box for Error Message.
customising alert boxes
Struts Validation Empty alert Box