• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Validation

 
Navi Lock
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys any suggestion is appreciated..

-Navi
 
Navi Lock
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic