public boolean configureTrinidadComponent(FacesContext facesContext, UIComponent uiComponent,
Map<String, Object> metaData)
{
boolean informationAdded = false;
//TODO
LengthValidator lengthValidator = (LengthValidator)facesContext.getApplication()
.createValidator("org.apache.myfaces.trinidad.Length");
Object minLength = null;
if(metaData.containsKey(CommonMetaDataKeys.MIN_LENGTH))
{
minLength = metaData.get(CommonMetaDataKeys.MIN_LENGTH);
}
else if(metaData.containsKey(CommonMetaDataKeys.MIN_LENGTH_DEFAULT))
{
minLength = metaData.get(CommonMetaDataKeys.MIN_LENGTH_DEFAULT);
}
if(minLength instanceof Integer)
{
lengthValidator.setMinimum((Integer)minLength);
informationAdded = true;
}
Object maxLength = null;
if(metaData.containsKey(CommonMetaDataKeys.MAX_LENGTH))
{
maxLength = metaData.get(CommonMetaDataKeys.MAX_LENGTH);
}
else if(metaData.containsKey(CommonMetaDataKeys.MAX_LENGTH_DEFAULT))
{
maxLength = metaData.get(CommonMetaDataKeys.MAX_LENGTH_DEFAULT);
}
if(maxLength instanceof Integer)
{
if(processComponent(uiComponent))
{
ReflectionUtils.tryToInvokeMethod(
uiComponent,
ReflectionUtils.tryToGetMethod(
uiComponent.getClass(),
"setMaximumLength",
int.class),
maxLength);
}
lengthValidator.setMaximum((Integer)maxLength);
informationAdded = true;
}
//reInitValidators((EditableValueHolder)uiComponent, metaData); //search wrappers and call .deactivate
if(informationAdded && lengthValidator instanceof ClientValidator)
{
if(uiComponent instanceof EditableValueHolder)
{
((EditableValueHolder)uiComponent).addValidator(
new ExtValTrinidadClientValidatorWrapper((ClientValidator)lengthValidator));
}
else if (uiComponent instanceof CoreOutputLabel)
{
if(lengthValidator.getMinimum() > 0)
{
((CoreOutputLabel)uiComponent).setShowRequired(true);
}
if(Boolean.TRUE.equals(metaData.get(CommonMetaDataKeys.SKIP_VALIDATION)))