It's not a secret anymore!
The moose likes Struts and the fly likes Struts 1.1 validation help on Requiredif Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.1 validation help on Requiredif" Watch "Struts 1.1 validation help on Requiredif" New topic

Struts 1.1 validation help on Requiredif

chingh tangh

Joined: Apr 06, 2004
Posts: 11
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 ( a sample war file that
has one requiredif validation.
This help is very much helpful.
Thanks in advance.
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727
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.

A good workman is known by his tools.
chingh tangh

Joined: Apr 06, 2004
Posts: 11
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=""/>
[ 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.
I agree. Here's the link:
subject: Struts 1.1 validation help on Requiredif
It's not a secret anymore!