Examples of UIDatePicker


Examples of org.apache.myfaces.tobago.component.UIDatePicker

      UIForm form = (UIForm) application.createComponent(UIForm.COMPONENT_TYPE);
      form.setRendererType(RendererTypes.FORM);
      form.setId(formIdAttribute != null ? formIdAttribute.getValue(faceletContext) : root.createUniqueId());
      panel.getChildren().add(form);

      UIDatePicker picker = (UIDatePicker) application.createComponent(UIDatePicker.COMPONENT_TYPE);
      picker.setRendererType(RendererTypes.DATE_PICKER);
      picker.setFor("@auto");
      picker.setId(pickerIdAttribute != null ? pickerIdAttribute.getValue(faceletContext) : root.createUniqueId());
      if (picker.getAttributes().get(OnComponentCreated.MARKER) == null) {
        picker.getAttributes().put(OnComponentCreated.MARKER, Boolean.TRUE);
        picker.onComponentCreated(faceletContext.getFacesContext(), panel);
      }
      if (markupAttribute != null) {
        if (markupAttribute.isLiteral()) {
          picker.setMarkup(Markup.valueOf(markupAttribute.getValue()));
        } else {
          ValueExpression expression = markupAttribute.getValueExpression(faceletContext, Object.class);
          ELAdaptor.setExpression(picker, Attributes.MARKUP, expression);
        }
      }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

  private static final Logger LOG = LoggerFactory.getLogger(DatePickerRenderer.class);

  @Override
  public void onComponentCreated(FacesContext facesContext, UIComponent component, UIComponent parent) {
    final UIDatePicker picker = (UIDatePicker) component;
    if (picker.getFor() == null) {
      picker.setFor("@auto");
    }
    picker.setImmediate(true);
    final String linkId = picker.getId();
    picker.setImage("image/date.gif");

    // create popup
    final String popupId = linkId != null ? linkId + "popup" : facesContext.getViewRoot().createUniqueId();
    final UIPopup popup = (UIPopup) CreateComponentUtils.createComponent(
        facesContext, UIPopup.COMPONENT_TYPE, RendererTypes.POPUP, popupId);
    final UIGridLayout layoutOfPopup = (UIGridLayout) CreateComponentUtils.createComponent(
        facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "layoutPopup");
    layoutOfPopup.setColumns("auto");
    layoutOfPopup.setRows("auto");
    popup.getFacets().put(Facets.LAYOUT, layoutOfPopup);
    popup.getAttributes().put(Attributes.Z_INDEX, 10);
    picker.getFacets().put(Facets.POPUP, popup);
    picker.onComponentPopulated(facesContext, parent);
    popup.setRendered(false);
    popup.onComponentPopulated(facesContext, picker);

    final ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
    final ELContext elContext = facesContext.getELContext();
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

    buttonPanel.onComponentPopulated(facesContext, parent);
  }

  @Override
  public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
    UIDatePicker picker = (UIDatePicker) component;
    // todo: use Measure instead of int
    // todo: call setWidth ???
    picker.getAttributes().put(
        Attributes.LAYOUT_WIDTH,
        getResourceManager().getThemeMeasure(facesContext, picker, "pickerWidth").getPixel());

    FacesContextUtils.addPopup(facesContext, (UIPopup) picker.getFacets().get(Facets.POPUP));

    super.prepareRender(facesContext, picker);
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

    super.prepareRender(facesContext, picker);
  }

  @Override
  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
    UIDatePicker picker = (UIDatePicker) component;
    UIDate dateInput = (UIDate) picker.getForComponent();
    if (dateInput == null) {
      LOG.error("The required UIDate component wasn't found for component id='" + component.getId());
      return;
    }
    // this can't be done in "onComponentPopulated()" of the picker, it seems to be to early
    final ValueExpression readonlyExpression = dateInput.getValueExpression(Attributes.READONLY);
    if (readonlyExpression != null) {
      picker.setValueExpression(Attributes.DISABLED, readonlyExpression);
    } else {
      final ValueExpression disabledExpression = dateInput.getValueExpression(Attributes.DISABLED);
      if (disabledExpression != null) {
        picker.setValueExpression(Attributes.DISABLED, disabledExpression);
      } else {
        picker.setDisabled(dateInput.isReadonly() || dateInput.isDisabled());
      }
    }
    UIPopup popup = (UIPopup) picker.getFacets().get(Facets.POPUP);
    picker.setRenderedPartially(new String[] {popup.getId()});
    Converter converter = getConverter(facesContext, dateInput);
    String converterPattern = "yyyy-MM-dd"; // from tobago-calendar.js  initCalendarParse
    if (converter instanceof DateTimeConverter) {
      converterPattern = DateFormatUtils.findPattern((DateTimeConverter) converter);
    } else {
      // LOG.warn("Converter for DateRenderer is not instance of DateTimeConverter. Using default Pattern "
      //    + converterPattern);
    }

    applyConverterPattern(facesContext, popup, converterPattern);

    if (!ComponentUtils.containsPopupActionListener(picker)) {
      picker.addActionListener(new PopupActionListener(popup.getId()));
    }
    super.encodeBegin(facesContext, component);
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

    }
  }

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
    UIDatePicker link = (UIDatePicker) component;
    UIDate dateInput = (UIDate) link.getForComponent();
    if (dateInput != null) {
      super.encodeEnd(facesContext, component);
    } else {
      LOG.error("The required UIDate component wasn't found for component id='" + component.getId());
    }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

      UIForm form = (UIForm) application.createComponent(UIForm.COMPONENT_TYPE);
      form.setRendererType(RendererTypes.FORM);
      form.setId(formIdAttribute != null ? formIdAttribute.getValue(faceletContext) : root.createUniqueId());
      panel.getChildren().add(form);

      UIDatePicker picker = (UIDatePicker) application.createComponent(UIDatePicker.COMPONENT_TYPE);
      picker.setRendererType(RendererTypes.DATE_PICKER);
      picker.setFor("@auto");
      picker.setId(pickerIdAttribute != null ? pickerIdAttribute.getValue(faceletContext) : root.createUniqueId());
      if (picker.getAttributes().get(OnComponentCreated.MARKER) == null) {
        picker.getAttributes().put(OnComponentCreated.MARKER, Boolean.TRUE);
        picker.onComponentCreated(faceletContext.getFacesContext(), panel);
      }
      if (markupAttribute != null) {
        if (markupAttribute.isLiteral()) {
          picker.setMarkup(Markup.valueOf(markupAttribute.getValue()));
        } else {
          ValueExpression expression = markupAttribute.getValueExpression(faceletContext, Object.class);
          picker.setValueExpression(Attributes.MARKUP, expression);
        }
      }
      form.getChildren().add(picker);
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

public class DatePickerRenderer extends LinkRenderer {
  private static final Log LOG = LogFactory.getLog(DatePickerRenderer.class);

  public void encodeBegin(FacesContext facesContext,
      UIComponent component) throws IOException {
    UIDatePicker link = (UIDatePicker) component;
    DatePickerController datePickerController = new DatePickerController();
    UIDateInput dateInput = (UIDateInput) link.getForComponent();
    if (dateInput == null) {
      LOG.error("No required UIDateInput component found.");
      return;
    }
    if (dateInput.getValueBinding(TobagoConstants.ATTR_READONLY) != null) {
      link.setValueBinding(TobagoConstants.ATTR_DISABLED, dateInput.getValueBinding(TobagoConstants.ATTR_READONLY));
    } else {
      link.setDisabled(dateInput.isReadonly());
    }
    String idPrefix = dateInput.getId() + "_picker";
    Map<String, Object>  attributes = link.getAttributes();
    link.setActionListener(datePickerController);
    attributes.put(ATTR_LAYOUT_WIDTH, getConfiguredValue(facesContext, component, "pickerWidth"));
    UIComponent hidden = (UIComponent) link.getChildren().get(0);
    hidden.setId(idPrefix + "Dimension");
    attributes.put(ATTR_ACTION_ONCLICK, "Tobago.openPickerPopup(event, '"
        + link.getClientId(facesContext) + "', '"
        + hidden.getClientId(facesContext) + "')");

    UIPopup popup = (UIPopup) link.getFacets().get(FACET_PICKER_POPUP);
    if (!popup.getActionIds().contains(link.getClientId(facesContext))) {
      popup.getActionIds().add(link.getClientId(facesContext));
    }
    attributes = popup.getAttributes();
    popup.setId(idPrefix + "popup");
    attributes.put(ATTR_WIDTH, String.valueOf(
           ThemeConfig.getValue(facesContext, link, "CalendarPopupWidth")));
    int popupHeight = ThemeConfig.getValue(facesContext, link, "CalendarPopupHeight");
    attributes.put(ATTR_POPUP_RESET, Boolean.TRUE);
    attributes.put(ATTR_HEIGHT, String.valueOf(popupHeight));
    Converter converter = getConverter(facesContext, dateInput);
    String converterPattern = "yyyy-MM-dd"; // from calendar.js  initCalendarParse
    if (converter instanceof DateTimeConverter) {
      converterPattern = DateFormatUtils.findPattern((DateTimeConverter) converter);
    } else {
     // LOG.warn("Converter for DateRenderer is not instance of DateTimeConverter. Using default Pattern "
      //    + converterPattern);
    }

    UICommand okButton = (UICommand) popup.findComponent("ok" + DatePickerController.CLOSE_POPUP);
    attributes = okButton.getAttributes();
    attributes.put(ATTR_ACTION_ONCLICK, "writeIntoField2(this); Tobago.closePickerPopup2(this)");
    okButton.setActionListener(datePickerController);

    UICommand cancelButton  = (UICommand) popup.findComponent(DatePickerController.CLOSE_POPUP);
    attributes = cancelButton.getAttributes();
    attributes.put(ATTR_ACTION_ONCLICK, "Tobago.closePickerPopup2(this)");
    cancelButton.setActionListener(datePickerController);

    applyConverterPattern(popup, converterPattern);

    UIComponent image = (UIComponent) link.getChildren().get(1);
    image.setId(idPrefix + "image");
    if (popup != null) {
      UIPage page = ComponentUtil.findPage(link);
      page.getPopups().add(popup);
    }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

  }

  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final UIDatePicker component = (UIDatePicker) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    if (forComponent != null) {
      component.setFor(forComponent);
    }

    if (tabIndex != null) {
      if (!tabIndex.isLiteralText()) {
        component.setValueExpression("tabIndex", tabIndex);
      } else {
        component.setTabIndex(Integer.parseInt(tabIndex.getExpressionString()));
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

  }

  protected void onComponentPopulated(FaceletContext faceletContext, UIComponent panel, UIComponent parent) {
    if (panel.getChildCount() == 2) {
      Application application = faceletContext.getFacesContext().getApplication();
      UIDatePicker picker = (UIDatePicker) application.createComponent(UIDatePicker.COMPONENT_TYPE);
      picker.setRendererType(RendererTypes.DATE_PICKER);
      picker.setFor("@auto");
      UIViewRoot root = ComponentSupport.getViewRoot(faceletContext, parent);
      picker.setId(root.createUniqueId());
      if (picker.getAttributes().get(OnComponentCreated.MARKER) == null) {
        picker.getAttributes().put(OnComponentCreated.MARKER, Boolean.TRUE);
        picker.onComponentCreated(faceletContext.getFacesContext(), panel);
      }
      panel.getChildren().add(picker);
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UIDatePicker

  private static final Logger LOG = LoggerFactory.getLogger(DatePickerRenderer.class);

  @Override
  public void onComponentCreated(FacesContext facesContext, UIComponent component, UIComponent parent) {
    final UIDatePicker picker = (UIDatePicker) component;
    if (picker.getFor() == null) {
      picker.setFor("@auto");
    }
    picker.setImmediate(true);
    final String linkId = picker.getId();

    // create popup
    final String popupId = linkId != null ? linkId + "popup" : facesContext.getViewRoot().createUniqueId();
    final UIPopup popup = (UIPopup) CreateComponentUtils.createComponent(
        facesContext, UIPopup.COMPONENT_TYPE, RendererTypes.POPUP, popupId);
    final UIGridLayout layoutOfPopup = (UIGridLayout) CreateComponentUtils.createComponent(
        facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "layoutPopup");
    layoutOfPopup.setColumns("auto");
    layoutOfPopup.setRows("auto");
    popup.getFacets().put(Facets.LAYOUT, layoutOfPopup);
    popup.getAttributes().put(Attributes.Z_INDEX, 10);
    picker.getFacets().put(Facets.PICKER_POPUP, popup);
    popup.setRendered(false);
    popup.onComponentPopulated(facesContext, parent);

    FacesUtils.setBindingOrExpression(
        popup, Attributes.LEFT, FacesUtils.createExpressionOrBinding("#{tobago.actionPosition.right.pixel + 5}"));
    FacesUtils.setBindingOrExpression(
        popup, Attributes.TOP, FacesUtils.createExpressionOrBinding("#{tobago.actionPosition.top.pixel}"));

    final UIBox box = (UIBox) CreateComponentUtils.createComponent(
        facesContext, UIBox.COMPONENT_TYPE, RendererTypes.BOX, "box");
    popup.getChildren().add(box);
    // TODO: set string resources in renderer
    box.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "datePickerTitle"));
    final UIGridLayout layoutOfBox = (UIGridLayout) CreateComponentUtils.createComponent(
        facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "layout");
    box.getFacets().put(Facets.LAYOUT, layoutOfBox);
    layoutOfBox.setRows("*;auto;auto");

    final UICalendar calendar = (UICalendar) CreateComponentUtils.createComponent(
        facesContext, UICalendar.COMPONENT_TYPE, RendererTypes.CALENDAR, "calendar");
    box.getChildren().add(calendar);

     // fixme: should work automatically from the layout manager
    final Measure width = getResourceManager().getThemeMeasure(facesContext, calendar, "minimumWidth");
    layoutOfBox.setColumns(width.toString());

    // add time input
    final UIPanel timePanel = (UIPanel) CreateComponentUtils.createComponent(
        facesContext, UIPanel.COMPONENT_TYPE, RendererTypes.PANEL, "timePanel");
    box.getChildren().add(timePanel);
    final UIGridLayout layoutOfTime = (UIGridLayout) CreateComponentUtils.createComponent(
        facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "timePanelLayout");
    timePanel.getFacets().put(Facets.LAYOUT, layoutOfTime);
    layoutOfTime.setColumns("1*;auto;1*");
    final UIPanel cell1 = (UIPanel) CreateComponentUtils.createComponent(
        facesContext, UIPanel.COMPONENT_TYPE, RendererTypes.PANEL, "cell1");
    cell1.onComponentPopulated(facesContext, parent);
    timePanel.getChildren().add(cell1);

    final UITime time = (UITime) CreateComponentUtils.createComponent(
        facesContext, UITime.COMPONENT_TYPE, RendererTypes.TIME, "time");
    timePanel.getChildren().add(time);

    final UIPanel cell2 = (UIPanel) CreateComponentUtils.createComponent(
        facesContext, UIPanel.COMPONENT_TYPE, RendererTypes.PANEL, "cell2");
    cell2.onComponentPopulated(facesContext, parent);
    timePanel.getChildren().add(cell2);

    timePanel.onComponentPopulated(facesContext, parent);


    final UIPanel buttonPanel = (UIPanel) CreateComponentUtils.createComponent(
        facesContext, UIPanel.COMPONENT_TYPE, RendererTypes.PANEL, "buttonPanel");
    final UIGridLayout layoutOfButtons = (UIGridLayout) CreateComponentUtils.createComponent(
        facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "buttonPanelLayout");
    buttonPanel.setLayoutManager(layoutOfButtons);
    layoutOfButtons.setColumns("*;*");
    layoutOfButtons.setRows("auto");

    box.getChildren().add(buttonPanel);
    box.onComponentPopulated(facesContext, parent);

    final UIButton okButton = (UIButton) CreateComponentUtils.createComponent(
        facesContext, UIButton.COMPONENT_TYPE, RendererTypes.BUTTON, "ok");
    buttonPanel.getChildren().add(okButton);
    okButton.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "datePickerOk"));
    okButton.setOnclick("writeIntoField2(this);");
    okButton.getAttributes().put(Attributes.POPUP_CLOSE, "afterSubmit");

    final UIButton cancelButton = (UIButton) CreateComponentUtils.createComponent(
        facesContext, UIButton.COMPONENT_TYPE, RendererTypes.BUTTON, "cancel");
    buttonPanel.getChildren().add(cancelButton);
    cancelButton.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "datePickerCancel"));
    cancelButton.setOnclick("writeIntoField2(this);");
    cancelButton.getAttributes().put(Attributes.POPUP_CLOSE, "immediate");

    buttonPanel.onComponentPopulated(facesContext, parent);

    // create image
    // check the id: its might be better not calling createUniqueId
    final String imageId = linkId != null ? linkId + "image" : facesContext.getViewRoot().createUniqueId();
    final UIImage image = (UIImage) CreateComponentUtils.createComponent(
        facesContext, UIImage.COMPONENT_TYPE, RendererTypes.IMAGE, imageId);
    image.setRendered(true);
    image.setValue("image/date.gif");
    image.setAlt(""); //TODO: i18n (write a text)
    StyleClasses.ensureStyleClasses(image).addFullQualifiedClass("tobago-datePicker-icon");
    picker.getChildren().add(image);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.