private NumberConverter getNumberConverter( Converter existingConverter ) { if ( existingConverter != null ) { if ( !( existingConverter instanceof NumberConverter ) ) { throw WidgetProcessorException.newException( "Unable to set number attributes on a " + existingConverter.getClass() ); } return (NumberConverter) existingConverter; } // In case the application defines its own one FacesContext context = FacesContext.getCurrentInstance(); NumberConverter numberConverter = (NumberConverter) context.getApplication().createConverter( Number.class ); if ( numberConverter != null ) { return numberConverter; } // The JSF default return new NumberConverter(); } }
private NumberConverter getNumberConverter( Converter existingConverter ) { if ( existingConverter != null ) { if ( !( existingConverter instanceof NumberConverter ) ) { throw WidgetProcessorException.newException( "Unable to set number attributes on a " + existingConverter.getClass() ); } return (NumberConverter) existingConverter; } // In case the application defines its own one FacesContext context = FacesContext.getCurrentInstance(); NumberConverter numberConverter = (NumberConverter) context.getApplication().createConverter( Number.class ); if ( numberConverter != null ) { return numberConverter; } // The JSF default return new NumberConverter(); } }
/** * Sets a value to the input. * * @param input * The input to set the value to. May not be null. * @param property * The property. May not be null. * @param context * The jsf context. May not be null. */ protected final void addValue(final UIInput input, final PropertyDescriptor<?, ?> property, final RenderContext context) { Validate.notNull(input, "Input may not be null."); Validate.notNull(property, AbstractRenderStrategy.PROPERTY_NULL); Validate.notNull(context, AbstractRenderStrategy.CONTEXT_NULL); input.setValueExpression( "value", this.expressionFactory.createValueExpression(context.getFacesContext().getELContext(), VariableUtil.compileVariable(context.getVariable(), context.getPrefixDeque()), Object.class)); final PresentationPropertyDescriptor<?, ?> presentationProperty = property.adapt(PresentationPropertyDescriptor.class); if (TypeUtil.isNumberType(property.getPropertyType()) && !CheckUtil.isNull(presentationProperty)) { final NumberConverter converter = new NumberConverter(); converter.setPattern(presentationProperty.getFormat()); input.setConverter(converter); } }
final PresentationPropertyDescriptor<?, ?> presentationProperty = property.adapt(PresentationPropertyDescriptor.class); if (TypeUtil.isNumberType(property.getPropertyType()) && !CheckUtil.isNull(presentationProperty)) { final NumberConverter converter = new NumberConverter(); converter.setPattern(presentationProperty.getFormat()); output.setConverter(converter);