Hi,
We are using 7.0.1.134339 P04.
We are using custom jsp to validate basic form level validation. Below is the screenshot how we are calling the jsp. Here we are validating if a serial number that we input in textbox already exists for any user or not.
PFB how we developed jsp -
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Properties" %>
<%@ page import="java.io.ByteArrayOutputStream" %>
<%
HashMap<String, String> values = new HashMap<String, String>();
HashMap<String, String> questions = new HashMap<String, String>();
// Make the parameters and questions easy to access
for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
String name = e.nextElement().toString();
String value = request.getParameter(name);
if (name.startsWith("value.")) values.put(name.substring(6), value);
if (name.startsWith("question.")) questions.put(name.substring(9), value);
}
System.out.println("validateform.jsp request method=" + request.getMethod());
System.out.println("validateform.jsp parameterMap=" + request.getParameterMap());
System.out.println("validateform.jsp values=" + values);
System.out.println("validateform.jsp questions=" + questions);
Properties outputProps = new Properties();
if (!values.containsKey("NEFTID")) {
outputProps.put("error","Where is the NEFTID field!");
} else if ( values.get("NatID") != "" ) {
outputProps.put("error.NEFTID","Please change the NEFTID as this already exists for another user:TEST");
outputProps.put("error","Form validation failed!");
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputProps.store(outputStream, null);
outputStream.close();
out.print(outputStream.toString("ISO-8859-1"));
%>
It works fine and throws error when serial number already exists for user but does not work when we input new serial number. Ideally it should go on next page but its not happening .
Any suggestion what could be issue.
> It works fine and throws error when serial number already exists for user but does not work when we input new serial number.
I don't quite understand what you mean. I suppose that you want to resubmit the corrected webpage again after the first submission fails?
It might fail again if the error condition persists, according to the code if "NatID" is not "". Did you check that the value in the dropdown is updated after the first submission fails?
In our implementation, we also validate forms with JSP Files, but I found that doing it first in the browser is better as the results are displayed immediately. For that you have to (1)Use a a Dropdown with Webservices Field that takes a Text Field as input (in your case NEFTID I guess) and (2) in a Javascript Field check if the Dropdown has any value, if yes then throw error. When the error condition is gone, the Dropdown becomes empty and the error messages should be cleared.