Пример #1
0
  protected Converter createConverter() throws JspException {
    FacesContext context = FacesContext.getCurrentInstance();
    ELContext elctx = context.getELContext();

    if (binding != null) {
      Converter boundConverter = (NumberConverter) binding.getValue(elctx);
      if (boundConverter != null) return boundConverter;
    }

    NumberConverter converter = new NumberConverter();

    if (currencyCode != null) converter.setCurrencyCode((String) currencyCode.getValue(elctx));
    if (currencySymbol != null)
      converter.setCurrencySymbol((String) currencySymbol.getValue(elctx));
    if (groupingUsed != null) converter.setGroupingUsed((Boolean) groupingUsed.getValue(elctx));
    if (integerOnly != null) converter.setIntegerOnly((Boolean) integerOnly.getValue(elctx));
    if (maxFractionDigits != null)
      converter.setMaxFractionDigits((Integer) maxFractionDigits.getValue(elctx));
    if (minFractionDigits != null)
      converter.setMinFractionDigits((Integer) minFractionDigits.getValue(elctx));
    if (minIntegerDigits != null)
      converter.setMinIntegerDigits((Integer) minIntegerDigits.getValue(elctx));
    if (pattern != null) converter.setPattern((String) pattern.getValue(elctx));
    if (type != null) converter.setType((String) type.getValue(elctx));

    Locale loc = null;
    if (locale != null) loc = FacesUtils.getLocaleFromExpression(context, locale);
    if (loc == null) loc = context.getViewRoot().getLocale();
    converter.setLocale(loc);

    if (binding != null) binding.setValue(elctx, converter);
    return converter;
  }
 // Create and configure a NumberConverter
 protected NumberConverter createNumberConverter() {
   NumberConverter nc = new NumberConverter();
   nc.setCurrencyCode("USD");
   nc.setCurrencySymbol("$");
   nc.setGroupingUsed(false);
   nc.setIntegerOnly(true);
   nc.setMaxFractionDigits(2);
   nc.setMaxIntegerDigits(10);
   nc.setMinFractionDigits(2);
   nc.setMinIntegerDigits(5);
   nc.setType("currency");
   return (nc);
 }