Share on Google+Share on Google+

meeya
What is Struts 2 RequiredFieldValidator? Need an Example or Code
2 Answer(s)      9 years ago
Posted in : Struts

What is Struts 2 RequiredFieldValidator?
Need an Example or Code on Field Validation in Struts 2.

Ads

View Answers

February 21, 2008 at 8:06 PM


Please follow the following instruction:

1. index.jsp

<ul>
<li><a href="roseindia/requiredFieldValidatorError.action">RequiredFieldValidator Example</a></li>
</ul>

2. struts.xml

<action name="requiredFieldValidatorError">
<result>/pages/chatQuestion/requiredFieldValidatorError.jsp</result>
</action>

<action name="requiredFieldValidatorError1" class="net.roseindia.requiredFieldValidatorAction">
<result name="input">/pages/chatQuestion/requiredFieldValidatorError.jsp</result>
<result name="error">/pages/chatQuestion/requiredFieldValidatorError.jsp</result>
<result name="success">/pages/chatQuestion/requiredFieldValidatorSuccess.jsp</result>
</action>

3. requiredFieldValidatorError.jsp

<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<title>RequiredFieldValidator Example!</title>

<link href="<s:url value="/css/main.css"/>" rel="stylesheet"
type="text/css"/>

<s:head theme="ajax" />
<s:actionerror/>

</head>
<body>

<s:form name="validate" action="requiredFieldValidatorError1" method="POST" validate="true">
<s:textfield name="username" label="Username"/>
<s:password name="password" label="Password"/>
<s:submit value="Submit" />

</s:form>

</body>

</html>

4. requiredFieldValidatorSuccess.jsp

<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<title>RequiredFieldValidator Example!</title>

<link href="<s:url value="/css/main.css"/>" rel="stylesheet"
type="text/css"/>
</head>
<body>

Username: <s:property value="username" /><br>
Password: <s:property value="password" />

</body>

</html>

Whenever user don't input any data then it displays an error. If you enter username and password then you get your username and password in requiredFieldValidatorSuccess.jsp.


February 21, 2008 at 8:19 PM


For knowing more information about RequiredFieldValidator then you go:http://www.roseindia.net/struts/struts2/struts2login.shtml

Regards
Neelam









Tutorials   
Java Spring Hibernate Struts Training Dynamic tabs in struts 1.2 Unable to upload a file to mysql database using struts1 Pagination in struts 2 struts2 filterdispatcher is deprecated please use the new filters viewing How to add struts2 dependency in Maven? Struts Exception Handling can you check below code if any erors multimedia how to display the value of termcell name in label class not found exception Where to learn Struts 2? dropdown cacheing Upload and Download Large files in jsp What is Struts 2 framework struts and hibernate based health care project source code struts and hibernate based health care project source code Struts 2 Integration with Struts 1 About captcha of strut2 About captcha of strut2 Which is the good website for struts 2 tutorials? advance java source code source code In Struts 2 how to pass the Struts struts internationalization for Korean language struts2 Struts2 and Hibernate Fetch Data Base Value Struts2 and Hibernate Fetch Data Base Value Struts2 and Hibernate i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse Struts2 and Hibernate Struts2 and Hibernate Struts2 validation Procedure Struts2 validation Procedure Struts2 validation Procedure Struts2 validation Procedure Struts 2 action-validation.xml not loading Struts-2 and Ajax integration STRUTS QUESTION conerting web project into .exe file About Select tag ScartApplication aplicacion ecommerce struts 1.3 struts 1.3 sms prob Need to know struts1 all jar file names struts with hibernate

Ads

 
Advertisement null

Ads