• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Struts 1.1 validation help on Requiredif  RSS feed

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to implement requiredif but it is not working for me in Tomcat
4.1 with Struts 1.1.
Can anybody please send me (mystruts2004@yahoo.com) a sample war file that
has one requiredif validation.
This help is very much helpful.
Thanks in advance.
pie sneak
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may direct you in the right direction.
There's a good reason why requiredif is already deprecated. It's ugly.
I recommend writing your own validation method to achieve the functionality. It's not too hard to do. Just have a method that returns false if you don't want to run any validations.
validwhen may even be a good option unless you are using the 1.1 production release.
chingh tangh
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've gone through requiredif & validwhen in apache site. But, as our production release is struts 1.1, need to implement with requiredif until struts 1.2 goes into our prod.
Tried "requiredif" mentioned in apache, but of no luck. Only "required" validation is working, not getting why in the sameway "requiredif" is not working !!!
I am using Tomcat 4.1
here is my validations.xml
<field property="age" depends="required">
<arg0 key="label.age"/>
<field property="name" depends="requiredif">
<arg0 key="label.name"/>
[ I have tried for NOTNULL and also NULL]
here is the form-bean
<form-bean name="TestForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="age" type="java.lang.String" />
<form-property name="name" type="java.lang.String" />
<form-property name="submit" type="java.lang.String" />
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:form action="MedicalAction" onsubmit="return validateTestForm(this)" >
<html:text property="age" value="" />
<html:text property="name" value="" />
<html:submit property="submit" value="sbt" />
<html:javascript formName="TestForm"/>
Here required validation for 'age' is working fine, But 'name' is not being validated for "requiredif".
I have seen the html page generated, it doesn't have the javascript code for "name".
I am not sure - why required validation is working and why in the sameway requiredif is not working.
Any kind of guess is also thankful.
thanx in advance.
Do not set lab on fire. Or this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!