commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "struts commons" <>
Subject new (custom) validation
Date Thu, 30 Sep 2004 13:49:18 GMT
Hello all,
I hope this question is not to remedial but I am really trying to understand 
what's wrong here.
I am trying to create a new validator for 'time'. I am basically parsing the 
string down to test components that make up the user input. I have followed 
numerous examples from books and internet to come up with the code below.
My new class seems to be the problem as I can get the client side to 
function and return a valid boolean but it will not give me the resource 
message either client side or server side. I am able to put alert message in 
my javascript and get those but it will not return with the .properties 
message I wrote. All other validation (date, required, etc.. etc..) works 
fine both client and server.
I included the code (minus the logic, I'm sure that is works) where I 
thought the problem may lie, but I'm new to Struts and fairly new to Java so 
if you need more I would be more than happy to oblige(just tell me what 
would help) but the rest of it seemed fairly standard and not where the 
problem may be.
Thanks in advance.

new class I created

package com.gli.validator;

import javax.servlet.http.HttpServletRequest;
import org.apache.commons.validator.Field;
import org.apache.commons.validator.ValidatorAction;
import org.apache.struts.action.ActionErrors;
import org.apache.commons.validator.GenericValidator;
import org.apache.commons.validator.ValidatorUtil;
import org.apache.struts.util.StrutsValidatorUtil;

public class GLIValidator implements Serializable {
  public GLIValidator(){

  public static boolean validateTime(Object bean, ValidatorAction va, Field 
  ActionErrors errors, HttpServletRequest request) {

  //processing to validate (left out to shorten email but it works)
  // ValidatorUtil.getValueAsString(bean, field.getProperty() )

  return bValid;



relevant portion of validator-rules.xml

       <validator name="time"

           function validateTime(form){

             // process to validate client side (left out to shorten email 
but it works)
                      return bValid;
           } ]]>

relevant portion of validation.xml

  <form name="onCallLogForm">
       <field property="call_date" depends="required,date">
           <arg0 key="label.call_date"/>
       <field property="call_time" depends="required,time">
             <arg0 key="label.call_time"/>

Express yourself instantly with MSN Messenger! Download today - it's FREE! 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message