public void apply(final FaceletContext faceletContext, final UIComponent parent)
throws IOException, ELException {
if (parent instanceof ValueHolder) {
if (ComponentHandler.isNew(parent)) {
final ValueHolder valueHolder = (ValueHolder) parent;
Converter converter = null;
ValueExpression valueExpression = null;
if (binding != null) {
valueExpression = binding.getValueExpression(faceletContext, Converter.class);
converter = (Converter) valueExpression.getValue(faceletContext);
}
if (converter == null) {
try {
converter = FacesContext.getCurrentInstance().getApplication().createConverter(
(String) converterId.getValueExpression(faceletContext, String.class).getValue(faceletContext));
} catch (final Exception e) {
throw new TagAttributeException(tag, converterId, e.getCause());
}
if (valueExpression != null) {
valueExpression.setValue(faceletContext, converter);
}
}
if (converter != null) {
valueHolder.setConverter(converter);
}
// TODO else LOG.warn?
}
} else {
throw new TagException(tag, "Parent is not of type ValueHolder, type is: " + parent);