wood burning stoves 2.0*
The moose likes Struts and the fly likes Dynamic Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic Validation" Watch "Dynamic Validation" New topic
Author

Dynamic Validation

Navi Lock
Ranch Hand

Joined: Jul 29, 2003
Posts: 39
Friends, need some help on the below..

Idea is to learn Dynamic validation using Struts Validation framework.
I am using "org.apache.struts.validator.DynaValidatorForm" for validating a form as below :

Struts-Config.xml:-
<form-beans>
<form-bean name="dummy" type="org.apache.struts.validator.DynaValidatorActionForm">
<
form-property name="tn" type="java.lang.String" />
</form-beans>
<action path="/myController" type="abc.efg.controller" name="dummy" validate="true" scope="request">
<forward name="RESULT_PAGE" path="/Response.jsp" />
<forward name="TECH_DIFFICULTY" path="/TechDifficulty.jsp" /> <forward name="VALIDATION_FAILURE" path="/Request.jsp" /> </action>

Validation.xml:-
<form-validation> <formset> <form name="dummy"> <field property="tn" depends="required"> <arg0 key="prompt.TN" /> </field> </form> </formset> </form-validation>

Request.jsp page :-

<html:errors/> <html:form action="myController"> <TABLE border="1"> <TBODY> <TR> <TD width="364">Form</TD> </TR> </TBODY> </TABLE> <TABLE border="10"> <TBODY> <TR> <TD> Telephone Number</TD> <TD width="184"><INPUT name=<%=SimpleConstants.TN %> type="text" value="" size="21"></TD> </TR> </TBODY> </TABLE> .. ..

I am not entering any value for TN field. My understanding is that, if you use Dynamic Forms then the flow should not reach the Action (myController) ..
but it does and does not throw any validation exceptions on the page..

Please let me know what i am missing..

Thanks in advance -Navi
[ September 18, 2007: Message edited by: Navi Navi ]
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I am using "org.apache.struts.validator.DynaValidatorForm"

Are you? Your code snippet is using DynaValidatorActionForm. The "action" versions of these forms differ in that they look for a validator rule where the name matches the name of action. Try switching over to use DynaValidatorForm and see if that fixes your problem.

- Brent
Navi Lock
Ranch Hand

Joined: Jul 29, 2003
Posts: 39
Hi Brent,
Thanks for responding..
Yes i am using 'DynaValidatorActionForm'..apologies for the wrong info..

But if i try using the 'DynaValidatorForm' i get the follwoing message
'No input attribute for mapping path /myController'


I am open to either one.. just dont want to create Static forms if possible...

Also i changed the Validation.XMl file as below ('DynaValidatorActionForm') but no changes

<form name="myController">
<field property="tn" depends="required">
<arg0 key="prompt.TN" />
</field>
</form>


Thanks,
-Navi.

[ September 18, 2007: Message edited by: Navi Navi ]

[ September 18, 2007: Message edited by: Navi Navi ]

[ September 18, 2007: Message edited by: Navi Navi ]
[ September 18, 2007: Message edited by: Navi Navi ]
Navi Lock
Ranch Hand

Joined: Jul 29, 2003
Posts: 39
Guys any suggestion is appreciated..

-Navi
Navi Lock
Ranch Hand

Joined: Jul 29, 2003
Posts: 39
My apologies..
I had named the validation.xml file as 'Validation.xml'{upper case} and that was causing to miss the validation.

Thanks again for the responses
-Navi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dynamic Validation
 
Similar Threads
Error 'required' is undefined
Struts 1.x, 2, jstl questions
server side validation errors
validation
Validator Problem