Package org.apache.myfaces.tobago.component

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


    if (LOG.isDebugEnabled()) {
      LOG.debug("POPUP");
    }
    final 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);

    final 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);
    popup.onComponentPopulated(facesContext, messages);
    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


  }

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

    final UIPopup popup = (UIPopup) component;
    FacesContextUtils.addPopup(facesContext, popup);

    super.prepareRender(facesContext, popup);

    if (popup.isModal()) {
      ComponentUtils.addCurrentMarkup(popup, Markup.MODAL);
    }
  }
View Full Code Here

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

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    final UIPopup popup = (UIPopup) component;

    final 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"
    final 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);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, popup);
    final 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

    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();
    popup.setValueExpression(Attributes.LEFT, expressionFactory.createValueExpression(
        elContext, "#{tobagoContext.actionPosition.right.pixel + 5}", Object.class));
    popup.setValueExpression(Attributes.TOP, expressionFactory.createValueExpression(
        elContext, "#{tobagoContext.actionPosition.top.pixel}", Object.class));

    final UIBox box = (UIBox) CreateComponentUtils.createComponent(
        facesContext, UIBox.COMPONENT_TYPE, RendererTypes.BOX, "box");
    popup.getChildren().add(box);
    box.setValueExpression(Attributes.LABEL, expressionFactory.createValueExpression(
        elContext, "#{tobagoContext.resourceBundle.datePickerTitle}", String.class));
    final UIGridLayout layoutOfBox = (UIGridLayout) CreateComponentUtils.createComponent(
        facesContext, UIGridLayout.COMPONENT_TYPE, RendererTypes.GRID_LAYOUT, "layout");
    box.getFacets().put(Facets.LAYOUT, layoutOfBox);
View Full Code Here

        picker.setValueExpression(Attributes.DISABLED, disabledExpression);
      } else {
        picker.setDisabled(dateInput.isReadonly() || dateInput.isDisabled());
      }
    }
    final UIPopup popup = (UIPopup) picker.getFacets().get(Facets.POPUP);
    picker.setRenderedPartially(new String[] {popup.getId()});
    final 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

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

    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.closePopup(this);");
    attributes.put(TobagoConstants.ATTR_POPUP_CLOSE, "afterSubmit");
   // okButton.setActionListener(datePickerController);

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

    applyConverterPattern(popup, converterPattern);

    UIComponent image = (UIComponent) link.getChildren().get(1);
    image.setId(idPrefix + "image");
    if (popup != null) {
      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

  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

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

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

    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 (component.isModal()) {
      writer.startElement(HtmlConstants.DIV, component);
      writer.writeIdAttribute(clientId);
      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 frameSize = new StringBuilder();
      if (component.isModal()) {
        // full client area
        frameSize.append("width: ");
        frameSize.append(page.getWidth());
        frameSize.append("; ");
        frameSize.append("height: ");
View Full Code Here

  }

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

    String setupScript = "Tobago.setupPopup('" + clientId + "', '"
        + component.getLeft() + "', '" + component.getTop() + "', " + component.isModal() + ");";
    writer.writeJavascript(setupScript);
  }
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.