Java, J2SE, J2ME, J2EE, ANDROID, JQUERY, JAVA SCRIPT, JSP, SERVLET, Collection Framework, Java Generics, C, C++
Tuesday, April 28, 2015
STRUTS2 VISITOR VALIDATOR COMPLETE EXAMLE
Login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!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>Login</title>
<style>
.errorMessage{
color:red;
font-size: 11px;
text-align:right;
}
</style>
</head>
<body>
<center>
<s:form action="loginAction" method="post" validate="true" >
<s:textfield name="user[0].username" label="Username" />
<s:textfield name="user[0].password" label="Password" />
<s:textfield name="mobileNumber" label="Mobile Number" />
<s:submit/>
</s:form>
</center>
</body>
</html>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!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>Login</title>
<style>
.errorMessage{
color:red;
font-size: 11px;
text-align:right;
}
</style>
</head>
<body>
<center>
<s:form action="loginAction" method="post" validate="true" >
<s:textfield name="user[0].username" label="Username" />
<s:textfield name="user[0].password" label="Password" />
<s:textfield name="mobileNumber" label="Mobile Number" />
<s:submit/>
</s:form>
</center>
</body>
</html>
LoginAction.java
import java.util.List;
import mod.User;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;
public class LoginAction extends ActionSupport{
private String mobileNumber;
private List<User> user;
public String getMobileNumber() {
return mobileNumber;
}
public void setMobileNumber(String mobileNumber) {
this.mobileNumber = mobileNumber;
}
@VisitorFieldValidator(message = "Userssss")
public List<User> getUser() {
return user;
}
public void setUser(List<User> user) {
this.user = user;
}
}
LoginAction-validation.xml
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
<validators>
<field name="mobileNumber" >
<field-validator type="requiredstring" short-circuit="true" >
<message>Empty Mobile Number !</message>
</field-validator>
</field>
</validators>
<validators>
<field name="mobileNumber" >
<field-validator type="requiredstring" short-circuit="true" >
<message>Empty Mobile Number !</message>
</field-validator>
</field>
</validators>
User.java
package mod;
public class User {
private String username;
private String password;
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* @param username the username to set
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
}
public class User {
private String username;
private String password;
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* @param username the username to set
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
}
welcome.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>
WELCOME TO CUSTOM VALIDATION DEMO PROJECT
</body>
</html>
pageEncoding="ISO-8859-1"%>
<!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>
WELCOME TO CUSTOM VALIDATION DEMO PROJECT
</body>
</html>
Thanks
Keep Visiting. Be happy :)
Monday, April 27, 2015
JQuery to count total TD available in particular TR
var totalCells = $(this).parent().find('td').size();
Subscribe to:
Posts (Atom)
Scrum and Scrum master
Scrum Scrum is a framework which helps a team to work together. It is like a rugby team (the scrum name comes from rugby game). Scrum enco...
-
Docker: Docker is a tool/system/framework designed to make it easier to create, deploy, and run applications by using containers. Contain...
-
var beanPropertyArray = []; columnData = { "1": "One", "2": "Two", ...
-
Whenever an object of a POJO class is created then it will be in the Transient state An object in a Transient state doesn’t represent any...