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



Home Answers Viewqa Struts Struts validation not work properly
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


firdaus zulkafli
Struts validation not work properly
1 Answer(s)      4 years and 11 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
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
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 - Struts
information, http://www.roseindia.net/struts/struts-login-form.shtml Thanks
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
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
Advertisements
 

 

 

DMCA.com