Can you make sure that class file of ValidationUtil resides in the classpath
of your application ...

It usually bundled as jar  file.

Prithvi

On 3/29/07, Niall Pemberton <[EMAIL PROTECTED]> wrote:

On 3/28/07, Dwight Galloway <[EMAIL PROTECTED]> wrote:
> here is what I have inside my struts, I guess I am not sure what I must
do inside of the struts config for the validation, but I am using version
1.0 with the config at 1.1.dtd, I inherited this system and I really know
very little about struts, thank you for your help...

OK I was more wondering what you have configured for the
ValidatorPlugIn - should be a <plug-in> element in your struts config.

Also what you say about versions is confusing - can you be explicit
about the Struts version and the Commons Validator version you are
using. For example "the config at 1.1.dtd" doesn't tell me whether
you're referring to the Struts dtd or the Commons Valdiator dtd?

Niall

> <!--=== Cycle ===-->
>                 <action path="/cycle/edit" type="
gov.utah.dhs.pats.service.ui.CycleAction"
>                                 name="cycleEditForm" scope="request"
parameter="getCycle" validate="false">
>                                 <forward name="success"
path=".view.cycle.edit"/>
>                                 <forward name="failure"
path=".view.cycle.edit"/>
>                 </action>
>                 <action path="/cycle/save" type="
gov.utah.dhs.pats.service.ui.CycleAction"
>                         name="cycleEditForm" scope="request"
parameter="saveCycle" validate="false"
>                         input="/cycle/edit.do">
>                 <forward name="continue" path="/session/edit.do"/>
>                 <forward name="failure" path="/cycle/edit.do"/>
>         </action>
>         <action path="/cycle/assignedService" type="
gov.utah.dhs.pats.service.ui.CycleAction"
>                         name="cycleEditForm" scope="request"
parameter="getAssignedServices" validate="false">
>                 <forward name="success" path=".view.session.edit"/>
>         </action>
>                 <action path="/cycle/search" type="
gov.utah.dhs.pats.service.ui.CycleAction"
>                         name="cycleEditForm" scope="session"
parameter="searchCycles" validate="false">
>                 <forward name="success" path=".view.cycle"/>
>                 <forward name="failure" path=".view.cycle"/>
>                 </action>
>
>                 <action path="/cycle/picklist"
forward="/cycle/picklist/search.do" />
>                 <action path="/cycle/picklist/search" type="
gov.utah.dhs.pats.service.ui.CycleAction"
>                         name="cycleEditForm" scope="session"
parameter="searchCycles" validate="false">
>                 <forward name="success" path=".picklist.cycle"/>
>                 <forward name="failure" path=".picklist.cycle"/>
>                 </action>
>
> >>> "Niall Pemberton" <[EMAIL PROTECTED]> 3/28/2007 2:53 PM >>>
> I can't see anything wrong with what you have here. Can you show us
> how you have configured Struts to pick up your custom validation rules
> and also say what version of Struts and what version of Commons
> Validator you are using
>
> Niall
>
> On 3/28/07, Dwight Galloway <[EMAIL PROTECTED]> wrote:
> > I am having troubles getting my own validator to work, I wonder if it
is the classpath where I am pointing to my Class with? I am trying to create
a dateRange validation to determin if the date falls between two dates or
not. This is what I have in my validation.xml
> >
> > >               <field property="startDate"
depends="required,date,dateRange">
> > >                       <arg0 key="Start Date" resource="false"/>
> > >
<var><var-name>datePattern</var-name><var-value>MM/dd/yyyy</var-value></var>
> > >
<var><var-name>minDate</var-name><var-value>07/01/2003</var-value></var>
> >
>                                                                
<var><var-name>maxDate</var-name><var-value>06/30/2004</var-value></var>
> > >               </field>
> >
> > > this is what I have in my validator-rules
> >
> > >       <validator name="dateRange"
> > >               classname="gov.utah.dhs.pats.util.ValidationUtil"
> > >                method="validateDateRange"
> > >          methodParams="java.lang.Object,
> > >       org.apache.commons.validator.ValidatorAction,
> > >       org.apache.commons.validator.Field,
> > >                       org.apache.struts.action.ActionMessages,
> > >                       javax.servlet.http.HttpServletRequest"
> > >               depends=""
> > >                   msg="errors.dateRange"/>
> >
> > >  and my class looks like this, notice I have a println at the start
of my program, it is like it is completely ignoring my class, I am clueless
how to test this and to see what is really happening, I don't have much
experience with struts so please any suggestions would help,thank you...
> >
> > > package gov.utah.dhs.pats.util;
> > > import java.text.SimpleDateFormat;
> > > import java.util.Date;
> > > import javax.servlet.http.HttpServletRequest;
> > > import org.apache.commons.validator.Field;
> > > import org.apache.commons.validator.ValidatorAction;
> > > import org.apache.commons.validator.util.ValidatorUtils;
> > > import org.apache.struts.action.ActionMessages;
> > > import org.apache.struts.validator.Resources;
> > > public class ValidationUtil {
> > >         public static final String DEFAULT_FORM_DATE_PATTERN =
"M/dd/yyyy";
> > >         public static final Date DEFAULT_MIN_DATE =
getDefaultMinDate();
> > >         public static final Date DEFAULT_MAX_DATE =
getDefaultMaxDate();
> > >         public static boolean validateDateRange(Object bean,
ValidatorAction va, Field field, ActionMessages msg, HttpServletRequest
request) {
> > >               //if we're not properly configured to parse dates,
> > >               //all date validation will fail
> > >               System.out.println("!!!!!!!!!!!!!INSIDE THE VALIDATION
UTILITY the FIELD.. " + field );
> > >               if (DEFAULT_MIN_DATE == null || DEFAULT_MAX_DATE ==
null) return false;
> > >               try {
> > >                 String value = ValidatorUtils.getValueAsString(bean,
field.getProperty());
> > >                 Date date = getDate(value,
DEFAULT_FORM_DATE_PATTERN);
> > >                 Date minDate = getDate(field.getVarValue
("minDate"),  DEFAULT_FORM_DATE_PATTERN);
> > >                 Date maxDate = getDate(field.getVarValue("maxDate"),
DEFAULT_FORM_DATE_PATTERN);
> > >                 if (date.compareTo(minDate) < 0 || date.compareTo(maxDate)
> 0) {
> > >                       msg.add(field.getKey().toString(),
Resources.getActionMessage(request, va, field));
> > >                       return false;
> > >                 }
> > >                 return true;
> > >               }
> > >               catch (Exception e) {
> > >                 e.printStackTrace();
> > >                 msg.add(field.getKey().toString(),
Resources.getActionMessage(request, va, field));
> > >                 return false;
> > >               }
> > >         }
> > >
> > >       protected static Date getDate(String dateString, String
pattern) {
> > >         Date date = null;
> > >         try {
> > >               SimpleDateFormat df = new SimpleDateFormat(pattern);
> > >               date = df.parse(dateString);
> > >         }
> > >         catch (Exception e) {
> > >               e.printStackTrace();
> > >         }
> > >         return date;
> > >       }
> > >       protected static Date getDefaultMinDate() {
> > >         return getDate("01/01/1900", DEFAULT_FORM_DATE_PATTERN);
> > >       }
> > >       protected static Date getDefaultMaxDate() {
> > >         return getDate("12/31/2030", DEFAULT_FORM_DATE_PATTERN);
> > >       }
> > >   }
> >
> > > if anyone can please just help guide me a bit on this I would
appreciate it.
> >
> >
> > Dwight S. Galloway
> > (801) 538-4234
> > [EMAIL PROTECTED]
> > Department of Technology Services
> > MAKE IT A GREAT DAY!
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to