Menu

Credit card Stereotype and validation class

2007-11-21
2012-11-26
  • Janesh Kodikara

    Janesh Kodikara - 2007-11-21

    Hi Javi
    I am thinking of creating Credit Card stereotype and a validation class for Open Xava.
    Please let me know if this is a good idea since my project has no use of this currently.

    Thanking You
    Janesh

     
    • Javier Paniza

      Javier Paniza - 2007-11-21

      Hi Janesh,

      > ... Credit Card stereotype and a validation ...
      > ... is a good idea ...
      Of course, it's a good idea

      > since my project has no use of this currently
      Many features I developed for OpenXava have been developed "on demand",
      that is, a customer demands a feature to a developer of my company,
      then the developer demands the feature to me.
      In this way, our customers finances OpenXava growing.

      In the other hand, I also add some features to OpenXava that I think
      interesting; as JPA support, Java 5 annotations, AspectJ, etc.

      You can choose you way. All useful and interesting things you develop
      for OpenXava will be included.

      Cheers
      Javi

       
    • Janesh Kodikara

      Janesh Kodikara - 2007-11-27

      Hi Javi
      Please find the details for the stereotype below.

      Following was done 
      1) Added to default-size.xml 
      <for-stereotype name="CREDITCARD" size="19"/> 

      2) Added to editors.xml 
      <editor url="textEditor.jsp"> 
      <for-stereotype stereotype="CREDITCARD"/> 
      </editor> 

      3) Added to Stereotype-type-default.xml 
      <for stereotype="CREDITCARD" type="String"/> 

      4) Added to messages_en.properties file 

      creditcard_validation_error={0} must be a valid Credit card number 

      5) Validation class 

      package org.openxava.validators;

      import org.openxava.validators.IPropertyValidator;
      import org.openxava.util.Messages;
      import org.apache.commons.validator.GenericValidator;

      /**
      * @author Janesh Kodikara
      */

      public class CreditCardValidator implements IPropertyValidator {

          public void validate(Messages errors, Object value, String propertyName, String modelName) throws Exception {

              if (value == null || value.toString().length() == 0) return;

              if (! GenericValidator.isCreditCard(value.toString())) {
                  errors.add("creditcard_validation_error", propertyName);
              }

          }

      }

      Appreciate your comments to improve this.

      Thanking You
      Janesh

       
      • Javier Paniza

        Javier Paniza - 2007-11-27

        Hi Janesh,

        it's good.

        I'll add it to OX2.2.4.
        Also I will add your ISBN and IP stereotypes.

        Cheers
        Javi

         
      • Javier Paniza

        Javier Paniza - 2007-12-19

        Hi Janesh,

        the code for IP stereotype is already in CVS,
        therefore it will be available in OX2.2.4 and OX3.0beta5.

        I ignored the part of editor.xml, because if you declare
        String as type for you stereotype it will use textEditor by default.

        Also I rename the stereotype to CREDIT_CARD (instead of CREDITCARD) because of
        coherence with the rest of stereotypes.

        Cheers
        Javi

         
    • Janesh Kodikara

      Janesh Kodikara - 2007-12-03

      Hi Javi
      Thank a lot. I was busy with family last week.
      New baby girl was added to our family :-)
      Thanking You
      Janesh

       
      • Trifon (An ADempiere founder)

        >Thank a lot. I was busy with family last week.
        >New baby girl was added to our family :-)

        Congratulations, Janesh!!!

        Wish you all the best to your new family member and all your family.
        Welcome to Father's club!

        I have baby girl 4 month old.

        Kind regards,
        Trifon

         
      • Javier Paniza

        Javier Paniza - 2007-12-03

        Hi Janesh,

        > New baby girl was added to our family :-)

        Congratulations!
        Enjoy your baby!

        Cheers
        Javi

         

Log in to post a comment.