Package org.apache.myfaces.tobago.component

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


    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);
    popup.getAttributes().put(Attributes.Z_INDEX, 10);
    picker.getFacets().put(Facets.PICKER_POPUP, popup);
    popup.setRendered(false);
    popup.onComponentPopulated(facesContext, parent);

    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);
View Full Code Here


    // todo: call setWidth ???
    picker.getAttributes().put(
        Attributes.LAYOUT_WIDTH,
        getResourceManager().getThemeMeasure(facesContext, picker, "pickerWidth").getPixel());
    if (facesContext instanceof TobagoFacesContext) {
      UIPopup popup = (UIPopup) picker.getFacets().get(Facets.PICKER_POPUP);
      if (popup != null) {
        popup.setWidth(getResourceManager().getThemeMeasure(facesContext, picker, "calendarPopupWidth"));
        popup.setHeight(getResourceManager().getThemeMeasure(facesContext, picker, "calendarPopupHeight"));
        ((TobagoFacesContext) facesContext).getPopups().add(popup);
      }
    }
    super.prepareRender(facesContext, picker);
  }
View Full Code Here

      } else {
        picker.setDisabled(dateInput.isReadonly() || dateInput.isDisabled());
      }
    }
    Map<String, Object> attributes = picker.getAttributes();
    UIPopup popup = (UIPopup) picker.getFacets().get(Facets.PICKER_POPUP);

    attributes.put(Attributes.ONCLICK, "Tobago.openPopupWithAction(Tobago.element(event), '"
        + popup.getClientId(facesContext) + "', '"
        + picker.getClientId(facesContext) + "')");

    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);
    }

    applyConverterPattern(facesContext, popup, converterPattern);

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

    if (disabled) {
      onclick = "";
      href = "";
    } else {
      href = "#"; // this is to make the link "active", needed for focus, cursor, etc.
      UIPopup popup = (UIPopup) command.getFacet(Facets.POPUP);
      if (popup != null) {
        if (!ComponentUtils.containsPopupActionListener(command)) {
          command.addActionListener(new PopupFacetActionListener());
        }
      }
View Full Code Here

  }

  @Override
  public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {

    UIPopup popup = (UIPopup) component;

    if (facesContext instanceof TobagoFacesContext) {
      ((TobagoFacesContext) facesContext).getPopups().add(popup);
    }

    // TODO: where to put this code, it is good here?
    TobagoFacesContext tobagoContext = (TobagoFacesContext) facesContext;
    tobagoContext.getScriptBlocks().add("jQuery(document).ready(function() {Tobago.setupPopup();});");

    super.prepareRender(facesContext, popup);

    if (popup.isModal()) {
      popup.setCurrentMarkup(popup.getCurrentMarkup().add(Markup.MODAL));
    }
  }
View Full Code Here

      writer.startJavascript();
      writer.write("Tobago.setupPopup();");
      writer.endJavascript();
    }
   
    UIPopup popup = (UIPopup) component;

// LAYOUT Begin

    // todo: remove time logging
    long begin = System.nanoTime();
    LayoutContext layoutContext = new LayoutContext(popup);
    layoutContext.layout();
    LOG.info("Laying out takes: " + new DecimalFormat("#,##0").format(System.nanoTime() - begin) + " ns");

// LAYOUT End

    final String clientId = popup.getClientId(facesContext);

    // XXX May be computed in the "Layout Manager Phase"
    AbstractUIPage page = ComponentUtils.findPage(facesContext);
    if (popup.getLeft() == null) {
      popup.setLeft(page.getWidth().subtract(popup.getWidth()).divide(2));
    }
    if (popup.getTop() == null) {
      popup.setTop(page.getHeight().subtract(popup.getWidth()).divide(2));
    }

    writer.startElement(HtmlElements.DIV, popup);
    writer.writeIdAttribute(clientId);
    Style style = new Style(facesContext, popup);
    Integer zIndex = popup.getZIndex();
    if (zIndex == null) {
      zIndex = 100;
      LOG.warn("No z-index found for UIPopup. Set to " + zIndex);
    }
    style.setZIndex(zIndex);
View Full Code Here

      picker = createPicker(input);
      input.getFacets().put(FACET_PICKER, picker);
    }
    RenderUtil.encode(facesContext, picker);

    UIPopup popup = (UIPopup) picker.getFacet(FACET_PICKER_POPUP);
    if (popup != null) {
      UIPage page = ComponentUtil.findPage(input);
      page.getPopups().add(popup);
    }
  }
View Full Code Here

  public void encodeBeginTobago(
      FacesContext facesContext, UIComponent uiComponent) throws IOException {

    TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();
    UIPopup component = (UIPopup) uiComponent;
    final String clientId = component.getClientId(facesContext);
    final String contentDivId = clientId + CONTENT_ID_POSTFIX;
    final String left = component.getLeft();
    final String top = component.getTop();

    final StringBuffer contentStyle = new StringBuffer();
    if (component.getWidth() != null) {
      contentStyle.append("width: ");
      contentStyle.append(component.getWidth());
      contentStyle.append("; ");
    }
    if (component.getHeight() != null) {
      contentStyle.append("height: ");
      contentStyle.append(component.getHeight());
      contentStyle.append("; ");
    }
    contentStyle.append("left: ");
    contentStyle.append(left != null ? left : "100");
    contentStyle.append("; ");
View Full Code Here

  }

  public void encodeEndTobago(FacesContext facesContext,
      UIComponent uiComponent) throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();
    UIPopup component = (UIPopup) uiComponent;
    final String clientId = component.getClientId(facesContext);

    writer.endElement("div");

    String setupScript = "Tobago.setupPopup('" + clientId + "', '"
        + component.getLeft() + "', '" + component.getTop() + "');";
    HtmlRendererUtil.writeJavascript(writer, setupScript);

    if (ComponentUtil.getBooleanAttribute(component, ATTR_POPUP_RESET)) {
      component.setRendered(false);
    }
  }
View Full Code Here

    if (disabled) {
      onclick = "";
      href = "";
    } else {

      UIPopup popup = (UIPopup) command.getFacet(FACET_POPUP);
      if (popup != null) {
        if (!ComponentUtil.containsPopupActionListener(command)) {
          command.addActionListener(new PopupActionListener(popup));
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.component.UIPopup

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.