}
}
private void validateQueryParams(final FacesContext context, final UrlMapping mapping)
{
QueryParameter currentParameter = new QueryParameter();
String currentValidatorId = "";
try
{
List<QueryParameter> params = mapping.getQueryParams();
for (QueryParameter param : params)
{
if (param.hasValidators() || (param.getValidatorExpression() != null))
{
currentParameter = param;
String name = param.getName();
String el = param.getExpression().getELExpression();
if (elUtils.getExpectedType(context, el).isArray())
{
String[] values = context.getExternalContext().getRequestParameterValuesMap().get(name);
if (values != null)
{
Object coerced = elUtils.coerceToType(context, el, values);
for (String id : param.getValidatorIdList())
{
currentValidatorId = id;
Validator validator = context.getApplication().createValidator(id);
validator.validate(context, new NullComponent(), coerced);
}
if (param.getValidatorExpression() != null)
{
elUtils.invokeMethod(context, param.getValidatorExpression().getELExpression(),
new Class<?>[] { FacesContext.class, UIComponent.class, Object.class },
new Object[] { context, new NullComponent(), coerced });
}
}
}
else
{
String value = context.getExternalContext().getRequestParameterMap().get(name);
if (value != null)
{
Object coerced = elUtils.coerceToType(context, el, value);
for (String id : param.getValidatorIdList())
{
currentValidatorId = id;
Validator validator = context.getApplication().createValidator(id);
validator.validate(context, new NullComponent(), coerced);
}
if (param.getValidatorExpression() != null)
{
elUtils.invokeMethod(context, param.getValidatorExpression().getELExpression(),
new Class<?>[] { FacesContext.class, UIComponent.class, Object.class },
new Object[] { context, new NullComponent(), coerced });
}
}
}
}
}
}
catch (ELException e)
{
FacesMessage message = new FacesMessage("Could not coerce value [" + currentParameter.getValue()
+ "] on mappingId [" + mapping.getId() + "] to type ["
+ elUtils.getExpectedType(context, currentParameter.getExpression().getELExpression()) + "]");
handleValidationFailure(context, message, currentParameter.getOnError());
}
catch (ValidatorException e)
{
handleValidationFailure(context, e.getFacesMessage(), currentParameter.getOnError());
}
catch (FacesException e)
{
FacesMessage message = new FacesMessage("Error occurred invoking validator with id [" + currentValidatorId
+ "] on mappingId [" + mapping.getId() + "] parameter [" + currentParameter.getName() + "]");
handleValidationFailure(context, message, currentParameter.getOnError());
}
}