• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic Validation

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys any suggestion is appreciated..

-Navi
 
Navi Lock
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic