Hi Javi I have used EMAIL_LIST stereotype and validation class in qaManager and want to share same with OpenXava.
Following was done 1) Added to default-size.xml <for-stereotype name="EMAIL_LIST" size="200"/>
2) Added to editors.xml <editor url="textEditor.jsp"> <for-stereotype stereotype="EMAIL_LIST"/> </editor>
3) Added to Stereotype-type-default.xml <for stereotype="EMAIL_LIST" type="String"/>
4) Added to messages_en.properties file
email_list_validation_error=Email list should contain valid emails seperated by commas
5) Validation class
package org.openxava.validators;
import org.openxava.validators.IPropertyValidator; import org.openxava.util.Messages;
import org.apache.commons.validator.GenericValidator; import java.util.StringTokenizer;
/** * @author Janesh Kodikara */
public class EmailListValidator implements IPropertyValidator {
public void validate(Messages errors, Object value, String propertyName, String modelName) throws Exception {
if (value == null || value.toString().length() == 0) return;
StringTokenizer emailAddresses = new StringTokenizer(value.toString(), ","); while(emailAddresses.hasMoreTokens()) { if (! GenericValidator.isEmail(emailAddresses.nextToken())) { errors.add("email_list_validation_error", propertyName); } }
}
Your comments to improve this is appreciated.
Thanking you Janesh
Hi Janesh,
I think it's good!.
I'll add it to next OX version.
Thanks Javi
the code for EMAIL_LIST 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.
Cheers Javi
Log in to post a comment.
Hi Javi
I have used EMAIL_LIST stereotype and validation class in qaManager and want to share same with OpenXava.
Following was done
1) Added to default-size.xml
<for-stereotype name="EMAIL_LIST" size="200"/>
2) Added to editors.xml
<editor url="textEditor.jsp">
<for-stereotype stereotype="EMAIL_LIST"/>
</editor>
3) Added to Stereotype-type-default.xml
<for stereotype="EMAIL_LIST" type="String"/>
4) Added to messages_en.properties file
email_list_validation_error=Email list should contain valid emails seperated by commas
5) Validation class
package org.openxava.validators;
import org.openxava.validators.IPropertyValidator;
import org.openxava.util.Messages;
import org.apache.commons.validator.GenericValidator;
import java.util.StringTokenizer;
/**
* @author Janesh Kodikara
*/
public class EmailListValidator implements IPropertyValidator {
public void validate(Messages errors, Object value, String propertyName, String modelName) throws Exception {
if (value == null || value.toString().length() == 0) return;
StringTokenizer emailAddresses = new StringTokenizer(value.toString(), ",");
while(emailAddresses.hasMoreTokens()) {
if (! GenericValidator.isEmail(emailAddresses.nextToken())) {
errors.add("email_list_validation_error", propertyName);
}
}
}
}
Your comments to improve this is appreciated.
Thanking you
Janesh
Hi Janesh,
I think it's good!.
I'll add it to next OX version.
Thanks
Javi
Hi Janesh,
the code for EMAIL_LIST 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.
Cheers
Javi