This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm developing a simple e-commerce web project for school, and today I had some troubles using validation framework built-in with Struts 2.
As discussed in this thread, it seems that Struts 2 simply ignore the fact that fields that should contain numbers, are empty. In other words, an empty string is considered to be a valid number.
I would like to solve this problem using XML only, is it possible? I know I could check fields within the Java code, but I think it's not the best solution.
I tried to use some validators (regex, required, requiredstring) before the <field-validator type="long">, but none of them worked. I suppose the reason's that all non-number validators expect a String from the getter, but they receives a long.
Jack Dragano wrote: I know I could check fields within the Java code, but I think it's not the best solution.
Frankly, the "best solution" is the one that works. It looks like the XML validator doesn't do what you want it to do.
Since it looks like a few people have encountered this problem, you may want to check the Struts mailing list to see if anyone has an acceptable workaround. If you find one, be sure to check back in with us!