Home Answers Viewqa Struts Struts validation not work properly

 
 


firdaus zulkafli
Struts validation not work properly
1 Answer(s)      3 years and 5 months ago
Posted in : Struts

hi...

i have a problem with my struts validation framework.
i using struts 1.0...

i have 2 page which is:

1)index.jsp
===================================

<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<html:link action="/example.do?actLink=addrecord">[Add record]
</html:link><br>
</body>
</html>


2)add.jsp
================================

<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<html>
<head>
<title>JSP for exampleForm</title>
<html:javascript formName="exampleForm" />
</head>
<body>
<html:form action="/example" onsubmit="return validateExampleForm(this)">
<html:errors /> <br>
Name: <html:text property="name" /> <br>
Age: <html:text property="age" /> <br>
Email: <html:text property="email" /> <br>
NRIC: <html:text property="nric" /> <br>
Address: <html:text property="address" /> <br>
<html:submit value="Send"/>
</html:form>
</body>
</html>


index.jsp act as my 1st page & when it load it has 1 link [Add record] which will open add.jsp (form). in this add.jsp i have several fields which requires some validation (client side - javascript).

currently i managed to validate 2 fields (name & age). for the rest, when i try to put 1 more validation (let say for email), i could not click on [Add record] link to open add.jsp.

but when i remove it, it can open the add.jsp, it seems like it's only allowed for 2 fields to be validated. what have i missed? is there anything that i forgot...

pls help to advise, i face it for almost a week now...

this is my action class...

========================================

public class ExampleAction extends Action {

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {


String link = (String) request.getParameter("actLink");

System.out.println("actLink----------->"+link);

return mapping.findForward(link);
}

}


my bean class......
=========================================

public class ExampleForm extends ValidatorForm {

//Eigenschaften der Klasse
private String actLink;

private String name;
private int age;
private String email;
private String nric;
private String address;

public String getActLink() {
return actLink;
}
public void setActLink(String actLink) {
this.actLink = actLink;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getNric() {
return nric;
}
public void setNric(String nric) {
this.nric = nric;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}



my struts-config.xml
======================================
<form-beans >
<form-bean name="exampleForm" type="de.laliluna.tutorial.validatorform.form.ExampleForm" />
</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="exampleForm"
input="/form/index.jsp"
name="exampleForm"
path="/example"
scope="request"
type="de.laliluna.tutorial.validatorform.action.ExampleAction" >
<forward name="home" path="/form/index.jsp" />
<forward name="addrecord" path="/form/add.jsp" />
<forward name="link1" path="/form/link1.jsp" />
<forward name="link2" path="/form/link2.jsp" />
</action>


</action-mappings>



my validation.xml
=====================================
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

<form-validation>
<global>
<!-- An example global constant
<constant>
<constant-name>postalCode</constant-name>
<constant-value>^\d{5}\d*$</constant-value>
</constant>
end example-->
</global>

<formset>
<!-- validation mapping for example form -->
<form name="exampleForm">
<field property="name" depends="required">
<arg0 key="exampleForm.name"/>
</field>
<field property="age" depends="required">
<arg0 key="exampleForm.age"/>
</field>
<field property="email" depends="required">
<arg0 key="exampleForm.email"/>
</field>
</form>
</formset>
</form-validation>
View Answers









Related Pages:
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... add.jsp (form). in this add.jsp i have several fields which requires some validation
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation... jquery.validate.min.js I called the functions (validate function) properly. But jquery effect does not work. Could you please solve this problem? Thanks!   
Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation... jquery.validate.min.js I called the functions (validate function) properly. But jquery effect does not work. Could you please solve this problem? Thanks!   
validation - Struts
validation  Hi Deepak can you please tell me about struts validations perticularly on server side such as how they work whats their role etc.? thank you
sing validator framework work in struts
sing validator framework work in struts  How does client side validation using validator framework work in struts
Validation - Struts
Validation  what is the best way to use validation in Struts?either "validation.xml" or JavaScript
Struts 2 - Validation - Struts
Struts 2 - Validation annotations  digging for a simple struts 2 validation annotations example
Struts validation
Struts validation  I want to put validation rules on my project.But... validation rules,put the plugins inside strutsconfig.xml, put the html:errors tag... that violate the rules for struts automatic validation.So how I get the solution
validation
code.Ok if you use struts then you can use Validation method valid the in put... madu dil, Can you please add code.Ok if you use struts then you can use Validation method valid the in put. otherwise call the javascript onsubmit to check
struts validation
struts validation  Sir i am getting stucked how to validate struts using action forms, the field vechicleNo should not be null and it should...://www.roseindia.net/struts/strutsvalidatorframework.shtml http://www.roseindia.net
Validation - Struts
Validation  How can i use validation framework i don't understand am...; Hi friend, Phone validation using javaScript function... return true; } Phone Validation
validation
:checkbox path="community" value="Struts" label="Struts" /><
validation - Struts
information, http://www.roseindia.net/struts/struts-login-form.shtml Thanks
validator framework work in Struts
validator framework work in Struts  How does validator framework work in Struts
struts validation
struts validation  I want to apply validation on my program.But i am failure to do that.I have followed all the rules for validation still I am...;%@ include file="../common/header.jsp"%> <%@ taglib uri="/WEB-INF/struts
struts validation
struts validation  I want to apply validation on my program.But i am failure to do that.I have followed all the rules for validation still I am...;%@ include file="../common/header.jsp"%> <%@ taglib uri="/WEB-INF/struts
struts validation problem - Struts
struts validation problem  i used client side validation in struts 2 .but message will display only on the top of the component.i want to display.../struts/struts2/ http://www.roseindia.net/struts/struts2/struts-2-client-side-validation
Regarding struts validation - Struts
Regarding struts validation  how to validate mobile number field should have 10 digits and should be start with 9 in struts validation?  Hi... ------------------------------------------------------------- For more information : http://www.roseindia.net/struts/struts_validator
Struts Validation - Struts
Struts Validation  Hi friends.....will any one guide me to use the struts validator...   Hi Friend, Please visit the following links: http://www.roseindia.net/struts/struts_validator_framework.shtml http
what is custom validation in struts
what is custom validation in struts  what is custom validatons in struts
validation using validate method
validation using validate method  HOW TO DO THE VALIDATION IN THE STRUTS 2 USING VALIDATE METHOD IN ACTION CLASS,AND ALSO AM HAVING MY BEAN CLASS AS SEPERATE. I HAD TRIED THAT BUT IT WAS NOT WORKING PROPERLY. IF U KNOW
validation problem in struts - Struts
validation problem in struts  hi friends... m working on one project using struts framework. so i made a user login form for user authentication. nd i write d code for sql connection and user athunetication in d action class
struts client side validation
struts client side validation  how can i code for client side validation
server side validation in struts
server side validation in struts  Hello sir, i want to do server side validation in struts based on 3 fields. those 3 field are BatchNo,LotNo,StepNo.Here we can have the same batchno,lotno for different forms
struts
struts  <p>hi here is my code in struts i want to validate my form fields but it couldn't work can you fix what mistakes i have done</p>... }//execute }//class struts-config.xml &lt;struts
validation problem - Struts
validation problem  i want to create validation class for each action class bot project structure as i create a bean differnt and in action class i... is that in which name i create my validation xml file on bean name or action class name i also
validation message - Struts
validation message  sir, i took help of that example but in that we change only color of the message i want to shift the place of the error message.means all messages are put together at top of the form
Struts2 Validation Problem - Struts
Struts2 Validation Problem  Hi, How to validate field... in the browser having the example of handling the error in struts 2. http... information on Struts 2 visit to : http://www.roseindia.net
Struts 2 Validation
Struts 2 Validation  Hello,I have been learning struts. I have a problem in the validator tag. I have tried tutorials and got those. I have to add the Users to the database. So, have implemented the code. See attachement
validation query
validation query  where I should kept properties file inside struts Web application
validation - Framework
validation  how to validate the action forms in struts? could you please explain how cross validation is done for date?  You go the following url: http://www.roseindia.net/struts/struts-login-form.shtml
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
comboBox validation
comboBox validation  dear sir. i want to know . how to validate radio button in struts using xml validation. thanks
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
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-config.xml
Struts validation for j-query tabs data
Struts validation for j-query tabs data  Hi, I want apply struts validation for J-query tabs data while saving into database, can any body tell please
Regarding tiles and struts - Struts
Regarding tiles and struts  Hi, i have a struts application which... is a tiles page) i am not able to redirect properly it was showing response ...). So, redirect will not work. You can use the action class to conditionally
Client Side validation in Struts 2 application
Client Side validation in Struts 2 application   ...;. This is the only work we have to do and rest work is done by Struts 2... that will generate Java Script code for client side validation. In the last section we
struts
struts   Hi how struts flows from jsp page to databae and also using validation ? Thanks Kalins Naik
java struts validation - Java Server Faces Questions
java struts validation  i m unable to execute a validation page by struts . so please write u program and create a rar/jar file having all program with procedure and sand me . pls........ i m using bea weblogic 8.1 . my mail
Struts Articles
, but the examples should work in any container. We will create a Struts plugin class... into two categories: server-side and client-side. A struts validation framework... the existing struts validation framework with AJAX. A few components, such as a controller
struts
struts  Hi, Here my quation is can i have more than one validation-rules.xml files in a struts application
STRUTS
STRUTS   Validation: user entered as 123.34567 I want the value as 123.34 once the user submits. How you will validate
javascript validation
your question properly..   validation for name it is useful try... validation and for email field it will check formate useing regularexpressions...;html    Email Validation function checkEmail
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, like thanks n regards himanshu
Struts Login Validation. In This code setter of login page is called only one time again it doesnt call it. Why..?
Struts Login Validation. In This code setter of login page is called only one...="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org
Struts 2 Validation (Int Validator)
Struts 2 Validation (Int Validator)       Struts 2 Framework provides in-built validation functions to validate user.... This section discusses all the validation functions available with Struts 2
Struts Alternative
not force you to go the XML route, both technologies will work side by side. Struts... Struts Alternative Struts is very robust and widely used framework, but there exists the alternative to the struts framework
Struts - Framework
, Struts : Struts Frame work is the implementation of Model-View-Controller (MVC) design pattern for the JSP. Struts is maintained as a part of Apache Jakarta... struts application ? Before that what kind of things necessary
Struts 2 Validation Example
Struts 2 Validation Example      ... the form validation code in Struts 2 very easily. We will add the form validation... will see how to generate client side validation code). The Struts 2 validation