i'm creating web app and there i need users to register in order to use services.
while registering an int field Phone Number is required, i want to have phone numbers as int only. also o'm using action bean to retrive data.
my problem is that field is not returning any data if the length of integer is more then 8 digits???
here is the bean
please help!/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package formbeans; import javax.servlet.http.HttpServletRequest; import model.ObjectNotFoundException; import model.user; import model.userDAO; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; /** * * @author Arvind */ public class register extends org.apache.struts.action.ActionForm { private String name, username, password, cpassword, address; private int number; userDAO userDB = new userDAO(); user user = new user(); /** * @return */ public String getName() { return name; } /** * @param string */ public void setName(String string) { name = string; } /** * @return */ public int getNumber() { return number; } /** * @param i */ public void setNumber(int i) { number = i; } /** * */ public register() { super(); // TODO Auto-generated constructor stub } /** * This is the action called from the Struts framework. * @param mapping The ActionMapping used to select this instance. * @param request The HTTP Request we are processing. * @return */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (getUsername() == null || getUsername().length() < 1) { errors.add("name", new ActionMessage("error.user.required")); } if (getPassword() == null || getPassword().length() < 1) { errors.add("name", new ActionMessage("error.password.required")); } if (!getCpassword().equals(getPassword())) { errors.add("name", new ActionMessage("error.mis-match.required")); } if (getName() == null || getName().length() < 1) { errors.add("name", new ActionMessage("error.name.required")); } if (getAddress() == null || getAddress().length() < 1) { errors.add("name", new ActionMessage("error.address.required")); } phonelength(); try { if(searchmember()) errors.add("already", new ActionMessage("error.alredy.required")); } catch (ObjectNotFoundException ex) { errors.add("unexpected", new ActionMessage("error.runtime")); }catch(NumberFormatException e){ errors.add("unexpected", new ActionMessage("error.numbers")); } return errors; } private boolean searchmember() throws ObjectNotFoundException { int i = userDB.search(getUsername()); System.out.println(i); if ((i>0)) { return true; } return false; } private void phonelength(){ System.out.println("Phone is\t"+getNumber()); } /** * @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; } /** * @return the cpassword */ public String getCpassword() { return cpassword; } /** * @param cpassword the cpassword to set */ public void setCpassword(String cpassword) { this.cpassword = cpassword; } /** * @return the address */ public String getAddress() { return address; } /** * @param address the address to set */ public void setAddress(String address) { this.address = address; } /** * @return the phone */ }