| By Sonny Hastomo | Article Rating: |
|
| April 6, 2007 10:00 AM EDT | Reads: |
94,503 |
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).
Published April 6, 2007 Reads 94,503
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By 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.
![]() |
hanan mahmoud 07/27/08 03:39:45 AM EDT | |||
hi all |
||||
![]() |
Commenter 05/17/06 01:40:52 PM EDT | |||
I just need examples, and I can´t find it here. This article is weak. |
||||
![]() |
SYS-CON Belgium News Desk 05/02/06 03:27:56 PM EDT | |||
Struts Validations Framework Using AJAX |
||||
![]() |
SYS-CON Australia News Desk 05/02/06 01:44:38 PM EDT | |||
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 05/02/06 12:55:46 PM EDT | |||
AjaxWorld: Struts Validations Framework Using AJAX |
||||
![]() |
Rajesh 05/02/06 12:17:24 PM EDT | |||
The article was really nice.It would have been better if the source code was included. Thanks |
||||
![]() |
waikit 02/08/06 04:11:11 AM EST | |||
can I have a sample code of the example shown in this article, please regards |
||||
![]() |
SYS-CON Australia News Desk 01/27/06 02:21:45 PM EST | |||
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 01/26/06 06:18:56 AM EST | |||
Sonnie, thank you for your article, it brings pretty interesting idea. |
||||
- Kindle 2 vs Nook
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Windows 7 – Microsoft’s First Step to the Cloud
- Ulitzer Provides a Powerful Social Journalism Platform
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Open Source Mobile Cloud Sync and Push Email
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- US Post Office Hops a Ride on NetSuite’s Cloud
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Where Are RIA Technologies Headed in 2008?
- Struts Validations Framework Using AJAX






































