Converter converter = valueHolder.getConverter(); if (converter == null) { Class valueType = value.getClass();
/** * Finds appropriate converter for a given value holder * * @param context FacesContext instance * @param component ValueHolder instance to look converter for * @return Converter */ public static Converter getConverter(FacesContext context, UIComponent component) { if (!(component instanceof ValueHolder)) { return null; } Converter converter = ((ValueHolder) component).getConverter(); if (converter != null) { return converter; } ValueExpression valueExpression = component.getValueExpression("value"); if (valueExpression == null) { return null; } Class<?> converterType = valueExpression.getType(context.getELContext()); if (converterType == null || converterType == Object.class) { // no conversion is needed return null; } if (converterType == String.class && !PrimeApplicationContext.getCurrentInstance(context).getConfig().isStringConverterAvailable()) { return null; } return context.getApplication().createConverter(converterType); }
Converter converter = valueHolder.getConverter(); if (converter == null) { Class valueType = value.getClass();
public Converter getConverterByValue(FacesContext context, UIComponent component, Object value) { Converter result = null; if (component instanceof ValueHolder) { result = ((ValueHolder) component).getConverter(); } if (result == null && value != null) { result = getConverterForType(context, value.getClass()); } return result; }
public Converter getConverterByValue(FacesContext context, UIComponent component, Object value) { Converter result = null; if (component instanceof ValueHolder) { result = ((ValueHolder) component).getConverter(); } if (result == null && value != null) { result = getConverterForType(context, value.getClass()); } return result; }
public Converter getConverterByValue(FacesContext context, UIComponent component, Object value) { Converter result = null; if (component instanceof ValueHolder) { result = ((ValueHolder) component).getConverter(); } if (result == null && value != null) { result = getConverterForType(context, value.getClass()); } return result; }
public String getDatePattern() { Assert.isTrue(getChildren().get(0) instanceof ValueHolder, "Date validation can only be applied to an ValueHolder"); ValueHolder child = (ValueHolder) getChildren().get(0); if (child.getConverter() instanceof DateTimeConverter) { return ((DateTimeConverter) child.getConverter()).getPattern(); } return datePattern; }
private Converter getConverter(FacesContext context, UIComponent component) { Converter converter = null; if (component instanceof ValueHolder) { converter = ((ValueHolder) component).getConverter(); } if (converter == null) { // Use the DateTimeConverter's CONVERTER_ID, not Date.class, // because there is in fact not usually a converter registered // at Date.class converter = context.getApplication().createConverter( DateTimeConverter.CONVERTER_ID); } assert (converter != null); return converter; }
private Converter getConverter(FacesContext context, UIComponent component) { Converter converter = null; if (component instanceof ValueHolder) { converter = ((ValueHolder) component).getConverter(); } if (converter == null) { // Use the DateTimeConverter's CONVERTER_ID, not Date.class, // because there is in fact not usually a converter registered // at Date.class converter = context.getApplication().createConverter( DateTimeConverter.CONVERTER_ID); } assert (converter != null); return converter; }
private void detatch(UIComponent parent) { if (parent != null) { parent.getChildren().remove(this.exposedUISelectItems); if (parent instanceof ValueHolder) { ValueHolder valueHolder = (ValueHolder) parent; if (valueHolder.getConverter() == this.converter) { valueHolder.setConverter(null); } } } }
private void attatch(UIComponent parent) { if (parent != null) { parent.getChildren().add(this.exposedUISelectItems); if (parent instanceof ValueHolder) { ValueHolder valueHolder = (ValueHolder) parent; if (valueHolder.getConverter() == null) { valueHolder.setConverter(this.converter); } } } }
public static Converter findConverter(FacesContext facesContext, UIComponent component, String property) { Converter converter = null; if (component instanceof ValueHolder) { converter = ((ValueHolder) component).getConverter(); } if (converter == null) { ValueExpression ve = component.getValueExpression(property); if (ve != null) { Class<?> valueType = ve.getType(facesContext.getELContext()); if (valueType == null || Object.class.equals(valueType)) { // No converter needed } else { converter = facesContext.getApplication().createConverter(valueType); } } } return converter; }
private void inject(UIComponent uiComponent, boolean advancedQualifierRequiredForDependencyInjection) { if(uiComponent instanceof ValueHolder) { injectFields(((ValueHolder)uiComponent).getConverter()); if(uiComponent instanceof EditableValueHolder) { for(Validator validator : ((EditableValueHolder)uiComponent).getValidators()) { injectFields(validator, advancedQualifierRequiredForDependencyInjection); } } } } }
public static Converter findConverter(FacesContext facesContext, UIComponent component, String property) { Converter converter = null; if (component instanceof ValueHolder) { converter = ((ValueHolder) component).getConverter(); } if (converter == null) { ValueExpression ve = component.getValueExpression(property); if (ve != null) { Class<?> valueType = ve.getType(facesContext.getELContext()); if (valueType == null || Object.class.equals(valueType)) { // No converter needed } else { converter = facesContext.getApplication().createConverter(valueType); } } } return converter; }
private void inject(UIComponent uiComponent, boolean advancedQualifierRequiredForDependencyInjection) { if(uiComponent instanceof ValueHolder) { injectFields(((ValueHolder)uiComponent).getConverter()); if(uiComponent instanceof EditableValueHolder) { for(Validator validator : ((EditableValueHolder)uiComponent).getValidators()) { injectFields(validator, advancedQualifierRequiredForDependencyInjection); } } } } }
private void inject(UIComponent uiComponent, boolean advancedQualifierRequiredForDependencyInjection) { if(uiComponent instanceof ValueHolder) { injectFields(((ValueHolder)uiComponent).getConverter()); if(uiComponent instanceof EditableValueHolder) { for(Validator validator : ((EditableValueHolder)uiComponent).getValidators()) { injectFields(validator, advancedQualifierRequiredForDependencyInjection); } } } } }
public static Converter getConverter(final UIComponent component) { Converter converter = null; final ValueBinding vb = component .getValueBinding(JsfConstants.VALUE_ATTR); if (vb != null) { String expression = vb.getExpressionString(); converter = ConverterResource.getConverter(expression); } if (converter != null) { return converter; } if (component instanceof ValueHolder) { return ((ValueHolder) component).getConverter(); } return null; }
private Converter getConverterForValue(FacesContext context, UIComponent component) { Converter converter = ((ValueHolder) component).getConverter(); if (converter == null) { ValueExpression expression = component.getValueExpression("value"); if (expression != null) { Class<?> containerClass = ServiceTracker.getService(context, GenericsIntrospectionService.class) .getContainerClass(context, expression); converter = InputUtils.getConverterForType(context, containerClass); } } return converter; }
private Converter getConverterForValue(FacesContext context, UIComponent component) { Converter converter = ((ValueHolder) component).getConverter(); if (converter == null) { ValueExpression expression = component.getValueExpression("value"); if (expression != null) { Class<?> containerClass = ServiceTracker.getService(context, GenericsIntrospectionService.class) .getContainerClass(context, expression); converter = InputUtils.getConverterForType(context, containerClass); } } return converter; }
private Converter getConverterForValue(FacesContext context, UIComponent component) { Converter converter = ((ValueHolder) component).getConverter(); if (converter == null) { ValueExpression expression = component.getValueExpression("value"); if (expression != null) { Class<?> containerClass = ServiceTracker.getService(context, GenericsIntrospectionService.class) .getContainerClass(context, expression); converter = InputUtils.getConverterForType(context, containerClass); } } return converter; }