Package javax.faces.convert

Examples of javax.faces.convert.DateTimeConverter$Type


        assertEquals(facesMessage.getSummary(), summary);
    }

    @Test
    public void getConverterParameters() throws Exception {
        DateTimeConverter converter = new DateTimeConverter();

        converter.setDateStyle("short");
        converter.setPattern("MM/DD/YYYY");
        converter.setTimeStyle("full");
        converter.setType("both");
        converter.setTimeZone(TimeZone.getTimeZone("EST"));
        controller.replay();
        ConverterDescriptor converterDescription = serviceImpl.getConverterDescription(environment.getFacesContext(), input,
            converter, null);
        Map<String, ? extends Object> additionalParameters = converterDescription.getAdditionalParameters();
        assertEquals("short", additionalParameters.get("dateStyle"));
View Full Code Here


    }

    @Override
    protected Converter createConverter() throws JspException
    {
        DateTimeConverter converter = (DateTimeConverter)super.createConverter();

        ELContext elContext = FacesContext.getCurrentInstance().getELContext();
        setConverterDateStyle(elContext, converter, _dateStyle);
        setConverterLocale(elContext, converter, _locale);
        setConverterPattern(elContext, converter, _pattern);
View Full Code Here

    // for convenience, we will set the time zone of the converter to that
    // specified by the context or, if that is not present, to the time zone
    // of the server
    if (converter instanceof DateTimeConverter)
    {
      DateTimeConverter dtc = (DateTimeConverter) converter;
     
      boolean trinidadDTC = _isTrinidadDateTimeConverter(converter);
     
      if (!trinidadDTC)
      {
        // if it is not the Trinidad DateTimeConverter, set the date style to
        // short
        dtc.setDateStyle("short");
      }
     
      // if it is not the Trinidad DateTimeConverter or (it is AND
      // no time zone is set) then we want to set the
      // time zone to the one in the faces context or use
      // the default server time zone on the converter
      if (!trinidadDTC || dtc.getTimeZone() == null)
      {
        TimeZone tz = null;
       
        RequestContext requestContext = RequestContext.getCurrentInstance();
        tz = requestContext.getTimeZone();
        if(tz == null)
        {
          tz = TimeZone.getDefault();
        }
       
        dtc.setTimeZone(tz);
      }
    }
   
    return converter;
  }
View Full Code Here

        setConverterId(DateTimeConverter.CONVERTER_ID);
    }

    protected Converter createConverter() throws JspException
    {
        DateTimeConverter converter = (DateTimeConverter)super.createConverter();

        FacesContext facesContext = FacesContext.getCurrentInstance();
        setConverterDateStyle(facesContext, converter, _dateStyle);
        setConverterLocale(facesContext, converter, _locale);
        setConverterPattern(facesContext, converter, _pattern);
View Full Code Here

    // for convenience, we will set the time zone of the converter to that
    // specified by the context or, if that is not present, to the time zone
    // of the server
    if (converter instanceof DateTimeConverter)
    {
      DateTimeConverter dtc = (DateTimeConverter) converter;

      boolean trinidadDTC = _isTrinidadDateTimeConverter(converter);

      if (!trinidadDTC)
      {
        // if it is not the Trinidad DateTimeConverter, set the date style to
        // short
        dtc.setDateStyle("short");
      }

      // if it is not the Trinidad DateTimeConverter or (it is AND
      // no time zone is set) then we want to set the
      // time zone to the one in the faces context or use
      // the default server time zone on the converter
      if (!trinidadDTC || dtc.getTimeZone() == null)
      {
        TimeZone tz = null;

        RequestContext requestContext = RequestContext.getCurrentInstance();
        tz = requestContext.getTimeZone();
        if(tz == null)
        {
          tz = TimeZone.getDefault();
        }

        dtc.setTimeZone(tz);
      }
    }

    return converter;
  }
View Full Code Here

    // for convenience, we will set the time zone of the converter to that
    // specified by the context or, if that is not present, to the time zone
    // of the server
    if (converter instanceof DateTimeConverter)
    {
      DateTimeConverter dtc = (DateTimeConverter) converter;
     
      boolean trinidadDTC = _isTrinidadDateTimeConverter(converter);
     
      if (!trinidadDTC)
      {
        // if it is not the Trinidad DateTimeConverter, set the date style to
        // short
        dtc.setDateStyle("short");
      }
     
      // if it is not the Trinidad DateTimeConverter or (it is AND
      // no time zone is set) then we want to set the
      // time zone to the one in the faces context or use
      // the default server time zone on the converter
      if (!trinidadDTC || dtc.getTimeZone() == null)
      {
        TimeZone tz = null;
       
        RequestContext requestContext = RequestContext.getCurrentInstance();
        tz = requestContext.getTimeZone();
        if(tz == null)
        {
          tz = TimeZone.getDefault();
        }
       
        dtc.setTimeZone(tz);
      }
    }
   
    return converter;
  }
View Full Code Here

    super.encodeEnd(facesContext, component);

    Converter help = getConverter(facesContext, component);
    // TODO is this really needed?
    if (help instanceof DateTimeConverter) {
      DateTimeConverter converter = (DateTimeConverter) help;
      String pattern = DateFormatUtils.findPattern(converter);

      if (pattern != null) {
        TobagoResponseWriter writer = (TobagoResponseWriter)
            facesContext.getResponseWriter();
View Full Code Here

    Converter converter = super.getConverter();
    if (converter == null) {
      // setting required default converter
      Application application
          = FacesContext.getCurrentInstance().getApplication();
      DateTimeConverter dateTimeConverter
          = (DateTimeConverter) application.createConverter(DateTimeConverter.CONVERTER_ID);
      dateTimeConverter.setPattern("HH:mm");
      dateTimeConverter.setTimeZone(TimeZone.getDefault());
      setConverter(dateTimeConverter);
    }
    return converter;
  }
View Full Code Here

    }

    @Override
    protected Converter createConverter() throws JspException
    {
        DateTimeConverter converter = (DateTimeConverter)super.createConverter();

        ELContext elContext = FacesContext.getCurrentInstance().getELContext();
        setConverterDateStyle(elContext, converter, _dateStyle);
        setConverterLocale(elContext, converter, _locale);
        setConverterPattern(elContext, converter, _pattern);
View Full Code Here

  private void applyConverterPattern(FacesContext facesContext, UIPopup popup, String converterPattern) {
    UIComponent box = (UIComponent) popup.getChildren().get(0);
    UIComponent timePanel = box.findComponent("timePanel");
    if (converterPattern != null && (converterPattern.indexOf('h') > -1 || converterPattern.indexOf('H') > -1)) {
      UITime time = (UITime) timePanel.findComponent("time");
      DateTimeConverter dateTimeConverter
          = (DateTimeConverter) facesContext.getApplication().createConverter(DateTimeConverter.CONVERTER_ID);
      if (converterPattern.indexOf('s') > -1) {
        dateTimeConverter.setPattern("HH:mm:ss");
      } else {
        dateTimeConverter.setPattern("HH:mm");
      }
      dateTimeConverter.setTimeZone(TimeZone.getDefault());
      time.setConverter(dateTimeConverter);
    } else {
      timePanel.setRendered(false);
    }
  }
View Full Code Here

TOP

Related Classes of javax.faces.convert.DateTimeConverter$Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.