YOUR FEEDBACK
Gregor Rosenauer wrote: well, not what's your take on this? Did I miss a second page of this article or...


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Struts Validations Framework Using AJAX
Real-time data validation is one of the advantages of AJAX technology

Build Action and Action Form
For the Struts action, we just forward to the JSP we already built. The Action code will look as follows:

public ActionForward execute(...) {
return mapping.findForward("success");
}

The Action Form code will validate the requiredText property if the input is blank. Remember to extend this form from the AjaxForm class. The validate method of action form will appear as follows:

public ActionErrors validate(...) {
   ActionErrors errors = new ActionErrors();
   if (StringUtils.isEmpty(this.requiredText)) {
   errors.add("requiredText", new ActionError("error.required.input"));
   }
   request.setAttribute(Globals.ERROR_KEY, errors);
}

Applying Struts Validation Rules
The configure Struts validation rule, such as minimum length, maximum length, e-mail, and pattern text, will be applied to the input object of the client and the configuration will be similar to Listing 4.

Validation Processing Flow
First the client will initiate the XMLHTTP component to perform the request to the server and, then, on the event the user trigger starts to build, the parameter of the URL will be sent to the server. After its finish building the parameter, the client will attach the event of the oneadystatechange XMLHTTP to listen to the response from the server-side. When the response is accepted, the client side will start to parse the XML validation message and set the message into the right area (see Figure 6).

When the request is accepted to the server, the server will start to check the parameter of the AJAX validation condition and process the validation. Once it's finished, the errors object generated will be filtered into the specific error that is related to the user input object. From this point, the XML message will be generated after the filtering process is done and sent back to the client (see Figure 7).

Summary
In this article we built a controller that has the ability to receive asynchronous requests from the client and incorporate with the struts validation process to produce the action error object. Filtering the specific input object being validated will be done after the error object produces and generates the XML message as a reply to the client-side to indicate the error message (See Image 8 and Image 9).

About Sonny Hastomo
Sonny Hastomo is an IT architect at Sun Microsystems, Indonesia, for the telecommunication industry division. His currently is focusing on providing solution design, sizing, implementation, consulting services, and quality support to customers in their evaluation of their IT challenges.

YOUR FEEDBACK
hanan mahmoud wrote: hi all its realy great article and it helped me to understand validation in ajax better ,i just hope if any one have sample code about that topic because till now i don't know how to find one and also i don't know where to put the code samples in the article so plz help me
Commenter wrote: I just need examples, and I can´t find it here. This article is weak.
SYS-CON Belgium News Desk wrote: Struts Validations Framework Using AJAX Real-time data validation is one of the advantages of AJAX technology. By applying this technology, the struts validation framework will enrich the struts MVC and move the Web application closer to the desktop application.
SYS-CON Australia News Desk wrote: Real-time data validation is one of the advantages of AJAX technology. By applying this technology, the struts validation framework will enrich the struts MVC and move the Web application closer to the desktop application.
AJAX News Desk wrote: AjaxWorld: Struts Validations Framework Using AJAX Real-time data validation is one of the advantages of AJAX technology. By applying this technology, the struts validation framework will enrich the struts MVC and move the Web application closer to the desktop application.
Rajesh wrote: The article was really nice.It would have been better if the source code was included. Thanks
waikit wrote: can I have a sample code of the example shown in this article, please regards
SYS-CON Australia News Desk wrote: Real-time data validation is one of the advantages of AJAX technology. By applying this technology, the struts validation framework will enrich the struts MVC and move the Web application closer to the desktop application.
Artem Vasiliev wrote: Sonnie, thank you for your article, it brings pretty interesting idea. It would be great to see some sample application (with source code of course) implementing this approach. I even thought that I would find as a source code for the article, but seems like JDJ doesn't have such practice. Sonnie, can you provide that? It could be an archive hosted somewhere, here or at some free hosting, e.g. http://rapidshare.de/
LATEST JAVA STORIES & POSTS
JavaScript 2 is becoming increasingly important. Learn how to take advantage of JavaScript 2 while still running in today's browsers. Leverage your current JavaScript and HTML skills to build applications that run in Flash 7-9, DHTML and more with no code changes! OpenLaszlo 4.2 ...
GigaSpaces Technologies and GoGrid have announced the availability of the GigaSpaces eXtreme Application Platform (XAP) on GoGrid's enterprise-grade cloud computing service for Windows and Linux. The two companies’ joint offering enables enterprises to migrate existing and new ...
JavaScript is a language with more than its share of bad parts. It went from non-existence to global adoption in an alarmingly short period of time. It never had an interval in the lab when it could be tried out and polished. JavaScript has some extraordinarily good parts. In Jav...
Since its emergence, Web Service technology has gone a long way towards perfecting itself and finding its right application in the real world. With the maturity of the specifications, Web Service technology, with its power of interoperability, is now the major enabling technology...
Terracotta has announced the latest version of their open source Java clustering solution, Terracotta version 2.7. The new version builds on the adoption of Terracotta in specific vertical markets and applications such as reservation systems, online gaming, and information portal...
Microsoft said, “Going forward we’ll use jQuery as one of the libraries used to implement higher-level controls in the ASP.NET AJAX Control Toolkit, as well as to implement new AJAX server-side helper methods for ASP.NET MVC. New features we add to ASP.NET AJAX (like the new ...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

SPONSORED BY INFRAGISTICS
In every field of design one of the first things students do is learn from the work of others. They ...
There are many forces that influence technological evolution. After a decade of building enterprise ...
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver...
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated...
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI...
The YUI development team has released version 2.5.2; you can download the new release from SourceFor...
ADS BY GOOGLE