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



Home Answers Viewqa Struts Struts validation not work properly

Have Programming Question? Ask it here!
 
 
 


firdaus zulkafli
Struts validation not work properly
1 Answer(s)      4 years and 7 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>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
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!   
Advertisements
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  what is the best way to use validation in Struts?either "validation.xml" or JavaScript
sing validator framework work in struts
sing validator framework work in struts  How does client side validation using validator framework work in struts
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 - 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
validator framework work in Struts
validator framework work in Struts  How does validator framework work in 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
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
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
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
validation - Struts
information, http://www.roseindia.net/struts/struts-login-form.shtml Thanks
what is custom validation in struts
what is custom validation in struts  what is custom validatons in struts
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
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
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
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
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
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
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
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 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 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
validation
validation  validation
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page  <p>?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
Form validation in javascript using jsf page  ?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html
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
What are Interceptors in Struts 2 and how do they work?
What are Interceptors in Struts 2 and how do they work? Understanding Struts 2 Interceptors concept is very important in learning the Struts 2. You should... of the work in Struts 2 framework. Interceptors can invoke logic before
validation
validation  we are doing payroll system project in java.So pls provide the complete validation code for employee master form
i need a school appication using struts frame work with oracle 10g using myeclipse6.0
i need a school appication using struts frame work with oracle 10g using myeclipse6.0   hi i need a school apllication using struts frame work backend 10g xe using myeclipse 6.0
validation.....
validation.....  hi.......... thanks for ur reply for validation code. but i want a very simple code in java swings where user is allowed to enter only numerical values in textbox , if he enters string values then it should
Why are my variables not dividing properly?
Why are my variables not dividing properly?  Why are my variables not dividing properly
Validation
); JLabel label=new JLabel("JTable validation Example",JLabel.CENTER); JPanel panel=new JPanel(); panel.add(scroll); JFrame frame=new JFrame("JTable validation
validation
validation  please help me to check validation for <form> <table class="form"> <tr> <td class="col1"> <label>Sno:</label> </td> <td
validation
:checkbox path="community" value="Struts" label="Struts" /><
output not coming properly - JSP-Servlet
output not coming properly  I am not getting the output properly when i had written my code like below: Add Employee Details for( j=0;j<11;j++) { out.println("Department code
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
validation query
validation query  where I should kept properties file inside struts Web application
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 - 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
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
 

 

 

DMCA.com