I can't believe how much problem I've been having with the struts validator framework! I can get NOTHING to work and have spent HOURS on this! I've read about 4 online tutorials, went through 3 textbooks and it's still not working. Any help would be appreciated. Here is my DIRT SIMPLE example that DOESN'T work.... Grrrrrr.... -- struts-config.xml -- <form-bean name="TestForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="email" type="java.lang.String"/> </form-bean> . . . <action path="/TestAction" type="mypack.TestAction" name="TestForm" input="/test.jsp"> <forward name="GOOD" path="/thankyou.jsp"/> </action>
-- validation.xml -- <form name="TestForm"> <field-property name="email" depends="required"/> </form> -- my test.jsp -- <%@ include file="/WEB-INF/taglibs.jsp" %> <HTML><HEAD><TITLE>Test page</TITLE></HEAD> <BODY> <H1>test page</H1> <P> Errors start <BR> <html:errors/> Errors end <P> <html:form action="/TestAction"> Your email: <html:text property="email"/><P> <html:submit/> </html:form> </BODY></HTML> ************************* Note: the WEB-INF/taglibs.jsp contains taglib declarations for all struts taglibs. (This is the ONE thing that actually works in this project of mine). Also the action class does nothing but return the "GOOD" string. (It SHOULDN'T do anything, right? The validation framework is automatic, right?) So, I boot my server and ensure that both validation XMLs are loaded. Then go into my input page, just push the submit without filling in the email section to test the validation. I am immediately ushered to the "Thank you for the valid data" screen. What is wrong here? I've seen about 8 posts via google about people having problems with this, but not one answer. I'm to the point where I now believe that the validation framework is vaporware! [ July 13, 2003: Message edited by: Jason Kosowan ]
Hi there, My suggestion might be in left field because I haven't used the Validator Framework for a LONG time and my books aren't not here. But I seem to recall that when using DynaValidatorForms, you need to associate the action with validation codem not the form bean per se. Try changing the validation code to refer to the name of the Struts action instead of the form bean. Here is an example from my code. If I have a form bean defined as follows:
Hi again, And of course, don't forget to register the validator plugin in the struts-config.xml file as follows:
posted 16 years ago
Hi again and thanks for the suggestions. I tried the suggestion about putting the action into the validation.xml, however and still no luck. So, then I went even simpler. I switched to a normal validator form to test even if the regular Validation worked. I made sure to extend from ValidatorForm and put in all of the niceties but *No Dice*. I'm completely stumped.
It must be something small that I'm missing here. I'd love to be able to use this framework and thought it would be fairly straightforward, but the integration is astoundingly rough. If anyone has more ideas, please let me know. I think my next step is to override the validate in the ValidatorForm and see if it even gets called. If it doesn't then I think I've got a very bad problem. Maybe it's my container? (I'm running Resin 2.19)
posted 16 years ago
More news - overriding the validation portion of the form confirms that the validation is being automatically called. But, it also confirms that the super.validate is not returning any ActionErrors, regardless of invalid input!