myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabian Frederick (JIRA)" <myfaces-...@incubator.apache.org>
Subject [jira] Updated: (MYFACES-372) url validator tag / tomahawk based on emailvalidator
Date Fri, 05 Aug 2005 12:58:35 GMT
     [ http://issues.apache.org/jira/browse/MYFACES-372?page=all ]

Fabian Frederick updated MYFACES-372:
-------------------------------------

    Attachment: myfacesff2_examples.txt

This adds url to validateForm + validateUrl (taken from validate sample) to sandbox for validateurl
tag check.
I've got a problem with this one : I'm using s:validateurl (as it's been added to sandbox
tld).with novalue it works ok, but when I write something, nothing is returned :( (ie TRANSLATE
(org.apache.myfaces.Url.INVALID) ...
btw, I patched my messages.properties and I can find this in myfaces-impl.jar for relevant
project :
org.apache.myfaces.Url.INVALID = Validation Error
org.apache.myfaces.Url.INVALID_detail =The given value ({0}) is not a correct url

What did I forget ? Where to place additional messages.properties through sandbox ?

Thanks,
Fab

> url validator tag / tomahawk based on emailvalidator
> ----------------------------------------------------
>
>          Key: MYFACES-372
>          URL: http://issues.apache.org/jira/browse/MYFACES-372
>      Project: MyFaces
>         Type: New Feature
>   Components: Sandbox
>     Versions: Nightly Build
>  Environment: windows
>     Reporter: Fabian Frederick
>     Priority: Trivial
>  Attachments: myfacesff2.diff, myfacesff2_examples.txt, myfacesff2_forrest.txt
>
> Index: tomahawk/tld/myfaces_ext.tld
> ===================================================================
> --- tomahawk/tld/myfaces_ext.tld	(revision 225811)
> +++ tomahawk/tld/myfaces_ext.tld	(working copy)
> @@ -2381,6 +2381,15 @@
>  			A custom validator for email address format, based upons Jakarta Commons.
>          </description>
>  	</tag>
> +    <!-- Validator for Url -->
> +     <tag>
> +        <name>validateUrl</name>
> +        <tag-class>org.apache.myfaces.custom.emailvalidator.ValidateUrlTag</tag-class>
> +        <body-content>JSP</body-content>
> +        <description>
> +			A custom validator for url format, based upons Jakarta Commons.
> +        </description>
> +	</tag>
>      <!-- Validator for ISBN -->
>       <!--tag>
> Index: tomahawk/conf/faces-config.xml
> ===================================================================
> --- tomahawk/conf/faces-config.xml	(revision 225811)
> +++ tomahawk/conf/faces-config.xml	(working copy)
> @@ -720,6 +720,11 @@
>  	</validator>
>  	<validator>
> +		<validator-id>org.apache.myfaces.validator.Url</validator-id>
> +		<validator-class>org.apache.myfaces.custom.urlvalidator.UrlValidator</validator-class>
> +	</validator>
> +
> +	<validator>
>  		<validator-id>org.apache.myfaces.validator.Equal</validator-id>
>  		<validator-class>org.apache.myfaces.custom.equalvalidator.EqualValidator</validator-class>
>  	</validator>
> Index: tomahawk/src/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java
> ===================================================================
> --- tomahawk/src/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java	(revision
0)
> +++ tomahawk/src/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java	(revision
0)
> @@ -0,0 +1,54 @@
> +package org.apache.myfaces.custom.urlvalidator;
> +
> +import org.apache.myfaces.util.MessageUtils;
> +
> +import org.apache.commons.validator.GenericValidator;
> +
> +import javax.faces.application.FacesMessage;
> +import javax.faces.component.UIComponent;
> +import javax.faces.context.FacesContext;
> +import javax.faces.validator.Validator;
> +import javax.faces.validator.ValidatorException;
> +
> +public class UrlValidator implements Validator {
> +
> +	/**
> +	 * <p>The standard converter id for this converter.</p>
> +	 */
> +	public static final String 	VALIDATOR_ID 	   = "org.apache.myfaces.validator.Url";
> +	/**
> +	 * <p>The message identifier of the {@link FacesMessage} to be created if
> +	 * the maximum length check fails.</p>
> +	 */
> +	public static final String URL_MESSAGE_ID = "org.apache.myfaces.Url.INVALID";
> +
> +	public UrlValidator(){
> +	}
> +
> +	/**
> +	 * method that validates an url address.
> +	 * it uses the commons-validator
> +	 */
> +	public void validate(
> +		FacesContext facesContext,
> +		UIComponent uiComponent,
> +		Object value)
> +		throws ValidatorException {
> +
> +
> +			if (facesContext == null) throw new NullPointerException("facesContext");
> +			if (uiComponent == null) throw new NullPointerException("uiComponent");
> +
> +			if (value == null)
> +			{
> +				return;
> +			}
> +			if (!GenericValidator.isUrl(value.toString())) {
> +				Object[] args = {value.toString()};
> +				throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,URL_MESSAGE_ID,
args));
> +
> +			}
> +
> +	}
> +
> +}
> Index: tomahawk/src/java/org/apache/myfaces/custom/urlvalidator/ValidateUrlTag.java
> ===================================================================
> --- tomahawk/src/java/org/apache/myfaces/custom/urlvalidator/ValidateUrlTag.java	(revision
0)
> +++ tomahawk/src/java/org/apache/myfaces/custom/urlvalidator/ValidateUrlTag.java	(revision
0)
> @@ -0,0 +1,27 @@
> +package org.apache.myfaces.custom.urlvalidator;
> +
> +import javax.faces.validator.Validator;
> +import javax.faces.webapp.ValidatorTag;
> +import javax.servlet.jsp.JspException;
> +
> +public class ValidateUrlTag extends ValidatorTag
> +{
> +  private static final long serialVersionUID = 6041422002721046221L;
> +
> +  public ValidateUrlTag()
> +    {
> +	}
> +
> +	protected Validator createValidator() throws JspException
> +    {
> +		setValidatorId(UrlValidator.VALIDATOR_ID);
> +	    UrlValidator validator = (UrlValidator)super.createValidator();
> +		return validator;
> +	}
> +
> +    public void release()
> +    {
> +        super.release();
> +    }
> +
> +}</textarea>
>                     </td>
>     </tr>
>     
>                     
>                 
>             
>                 
>                 
>                     
>                     
>                         
>                     
>                 
>             
>         
>         
>             
>     <tr><td colspan=2 bgcolor=ffffff>&nbsp;
>     <style>
>     <!--
>     .fieldLabelArea
>     {
>         width: 30%;
>     }
>     -->
>     </style>
>     </td></tr>
>     <tr><td colspan=2 bgcolor=f0f0f0>
>         <b>Comment</b>: (an optional comment describing this update)
>     </td></tr>
>     
> 	
> 	<tr 
>         
>         
>     >
> 		
> 		
> 			
> 			
> 				<td class="fieldLabelArea">
> 			
> 		
>         
>         
>  		
> 		Update comment:
>         
>         
> 		</td>
> 	
> 	
> 	<td bgcolor="ffffff" nowrap class="fieldValueArea">
> <textarea name="comment"
>           cols="70"
>           rows="4"
>           wrap="virtual"
>             
>             
>             style="width:90%"
>          
>          
>             
>          
>          
>             accesskey="m"
>          
>          
>             
>          
>          
>             
>          
>          
>             
>          
>          
>             
>          
>          
>             
>          
>          
>             
>          
> >

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message