Examples of UIPopup


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

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

      } 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

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

  private void createPopup(FacesContext facesContext, UIMessages messages) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("POPUP");
    }
    String id = messages.getId() != null ? messages.getId() + "popup" : facesContext.getViewRoot().createUniqueId();
    final UIPopup popup = (UIPopup)
        ComponentUtil.createComponent(facesContext, UIPopup.COMPONENT_TYPE, TobagoConstants.RENDERER_TYPE_POPUP, id);

    UIPage page = ComponentUtil.findPage(facesContext, messages);

    popup.setWidth(page.getWidth() - 200 + "px");
    popup.setHeight(page.getHeight() - 200 + "px");
    popup.setLeft("100px");
    popup.setTop("100px");
    popup.setRendered(true);
    popup.setActivated(true);
    page.getPopups().add(popup);

    Map<String, Object> okButtonAttributes = popup.getAttributes();
    okButtonAttributes.put(TobagoConstants.ATTR_POPUP_RESET, Boolean.TRUE);

    final UIComponent box = ComponentUtil.createComponent(
        facesContext, UIBox.COMPONENT_TYPE, TobagoConstants.RENDERER_TYPE_BOX);
    popup.getChildren().add(box);
    box.setId("box");
    // TODO: set string resources in renderer
    box.getAttributes().put(TobagoConstants.ATTR_LABEL, ResourceManagerUtil.getPropertyNotNull(
        facesContext, "tobago", "tobago.message.confirmation.title"));
    UIComponent layout = ComponentUtil.createComponent(
View Full Code Here

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

  }

  public void encodeEnd(FacesContext facesContext,
      UIComponent uiComponent) throws IOException {
    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
    UIPopup component = (UIPopup) uiComponent;
    final String clientId = component.getClientId(facesContext);

    writer.endElement(HtmlConstants.DIV);

    if (!AjaxUtils.isAjaxRequest(facesContext)) {
      writer.endElement(HtmlConstants.DIV);
    }

    String setupScript = "Tobago.setupPopup('" + clientId + "', '"
        + component.getLeft() + "', '" + component.getTop() + "', " + component.isModal() + ");";
    writer.writeJavascript(setupScript);
  }
View Full Code Here

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

    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

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

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

    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
    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();
    Integer zIndex = (Integer) facesContext.getExternalContext().getRequestMap().get(TobagoConstants.ATTR_ZINDEX);
    if (zIndex == null) {
      zIndex = 0;
    } else {
      zIndex += 10;
    }
    facesContext.getExternalContext().getRequestMap().put(TobagoConstants.ATTR_ZINDEX, zIndex);
    final StringBuilder contentStyle = new StringBuilder();
    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);
    //contentStyle.append("; ");
    //contentStyle.append("top: ");
    //contentStyle.append(top);
    //contentStyle.append("; ");

    if (!AjaxUtils.isAjaxRequest(facesContext)) {
      writer.startElement(HtmlConstants.DIV, component);
      writer.writeClassAttribute("tobago-popup-parent");
    }

    if (component.isModal()) {
      writer.startElement(HtmlConstants.DIV, component);
      writer.writeIdAttribute(clientId);
      writer.writeStyleAttribute("z-index: " + (zIndex + 1) + ";");
      writer.writeClassAttribute();
      writer.writeAttribute(HtmlAttributes.ONCLICK, "Tobago.popupBlink('" + clientId + "')", null);
      if (ClientProperties.getInstance(facesContext).getUserAgent().isMsie()) {
        String bgImage = ResourceManagerUtil.getImageWithPath(facesContext, "image/popupBg.png");
        writer.writeAttribute(HtmlAttributes.STYLE, "background: none; "
            + "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
          + bgImage + "', sizingMethod='scale');", false);
      }
      writer.endElement(HtmlConstants.DIV);
    }
    if (ClientProperties.getInstance(facesContext).getUserAgent().isMsie()) {
      writer.startElement(HtmlConstants.IFRAME, component);
      writer.writeIdAttribute(clientId + SUBCOMPONENT_SEP + HtmlConstants.IFRAME);
      writer.writeClassAttribute("tobago-popup-iframe tobago-popup-none");
      UIPage page = ComponentUtil.findPage(facesContext);
      final StringBuilder iFrameStyle = new StringBuilder();
      iFrameStyle.append("z-index: ");
      iFrameStyle.append(zIndex + 2);
      iFrameStyle.append("; ");
      if (component.isModal()) {
        // full client area
        iFrameStyle.append("width: ");
        iFrameStyle.append(page.getWidth());
        iFrameStyle.append("; ");
        iFrameStyle.append("height: ");
        iFrameStyle.append(page.getHeight());
        iFrameStyle.append("; ");
      } else {
        iFrameStyle.append(contentStyle); // size of the popup
      }
      writer.writeAttribute(HtmlAttributes.STYLE, iFrameStyle.toString(), false);
      writer.writeAttribute(HtmlAttributes.SRC, ResourceManagerUtil.getBlankPage(facesContext), false);
      writer.writeAttribute(HtmlAttributes.FRAMEBORDER, "0", false);
      writer.endElement(HtmlConstants.IFRAME);
    }
    writer.startElement(HtmlConstants.DIV, component);
    writer.writeIdAttribute(contentDivId);
    StyleClasses styleClasses = new StyleClasses();
    styleClasses.addClass("popup", "content");
    styleClasses.addClass("popup", "none");
    if (component.isModal()) {
      styleClasses.addClass("popup", "modal");
    }
    writer.writeClassAttribute(styleClasses);

    contentStyle.append("z-index: ");
View Full Code Here

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

  private void createPopup(FacesContext facesContext, UIMessages messages) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("POPUP");
    }
    String id = messages.getId() != null ? messages.getId() + "popup" : facesContext.getViewRoot().createUniqueId();
    final UIPopup popup = (UIPopup)
        CreateComponentUtils.createComponent(facesContext, UIPopup.COMPONENT_TYPE, RendererTypes.POPUP, id);
    popup.getAttributes().put(Attributes.Z_INDEX, 10);

    AbstractUIPage page = ComponentUtils.findPage(facesContext, messages);

    popup.setWidth(page.getCurrentWidth().subtract(200));
    popup.setHeight(page.getCurrentHeight().subtract(200));
    popup.setLeft(Measure.valueOf(100));
    popup.setTop(Measure.valueOf(100));
    popup.setRendered(true);
    popup.setActivated(true);
    FacesContextUtils.addPopup(facesContext, popup);

    Map<String, Object> okButtonAttributes = popup.getAttributes();
    okButtonAttributes.put(Attributes.POPUP_RESET, Boolean.TRUE);

    final UIComponent box = CreateComponentUtils.createComponent(
        facesContext, UIBox.COMPONENT_TYPE, RendererTypes.BOX);
    popup.getChildren().add(box);
    box.setId("box");
    // TODO: set string resources in renderer
    box.getAttributes().put(Attributes.LABEL, ResourceManagerUtils.getPropertyNotNull(
        facesContext, "tobago", "tobago.message.confirmation.title"));
    UIComponent layout = CreateComponentUtils.createComponent(
View Full Code Here

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

  }

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

    UIPopup popup = (UIPopup) component;

    FacesContextUtils.addPopup(facesContext, popup);


    FacesContextUtils.addScriptBlock(facesContext, "jQuery(document).ready(function() {Tobago.setupPopup();});");

    super.prepareRender(facesContext, popup);

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

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

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

    LayoutContext layoutContext = new LayoutContext(popup);
    layoutContext.layout();

    // XXX fixing invisible popups
    if (popup.getCurrentWidth() == null || popup.getCurrentWidth().equals(Measure.ZERO)) {
      LOG.warn("Undefined width of popup with id='" + popup.getClientId(facesContext) + "'");
      popup.setCurrentWidth(getPreferredWidth(facesContext, popup));
    }
    if (popup.getCurrentHeight() == null || popup.getCurrentHeight().equals(Measure.ZERO)) {
      LOG.warn("Undefined height of popup with id='" + popup.getClientId(facesContext) + "'");
      popup.setCurrentHeight(getPreferredHeight(facesContext, popup));
    }

    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.getCurrentWidth().subtract(popup.getCurrentWidth()).divide(2));
    }
    if (popup.getTop() == null) {
      popup.setTop(page.getCurrentHeight().subtract(popup.getCurrentHeight()).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

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

      }
    }
    Map<String, Object>  attributes = link.getAttributes();
    attributes.put(ATTR_LAYOUT_WIDTH, getConfiguredValue(facesContext, component, "pickerWidth"));
    UIComponent hidden = (UIComponent) link.getChildren().get(0);
    UIPopup popup = (UIPopup) link.getFacets().get(FACET_PICKER_POPUP);

    attributes.put(ATTR_ACTION_ONCLICK, "Tobago.openPickerPopup(event, '"
        + link.getClientId(facesContext) + "', '"
        + hidden.getClientId(facesContext) + "', '"
        + popup.getClientId(facesContext) +"')");

    attributes = popup.getAttributes();

    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" + UIDatePicker.CLOSE_POPUP);
    attributes = okButton.getAttributes();
    attributes.put(ATTR_ACTION_ONCLICK, "writeIntoField2(this);");
    attributes.put(TobagoConstants.ATTR_POPUP_CLOSE, "afterSubmit");
   // okButton.setActionListener(datePickerController);

    UICommand cancelButton  = (UICommand) popup.findComponent(UIDatePicker.CLOSE_POPUP);
    attributes = cancelButton.getAttributes();
    attributes.put(ATTR_ACTION_ONCLICK, "writeIntoField2(this);");
    attributes.put(TobagoConstants.ATTR_POPUP_CLOSE, "immediate");
    //cancelButton.setActionListener(datePickerController);

    applyConverterPattern(facesContext, popup, converterPattern);

    UIPage page = ComponentUtil.findPage(facesContext, link);
    page.getPopups().add(popup);

    if (!ComponentUtil.containsPopupActionListener(link)) {
      link.addActionListener(new PopupActionListener(popup.getId()));
    }
    super.encodeBegin(facesContext, component);
  }
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.