dcsimg
Edit form validation gives problem!!!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   pat_pat
Posted On:   Monday, January 27, 2003 09:30 PM

i have a register.htm page with couple of fields like: propertycode, propertyName, Address, city, state, country. for validation of these fields i am using Bean called FormValidation.java Once user fills register.htm it will be posted to process.jsp: process.jsp: <%@ page import="java.util.*" %> <%@ page language="java" import="FormValidation"%> <% if (formHandler.validate()) { %> <% } else { %> <% } %> FormValidation.java Bean will validate all the fields entered by the user like   More>>

i have a register.htm page with couple of fields like:


propertycode, propertyName, Address, city, state, country.


for validation of these fields i am using Bean called FormValidation.java


Once user fills register.htm it will be posted to process.jsp:


process.jsp:


<%@ page import="java.util.*" %>

<%@ page language="java" import="FormValidation"%>








<% if (formHandler.validate()) { %>



<% } else { %>



<% } %>


FormValidation.java Bean will validate all the fields entered

by the user like not blank or null length etc., along with it i have

propertycode field to be checked, which is to validate using

database , should be unique propertycode allowed for insert.


so this FormValidation Bean will check whether propertycode is already

entered or not.
if already entered it will display message in retry.jsp

which have the same interface as register.htm only difference is error messages

will be stuffed in it and importing formValidation

retry.jsp:


<%@ page import="java.util.*" %>
<%@ page language="java" import="FormValidation"%>









Property Code *


<%=formHandler.getPropertyCode()%>'

size=8 maxlength=8>

<%=formHandler.getErrorMsg("PropertyCode")%>

and so on.....

so untill formHandler.validate() = true this will be in loop,

every thing works fine but when i am doing Update/Edit of already entered

propertycode it fails for validation of propertycode with this FormValidation.java bean

because propertycode is already inserted without any errors and retreiving them in

the same format and trying to change the data and resubmitting, all field Validations

works fine expect propertycode, propertycode is already there in the database

if i give new propertycode it works fine, but this is edit, propertycode can be same

can change to new.

How to solve this problem ? Any help greatly appreciated.

thanks in advance.    <<Less

Re: Edit form validation gives problem!!!

Posted By:   vinay_salehithal  
Posted On:   Tuesday, January 28, 2003 04:22 PM

This means you have to differentiate between, how you do yr validation(for property code) , based on whether this is a new entry or update/edit an existing entry.

Try to send in a flag(hidden attribute or somesuch thing), which will allow yr validate method to differentiate between a new entry validation and an update/edit entry validation.
Then accordingly implement two different validation logic within yr validate method to satisfy the above criteria.
About | Sitemap | Contact