Moreover I have created a test, included in CustomerWithSectionTest:
public void testTELEPHONE_EMAIL_WEBURLstereotypes() throws Exception {
execute("Mode.detailAndFirst");
setValue("telephone", "asf");
setValue("email", "pepe");
setValue("website", "openxava");
execute("Customer.save");
assertError("Telephone must be a valid number");
assertError("eMail must be a valid email address");
assertError("Web site must be a valid url");
setValue("telephone", "123");
setValue("email", "pepe@mycompany");
setValue("website", "www.openxava.org");
execute("Customer.save");
assertError("Telephone must be at least 8 Digits long");
assertError("eMail must be a valid email address");
assertError("Web site must be a valid url");
assertValue("email", "pepe@mycompany"); // not converted to uppercase
assertValue("website", "www.openxava.org"); // not converted to uppercase
setValue("telephone", "961112233");
setValue("email", "pepe@mycompany.com");
setValue("website", "http://www.openxava.org");
execute("Customer.save");
assertNoErrors();
}
And I have updated the Reference Guide.
All this (including the oro and commons-validations jars) are now included in OpenXava.
Thanks for your contribution.
Now you are part of OpenXava team. OpenXava is also your project.
Cheers
Javi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if (value == null || value.toString().length() == 0) return;
if (! GenericValidator.isEmail(value.toString())) {
errors.add("email_validation_error", propertyName);
return;
}
}
}
This API has lot of validation methods which simplify the coding.
I am thinking of writing more validation class for OpenXava using this API.
New Stereotypes can be introduced as these validation classes are introduced.
Can you please guide me to implement this?
Thanking You
Janesh
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can copy and paste your code from this thread, but
because you are very active in contributions, maybe is
easier if you have access rights to OpenXava CVS, in this
way you will can modify directly the code.
Do you want I give you access to CVS ?
Cheers
Javi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Javi
I will love to have direct access.
But I will paste the stuff into the thread for sometime.
The qaManager reached 30 sometime back. :-)
I want to learn Hibernate and Java and contribute to OpenXava.
Any suggestions? I mean what should I learn to build competancy while contributing to the project slowly.
Cheers
Janesh
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> I will love to have direct access
Well! Now you have write access to OpenXava CVS.
> But I will paste the stuff into the thread for sometime
Well, in this case I have done the change.
From now on you can do directly the modification in
the HEAD of OpenXava CVS.
But we still need to debate here the changes to do before
modify OpenXava code. Then you can directly modify
the OpenXava code, and always I will revise the code.
> The qaManager reached 30 sometime back. :-)
Congratulations!
Cheers
Javi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Javi
I have used Email stereotype and validation class in qaManager and want to be included in OpenXava.
Following was done
1) Added to default-size.xml
<for-stereotype name="EMAIL" size="50"/>
2) Added to editors.xml
<editor url="textEditor.jsp">
<for-stereotype stereotype="EMAIL"/>
</editor>
3) Added to Stereotype-type-default.xml
<for stereotype="EMAIL" type="String"/>
4) Added to messages_en.properties file
email_validation_error={0} must be a valid email address
5) Validation class
package org.openxava.validators;
import org.openxava.util.*;
import org.openxava.validators.IPropertyValidator;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
/**
*
* @author Janesh Kodikara
*/
public class EmailValidator implements IPropertyValidator {
Pattern pat=Pattern.compile(".+@.+\\.[a-z]+");
public void validate(Messages errors, Object value, String propertyName, String modelName) throws Exception {
if (value == null || value.toString().length() ==0 ) return;
Matcher matcher = pat.matcher(value.toString());
if (! matcher.find()) {
errors.add("email_validation_error", propertyName);
return;
}
}
}
I wanted to contribute OpenXava as
Thanking You
Janesh
Hi Janes,
very good contribution.
I like it.
Kind regards,
Trifon
Hi Janesh,
your stereotypes EMAIL, TELEPHONE and WEBURL are included in OpenXava (in CVS HEAD).
They will be available for OpenXava 2.2.3
Also I have modified OpenXava/xava/validators.xml adding:
<default-validator>
<validator-class class="org.openxava.validators.EmailValidator"/>
<for-stereotype stereotype="EMAIL"/>
</default-validator>
<default-validator>
<validator-class class="org.openxava.validators.PhoneNumberValidator"/>
<for-stereotype stereotype="TELEPHONE"/>
<for-stereotype stereotype="TELEFONO"/>
</default-validator>
<default-validator>
<validator-class class="org.openxava.validators.URLValidator"/>
<for-stereotype stereotype="WEBURL"/>
</default-validator>
Moreover I have created a test, included in CustomerWithSectionTest:
public void testTELEPHONE_EMAIL_WEBURLstereotypes() throws Exception {
execute("Mode.detailAndFirst");
setValue("telephone", "asf");
setValue("email", "pepe");
setValue("website", "openxava");
execute("Customer.save");
assertError("Telephone must be a valid number");
assertError("eMail must be a valid email address");
assertError("Web site must be a valid url");
setValue("telephone", "123");
setValue("email", "pepe@mycompany");
setValue("website", "www.openxava.org");
execute("Customer.save");
assertError("Telephone must be at least 8 Digits long");
assertError("eMail must be a valid email address");
assertError("Web site must be a valid url");
assertValue("email", "pepe@mycompany"); // not converted to uppercase
assertValue("website", "www.openxava.org"); // not converted to uppercase
setValue("telephone", "961112233");
setValue("email", "pepe@mycompany.com");
setValue("website", "http://www.openxava.org");
execute("Customer.save");
assertNoErrors();
}
And I have updated the Reference Guide.
All this (including the oro and commons-validations jars) are now included in OpenXava.
Thanks for your contribution.
Now you are part of OpenXava team. OpenXava is also your project.
Cheers
Javi
Hi Javi
I am glad to be a part of OpenXava and will continue to contribute to the project.
A friend of mine is working on Japanese trnslation. Once this is done we will be able to contribute it to OpenXava.
Thanking You
Janesh
Hi Janesh,
> A friend of mine is working on Japanese trnslation. Once this is done we will be able to contribute it to OpenXava
Fantastic!
Hi Javi
Email Validation class is improved using the apache validator API.
Please find the class below.
import org.apache.commons.validator.GenericValidator;
import org.openxava.util.Messages;
import org.openxava.validators.IPropertyValidator;
/**
* @author Janesh Kodikara
*/
public class EmailValidator 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.isEmail(value.toString())) {
errors.add("email_validation_error", propertyName);
return;
}
}
}
This API has lot of validation methods which simplify the coding.
I am thinking of writing more validation class for OpenXava using this API.
New Stereotypes can be introduced as these validation classes are introduced.
Can you please guide me to implement this?
Thanking You
Janesh
Hi Janesh,
I can copy and paste your code from this thread, but
because you are very active in contributions, maybe is
easier if you have access rights to OpenXava CVS, in this
way you will can modify directly the code.
Do you want I give you access to CVS ?
Cheers
Javi
Hi Javi
I will love to have direct access.
But I will paste the stuff into the thread for sometime.
The qaManager reached 30 sometime back. :-)
I want to learn Hibernate and Java and contribute to OpenXava.
Any suggestions? I mean what should I learn to build competancy while contributing to the project slowly.
Cheers
Janesh
Hi Janesh,
> I will love to have direct access
Well! Now you have write access to OpenXava CVS.
> But I will paste the stuff into the thread for sometime
Well, in this case I have done the change.
From now on you can do directly the modification in
the HEAD of OpenXava CVS.
But we still need to debate here the changes to do before
modify OpenXava code. Then you can directly modify
the OpenXava code, and always I will revise the code.
> The qaManager reached 30 sometime back. :-)
Congratulations!
Cheers
Javi