Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts sing validator framework work in struts

Have Programming Question? Ask it here!
 
 
 


Clark
sing validator framework work in struts
1 Answer(s)      3 years and 9 months ago
Posted in : Struts


How does client side validation using validator framework work in struts ?


Advertisement
View Answers

November 19, 2010 at 4:52 PM


Hi friends,

Struts provides two files for validation.
1 : validator-rules.xml
2 : validation.xml
with the help of this example, you can do client side validation.
Step 1.
Code of jsp page :

    `<html:form action="/bookSaveAaction" method="post" onsubmit="return validatebookForm(this);"`>

<html:text property="bookId" size="30" maxlength="30"/>
<html:text property="bookName" size="30" maxlength="30"/>

<html:submit>Save</html:submit>

<!-- Start tag of  Validator Javascript Function-->
<html:javascript formName="empForm"/>
<!-- End tag of Validator Javascript Function-->
</html:form>
this tag is used for client side validation.

Step 2.
struts-config.xml is cofiguration file. It is used for action mapping

<action
path="/bookSaveAaction"
type="bookForm"
name="AddressForm"
scope="request"
validate="true"
input="/bookform.jsp">
<forward name="success" path="/success.jsp"/>
</action>

<form-beans>
<form-bean name="bookForm" type="com.roseindia.form.bookForm" />
</form-beans>

Step 3. validator-rules.xml :

The validation definitions available for given application is defined by the validator-rules.xml files. The validator-rules.xml file acts as a template, defining all of the possible Validators that are available to an application.

validator-rules.xml File :

</global>
</form-validation>

    <validator name="required"
                   classname="org.apache.struts.validator.FieldChecks"
                   method="validateRequired"
                   methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionMessages,
                       org.apache.commons.validator.Validator,
                       javax.servlet.http.HttpServletRequest"
                   msg="errors.required"/>
   </global>

</form-validation>

Step 4. validation.xml File : The validation.xml file is where you couple the individual Validators defined in the validator-rules.xml to components within your application. validation.xml File

<form-validation>
<formset>
<form name="bookForm">
<field
property="bookId"
depends="required">
<arg key="label.bookId"/>
</field>

<field
property="bookName"
depends="required">
<arg key="label.bookName"/>
</field>
</form>
</formset>
</form-validation>

The bookId and bookName are the required filed of the bookForm . So in the above configuration you can see we add for both bookId and bookName.

You can see depends="required" - "required" property is defind in validator-rules.xml.

In the resource bundle : application_resource.propertis file
label.bookId=bookId
label.bookName=bookName
Error messages used by the Validator errors.required={0} is required.

Based on the validation.xml File configuration . Error in jsp will be : Java Script message.
bookId is required.
bookName is required.

Thanks.



Related Tutorials/Questions & Answers:
sing validator framework work in struts
sing validator framework work in struts  How does client side validation using validator framework work in struts
validator framework work in Struts
validator framework work in Struts  How does validator framework work in Struts
Advertisements
Setup validator framework in Struts
Setup validator framework in Struts  How to Setup validator framework in Struts
Struts Validator Framework
Struts Validator Framework  What is Struts Validator Framework
Using the Validator framework in struts
Using the Validator framework in struts   What is the Benefits of Using the Validator framework in struts
Struts Validator Framework
Struts Validator Framework     ... Framework. In this lesson you will learn how to use Struts Validator Framework... to Validator Framework Struts Framework provides the functionality to validate the form
Fixed Value check using struts validator framework
Fixed Value check using struts validator framework  Hi All, can anyone tell me how to use struts validator framework for fixed value check. eg. country='India'; Thanks in advance
Struts Validator Framework - lab oriented lesson
STRUTS-VALIDATOR FRAMEWORK R.S.Ramaswamy ( developeriq..Oct-2005... framework.In this first part, a simple struts demo with non-framework based... of Validator framework, with a lab-oriented lesson. Since its introduction in 2001
XML files used in Validator Framework?
XML files used in Validator Framework?  Give the Details of XML files used in Validator Framework
Struts 2 double validator
Struts 2 double validator       The Double validator of Struts 2 Framework checks if the given input is double... validator can also be used to check the input range. This example is a demonstration
Struts 2 Date Validator
Struts 2 Date Validator       The Date validator in the Struts 2 Framework checks whether the supplied date lies... demonstrates how to use the date validator to check the input range. [ NOTE: If date
USING THE VALIDATOR FRAMEWORK
STRUTS-VALIDATOR FRAMEWORK USING THE VALIDATOR FRAMEWORK       Validator framework requires two XML files, namely, alidator... and struts-config.xml. So, no special installation is necessary, to use the Validator
Struts 2 E-mail Validator
Struts 2 E-mail Validator       The email validator in  Struts 2 Framework checks whether a given String... value does not match with the email type then the e-mail validator generates
Struts 2 RequiredString validator
Struts 2 RequiredString validator       This section discusses RequiredString validator of Struts 2 framework... the forms, required String validator will generate error message
validation using validator-rules.xml - Struts
validation using validator-rules.xml  Hi I am trying to validate my form using Validator-rules.xml. I am using Eclipse 3.0 Struts 1.1 and Tomcat.../struts/struts_validator_framework.shtml Thanks
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
Struts - Framework
it is better to go for Struts or any other framework. While if you are working... then it is not necessary to use struts or any other framework. Although various MVC frameworks are being used in production, but Struts is the most popular framework than
Struts - Framework
, Struts : Struts Frame work is the implementation of Model-View-Controller... project and is open source. Struts Framework is suited for the application... struts application ? Before that what kind of things necessary
Struts validation not work properly - Struts
Struts validation not work properly  hi... i have a problem with my struts validation framework. i using struts 1.0... i have 2 page which...) { this.address = address; } } my struts-config.xml
struts - Framework
struts  can show some example framework of struts  Hi Friend, Please visit the following links: http://www.roseindia.net/struts/ http://www.roseindia.net/struts/struts2/ Hope that the above links
Struts - Framework
in any other framework or else before starting struts. you just need to have... struts application ? Before that what kind of things necessary... that you are going to learn Struts. Just refer "http://www.roseindia.net
Struts Tutorial
, struts integration with other framework, Struts Validator Framework. What is Struts ? Struts is an open source MVC based framework for developing web..., internationalization, error handling, tiles layout etc. Struts framework is also
struts - Framework
Struts design pattern  Please explain Struts design pattern
struts - Framework
Struts Spring Hibernate Integration  struts spring hibernate integration tutorial
struts - Framework
struts  Tag libs in struts
struts - Framework
be defined in the Commons Validator configuration when dynamicJavascript="true
struts - Framework
Struts flow of execution diagram  What is the structure of struts flow ..can you show it with the help of diagram
Struts 2 Validation (Int Validator)
of Struts 2 framework: Conversion Validator Date Validator Double...Struts 2 Validation (Int Validator)       Struts 2 Framework provides in-built validation functions to validate user
Struts framework
Struts framework  How to populate the value in textbox of one JSP page from listbox of another JSP page using Struts-html tag and java script
Struts framework
Struts framework  How to populate the value in textbox of one JSP page from listbox of another JSP page using Struts-html tag and java script
struts - Framework
struts  Hi,roseindia I want best example for struts Login... in struts...  Hi Friend, You can get login applications from the following links: 1)http://www.roseindia.net/struts/struts-login-form.shtml 2)http
Struts - Framework
Struts  Hi, I am doing a reverse engineering in a project based on struts 1.1,after seeing the log file, i encounter some lines that are written by applicatoin, following are the lines in log related to strtus while
core classes of the Struts Framework
core classes of the Struts Framework  What are the core classes of the Struts Framework
Struts - Framework
================== ........ ....... ......... ........ ================= struts-config.xml
struts opensource framework
struts opensource framework  i know how to struts flow ,but i want struts framework open source code
Struts 2 Url Validator
Struts 2 Url Validator       The URLValidator of Struts 2 Framework checks whether the String contained within... to use the URL validator.  Follow the steps to develop the  URL
What is Struts Framework?
What is Struts Framework? Learn about Struts Framework This article is discussing the Struts Framework. It is discussing the main points of Struts framework... introduction to the Struts framework such as history, features and technology of Struts
Struts Framework - Apache Struts Framework an Introduction
Struts Framework - Apache Struts Framework an Introduction Apache Struts is open source framework that implements the MVC Design pattern. Apache Struts Framework is used to develop enterprise web applications. The Struts framework
Struts development application - Framework
Struts development application  hi friends, I want a source code for validation.xml,validation-rules.xml in DynaValidator framework regarding for struts framework,and what is difference b/w validation.xml and validation
Introduction to Struts 2 Framework
Introduction to Struts 2 Framework - Video tutorial of Struts 2 In this video... of the Struts 2 Framework. The Struts 2 framework is very elegant framework.... Welcome to the world of web application development using Struts 2 Framework
Struts Framework
An introduction to the Struts Framework This article is discussing about the high-class web application development framework, which is Struts. This article will give you detailed introduction to the Struts Framework. Struts
Struts in AJAX - Framework
Struts in AJAX  Dear Deepak Sir, How to use ajax in Struts Framework,if it is possible plz give me one simple example. Thanks & Regards, VijayaBabu.M  Hi, Struts 2 provides inbuilt support for Ajax and Dojo. Its
JSP pages are provided in Struts framework?
JSP pages are provided in Struts framework?  What helpers in the form of JSP pages are provided in Struts framework
how to work with dynaaction form in lomboz - Struts
how to work with dynaaction form in lomboz  hi friends i have on doubt regarding about how to use and work with struts dynaaction form in lomboz i know how to work with actionform in struts plzzzzzzzzzzzzzzzzzz send reply
JSP pages are provided in Struts framework
JSP pages are provided in Struts framework  What helpers in the form of JSP pages are provided in Struts framework
student marks sheet genaration in struts frame work
student marks sheet genaration in struts frame work  Hi every body iam using struts frame work back end as oracle 10g xe i wanna urgent code for student marks genaration code please help me thanks in advance
Action in Struts 2 Framework
Actions Actions are the core basic unit of work in Struts2 framework. Each action provides the processing logic for a specific URL with which it is linked. Actions are mostly associated with a HTTP request of User. The action class
Latest Version of Struts Framework
Complete detail and tutorials about the Latest Version of Struts Framework In this page we are listing the Latest Version of Struts Framework which is being... is working on the development and maintenance of Struts Framework
Struts upload file - Framework
Struts upload file  Hi, I have upload a file from struts... and send to file upload struts..how to get the sheets and data in that sheets Thanks.  Hi friend, For upload a file in struts visit to : http
Advertisements
 

 

 

DMCA.com