1 Reply Latest reply on Jun 17, 2009 1:47 PM by Zolotoj

    Convert ClassFactory to an object

    Zolotoj Level 3

      I am trying to come up with cell validation for emails entries:

      Here is my my column definition:

       

      <mx:DataGridColumn
      
       headerText="Email" labelFunction="formatEmail"dataField="
      
      email"/>
      

       

      private
      
      
      if (validations(column.itemEditor, "email"))
      
      return item.email;
      
      else
      return ""; }
      
      
      
       function formatEmail(item:Object, column:DataGridColumn):String{
      
      

       

      public
      
      
      var vResult:ValidationResultEvent; 
      
      var cValidator:Validator;
      
      switch(validationType){ 
      
      
      case "currency" :cValidator = 
      
      new CurrencyValidator;cValidator.source = objToValidate;
      cValidator.property = 
      
      "text";CurrencyValidator(cValidator).precision = 
      
      "2"; 
      
      break;
      
      default :
      
      break;
      
      case "string" :cValidator = 
      
      new StringValidator;cValidator.source = objToValidate;
      cValidator.property = 
      
      "text"; 
      
      break;
      
      case "number" :cValidator = 
      
      new NumberValidator;cValidator.source = objToValidate;
      cValidator.property = 
      
      "text"; 
      
      break; 
      
      case "email" :cValidator = 
      
      new EmailValidator;cValidator.source = objToValidate;
      cValidator.property = 
      
      "text"; 
      
      break; } 
      vResult = cValidator.validate();
      
      
      if (vResult.type == ValidationResultEvent.VALID) 
      
      return true;
      
      else
      return false; }
      
      
      
       function validations(objToValidate:Object, validationType:String):Boolean{ 
      
      

      It does not work because I need to send to validations function an object but instead I am sending a ClassFactory. Any way to get this code working?

       

      Thanks