Package javax.faces.convert

Examples of javax.faces.convert.DateTimeConverter


    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 = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
        String id = component.getClientId(facesContext);
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(CONVERTER_ID);
      dateTimeConverter.setPattern("HH:mm");
      dateTimeConverter.setTimeZone(TimeZone.getDefault());
      setConverter(dateTimeConverter);
    }
    return converter;
  }
View Full Code Here

  }

  public Date getConvertedValue(FacesContext context, String currentDateString)
      throws ConverterException {

    DateTimeConverter datetime = new DateTimeConverter();
    datetime.setPattern("m/y");
    Date newCurrentDate = (Date) datetime.getAsObject(context, this,
        currentDateString);
    return newCurrentDate;
  }
View Full Code Here

    try {
      ValueExpression ve = getValueExpression("currentDate");
      if (ve != null) {
            ELContext elContext = context.getELContext();
            if (ve.getType(elContext).equals(String.class)) {
          DateTimeConverter convert = new DateTimeConverter();
          convert.setLocale(getAsLocale(getLocale()));
          convert.setPattern(getDatePattern());
          ve.setValue(context.getELContext(), convert.getAsString(context, this,
              currentDate));
          return;
        } else if (ve.getType(elContext).equals(Calendar.class)) {
          Calendar c = Calendar.getInstance();
          c.setTime((Date) currentDate);
View Full Code Here

       
          if (date instanceof Date) {
        return (Date) date;
      } else {
            if (date instanceof String) {
          DateTimeConverter converter = new DateTimeConverter();
          converter.setPattern(this.getDatePattern());
          converter.setLocale(getAsLocale(this.getLocale()));
          converter.setTimeZone(this.getTimeZone());
          FacesContext context = FacesContext.getCurrentInstance();
          return (Date) converter.getAsObject(context, this,
              (String) date);
        } else {
          if (date instanceof Calendar) {
            return ((Calendar) date).getTime();
          } else {
               
                FacesContext context = FacesContext.getCurrentInstance();
                Converter converter = getConverter();
               
                if(converter != null) {
                    return getAsDate(converter.getAsString(context, this, date));
                }
               
            Application application = context.getApplication();
            converter = application.createConverter(date.getClass());
            if (null != converter) {
              return getAsDate(converter.getAsString(context,  this, date));
            } else {
              throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
            }

          }
View Full Code Here

   * @param calendar - calendar component
   *
   * @return created converter
   */
  protected static Converter createDefaultConverter() {
      return new DateTimeConverter();
  }
View Full Code Here

      if(converter == null) {
    return null;
      }
     
      if(converter instanceof DateTimeConverter) {
    DateTimeConverter defaultConverter = (DateTimeConverter) converter;
    defaultConverter.setPattern(calendar.getDatePattern());
    defaultConverter.setLocale(calendar.getAsLocale(calendar.getLocale()));
    defaultConverter.setTimeZone(calendar.getTimeZone());
      }
     
      return converter;
  }
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

    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 = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
        String id = component.getClientId(facesContext);
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

TOP

Related Classes of javax.faces.convert.DateTimeConverter

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.