can anyone tell me how to guarantee that the text field the user provide is a double?
how i did this??, mmm, (double a number with/out decimals) well, with regex, With regex you can control the amount of numbers after the dot ".###", if the number should negative or not, maybe start with a range (higher than 100)
i think that with regex is more fexible, furthermore remember this, all the variables of your actionForm are String (a simple class of course without composition).
I'm not sure what you're asking. Since you say you've used it, I assume you know how to apply the double validation rule to this field. If your question is "How does the Struts code validate a double?", the best way to find out would be to download the source code and look at the code in the org.apache.struts.validator.FieldChecks class.
4) Define ValidatorPlugIn in your struts-config.xml file.
Joined: Sep 10, 2004
I'm using the validation.xml but when I put a string value (instead of a number) I get the following error: javax.servlet.ServletException: For input string: "h" org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) javax.servlet.http.HttpServlet.service(HttpServlet.java:709) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I was under the impression the the validation-rules will take care of incorrect type.
Joined: Feb 08, 2006
I am not exactly sure what would cause that exception. My guess is that since the stack trace shows that the code got to processActionPerform, then your execute method is being called and it is your code that is throwing the exception. If you posted your ActionForm and Action code then maybe somebody can help out further.
Joined: Sep 10, 2004
The error comes from the action (the db gets a String (not double) and throws an error)
So...the problem is that it *GETS* to the action without the validity of the dynaActionForm. If the dynaActionForm would have thrown an error BEFORE it gets to the action that would've solved the problem (unfortunately, it doesn't).
I have the validation-rule.xml
but that doesn't kicks in.
Joined: Feb 15, 2005
Carefully review the steps that Brent outlined in his first post. I suspect that you will find one or more of them incomplete or missing. If you still can't find the error, please post:
* The entry for this field in your validation.xml file * your ActionForm * Relevant portions of the JSP * relevant message keys in your ApplicationResources.properties file * relevant portions of your struts-config.xml file [ November 14, 2006: Message edited by: Merrill Higginson ]
ok, this is my resolution: I realized that the form needs more than just checking for double (also date conflicts etc); so it would be much easier to do that with a regular form (not dynaActionForm). Anyhow, this solved the problem.
I guess that when it comes to long (problematic) forms one should not use the dynactionform (but that's just my observation)
thanks for your help at least I got familiar with xml validation.
subject: validator-rule.xml how to guarantee the text-field is a double?