Package org.apache.myfaces.tobago.component

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


    int tabLabelExtraWidth = getConfiguredValue(facesContext, component, "tabLabelExtraWidth");

    boolean first = true;
    for (UIComponent child : (List<UIComponent>) component.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          if (label.getText() != null) {
            tabs.getWidthList().add(RenderUtil.calculateStringWidth2(facesContext, component, label.getText())
                + tabLabelExtraWidth);
          } else {
View Full Code Here


    UIToolBar toolBar = null;
    if (toolbarWidth > 0) {
      toolBar = createToolBar(facesContext, component, virtualTab, switchType, tabList, clientId);
    }

    UITab activeTab = null;

    int index = 0;
    for (UIComponent child : (List<UIComponent>) component.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          String onclick;
          if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
              && SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
            onclick = null;
          } else {
            onclick = "tobago_switchTab('"+ switchType + "','" + clientId + "'," + index + ','
                + component.getChildCount() + ')';
          }

          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          StyleClasses outerClass = new StyleClasses();
          StyleClasses innerClass = new StyleClasses();
          if (virtualTab == index) {
            outerClass.addClass("tab", "selected-outer");
            innerClass.addClass("tab", "selected-inner");
            activeTab = (UITab) tab;
          } else {
            outerClass.addClass("tab", "unselected-outer");
            innerClass.addClass("tab", "unselected-inner");
          }
          outerClass.addMarkupClass(tab, "tab", "outer");
          innerClass.addMarkupClass(tab, "tab", "outer");
          writer.startElement(HtmlConstants.TD, tab);
          map = new HtmlStyleMap();
          map.put("width", tabList.getWidthList().get(index));

          writer.writeStyleAttribute(map);
          writer.writeIdAttribute(tab.getClientId(facesContext));

          HtmlRendererUtil.renderTip(tab, writer);

          writer.startElement(HtmlConstants.DIV, null);
          writer.writeStyleAttribute(map);
          writer.startElement(HtmlConstants.DIV, null);
          writer.writeClassAttribute(outerClass);
          //writer.writeStyleAttribute(map);
          writer.startElement(HtmlConstants.DIV, null);
          //writer.writeStyleAttribute(map);
          writer.writeClassAttribute(innerClass);

          writer.startElement(HtmlConstants.SPAN, null);
          String tabId = clientId + "__" + virtualTab + "__" + index;
          writer.writeIdAttribute(tabId);

          if (tab.isDisabled()) {
            writer.writeClassAttribute("tobago-tab-disabled");
          } else {
            writer.writeClassAttribute("tobago-tab-link");
            if (onclick != null) {
              writer.writeAttribute(HtmlAttributes.ONCLICK, onclick, true);
View Full Code Here

    writer.writeStyleAttribute(headerStyle);

    writer.startElement(HtmlConstants.TR, null);
    writer.writeAttribute(HtmlAttributes.VALIGN, "bottom", false);

    UITab activeTab = null;

    int index = 0;
    for (UIComponent child: (List<UIComponent>) component.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          String onclick;
          if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
              && SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
            onclick = null;
          } else if (SWITCH_TYPE_RELOAD_PAGE.equals(switchType)
              || SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
            onclick = "tobago_requestTab('"
                + clientId + "'," + index + ",'"
                + ComponentUtil.findPage(facesContext, component).getFormId(facesContext) + "')";
          } else {   //  SWITCH_TYPE_CLIENT
            onclick = "tobago_selectTab('"
                + clientId + "'," + index + ','
                + component.getChildCount() + ')';
          }

          LabelWithAccessKey label = new LabelWithAccessKey(tab);

          StyleClasses outerClass = new StyleClasses();
          StyleClasses innerClass = new StyleClasses();
          if (virtualTab == index) {
            outerClass.addClass("tab", "selected-outer");
            innerClass.addClass("tab", "selected-inner");
            activeTab = (UITab) tab;
          } else {
            outerClass.addClass("tab", "unselected-outer");
            innerClass.addClass("tab", "unselected-inner");
          }
          outerClass.addMarkupClass(tab, "tab", "outer");
          innerClass.addMarkupClass(tab, "tab", "outer");
          writer.startElement(HtmlConstants.TD, tab);
          writer.writeIdAttribute(tab.getClientId(facesContext));
          writer.writeAttributeFromComponent(HtmlAttributes.TITLE, ATTR_TIP);

          writer.startElement(HtmlConstants.DIV, null);
          writer.writeClassAttribute(outerClass);

          writer.startElement(HtmlConstants.DIV, null);
          writer.writeClassAttribute(innerClass);

          writer.startElement(HtmlConstants.SPAN, null);
          String tabId = clientId + "." + virtualTab + SUBCOMPONENT_SEP + index;
          writer.writeIdAttribute(tabId);

          if (tab.isDisabled()) {
            writer.writeClassAttribute("tobago-tab-disabled");
          } else {
            writer.writeClassAttribute("tobago-tab-link");
            if (onclick != null) {
              writer.writeAttribute(HtmlAttributes.ONCLICK, onclick, true);
View Full Code Here

    writer.writeClassAttribute(Classes.create(tabGroup, "headerInner"));

    int index = 0;
    for (UIComponent child : (List<UIComponent>) tabGroup.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          if (activeIndex == index) {
            ComponentUtils.addCurrentMarkup(tab, Markup.SELECTED);
          }
          FacesMessage.Severity maxSeverity = ComponentUtils.getMaximumSeverityOfChildrenMessages(facesContext, tab);
          if (maxSeverity != null) {
            ComponentUtils.addCurrentMarkup(tab, ComponentUtils.markupOfSeverity(maxSeverity));
          }
          writer.startElement(HtmlElements.DIV, tab);
          writer.writeClassAttribute(Classes.create(tab));
          writer.writeAttribute(HtmlAttributes.TABGROUPINDEX, index);
          String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, tab);
          if (title != null) {
            writer.writeAttribute(HtmlAttributes.TITLE, title, true);
          }

          writer.startElement(HtmlElements.A, tab);
          if (!tab.isDisabled()) {
            writer.writeAttribute(HtmlAttributes.HREF, "#", false);
          }
          final String tabId = tab.getClientId(facesContext);
          writer.writeIdAttribute(tabId);
          if (label.getText() != null) {
            HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
          } else {
            writer.writeText(Integer.toString(index + 1));
View Full Code Here

        facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "menu");
    FacetUtils.setDropDownMenu(all, menu);
    int index = 0;
    for (UIComponent child : (List<UIComponent>) tabGroup.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, "entry-" + index);
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          entry.setLabel(label.getText());
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            entry.setOnclick(JQueryUtils.selectId(clientId)
                + ".find('.tobago-tab[tabgroupindex=" + index + "]')"
                + ".click();"
View Full Code Here

    writer.writeClassAttribute(Classes.create(tabGroup, "headerInner"));

    int index = 0;
    for (UIComponent child : tabGroup.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          if (activeIndex == index) {
            ComponentUtils.addCurrentMarkup(tab, Markup.SELECTED);
          }
          FacesMessage.Severity maxSeverity = ComponentUtils.getMaximumSeverityOfChildrenMessages(facesContext, tab);
          if (maxSeverity != null) {
            ComponentUtils.addCurrentMarkup(tab, ComponentUtils.markupOfSeverity(maxSeverity));
          }
          writer.startElement(HtmlElements.DIV, tab);
          writer.writeClassAttribute(Classes.create(tab));
          writer.writeAttribute(HtmlAttributes.TABGROUPINDEX, index);
          String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, tab);
          if (title != null) {
            writer.writeAttribute(HtmlAttributes.TITLE, title, true);
          }

          writer.startElement(HtmlElements.A, tab);
          if (!tab.isDisabled()) {
            writer.writeAttribute(HtmlAttributes.HREF, "#", false);
          }
          final String tabId = tab.getClientId(facesContext);
          writer.writeIdAttribute(tabId);
          if (label.getAccessKey() != null) {
            writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
          }
          if (label.getText() != null) {
View Full Code Here

    menu.setTransient(true);
    FacetUtils.setDropDownMenu(all, menu);
    int index = 0;
    for (UIComponent child : tabGroup.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, null);
          entry.setTransient(true);
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          entry.setLabel(label.getText());
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            ComponentUtils.putDataAttribute(entry, "tobago-index", index); // XXX todo, define a DataAttribute
          }
          menu.getChildren().add(entry);
View Full Code Here

  }

  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final UITab component = (UITab) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    if (markup != null) {
      if (!markup.isLiteralText()) {
        component.setValueExpression("markup", markup);
      } else {
        component.setMarkup(org.apache.myfaces.tobago.context.Markup.valueOf(markup.getExpressionString()));
      }
    }
    if (accessKey != null) {
      if (!accessKey.isLiteralText()) {
        component.setValueExpression("accessKey", accessKey);
      } else {
        component.setAccessKey(accessKey.getExpressionString().charAt(0));
      }
    }
    if (labelWithAccessKey != null) {
      component.setValueExpression("labelWithAccessKey", labelWithAccessKey);
    }

    if (label != null) {
      component.setValueExpression("label", label);
    }

    if (disabled != null) {
      if (!disabled.isLiteralText()) {
        component.setValueExpression("disabled", disabled);
      } else {
        component.setDisabled(Boolean.parseBoolean(disabled.getExpressionString()));
      }
    }
    if (tip != null) {
      component.setValueExpression("tip", tip);
    }

  }
View Full Code Here

    writer.writeClassAttribute(Classes.create(tabGroup, "headerInner"));

    int index = 0;
    for (UIComponent child : (List<UIComponent>) tabGroup.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          if (activeIndex == index) {
            tab.setCurrentMarkup(tab.getCurrentMarkup().add(Markup.SELECTED));
          }
          FacesMessage.Severity maxSeverity = ComponentUtils.getMaximumSeverityOfChildrenMessages(facesContext, tab);
          if (maxSeverity != null) {
            tab.setCurrentMarkup(tab.getCurrentMarkup().add(ComponentUtils.markupOfSeverity(maxSeverity)));
          }
          writer.startElement(HtmlElements.DIV, tab);
          writer.writeClassAttribute(Classes.create(tab));
          writer.writeAttribute(HtmlAttributes.TABGROUPINDEX, index);

          writer.startElement(HtmlElements.A, tab);
          if (!tab.isDisabled()) {
            writer.writeAttribute(HtmlAttributes.HREF, "#", false);
          }
          final String tabId = tab.getClientId(facesContext);
          writer.writeIdAttribute(tabId);
          if (label.getText() != null) {
            HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
          } else {
            writer.writeText(Integer.toString(index + 1));
View Full Code Here

        facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "menu");
    FacetUtils.setDropDownMenu(all, menu);
    int index = 0;
    for (UIComponent child : (List<UIComponent>) tabGroup.getChildren()) {
      if (child instanceof UITab) {
        UITab tab = (UITab) child;
        if (tab.isRendered()) {
          UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
              facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, "entry-" + index);
          LabelWithAccessKey label = new LabelWithAccessKey(tab);
          entry.setLabel(label.getText());
          if (tab.isDisabled()) {
            entry.setDisabled(true);
          } else {
            entry.setOnclick(JQueryUtils.selectId(clientId)
                + ".find('.tobago-tab[tabgroupindex=" + index + "]')"
                + ".click();"
View Full Code Here

TOP

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

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.