Package org.apache.myfaces.tobago.component

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


  }

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


    UITabGroup component = (UITabGroup) uiComponent;

    HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, component);

    layoutTabs(facesContext, component);

    int activeIndex = ensureRenderedActiveIndex(facesContext, component);

    final String clientId = component.getClientId(facesContext);
    final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;
    final String switchType = component.getSwitchType();

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

    page.getScriptFiles().addAll(Arrays.asList(SCRIPTS));

    if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
      HtmlRendererUtil.writeScriptLoader(facesContext, SCRIPTS, new String[0]);
    }

    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlConstants.INPUT, null);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
    writer.writeAttribute(HtmlAttributes.VALUE, Integer.toString(activeIndex), false);
    writer.writeNameAttribute(hiddenId);
    writer.writeIdAttribute(hiddenId);
    writer.endElement(HtmlConstants.INPUT);

    String image1x1 = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");

    TabList tabList = getTabList(facesContext, component);

    // if a outer uiPage is presend, the virtual tab will go over all
    // tabs and render it as they are selected, and it will
    // selected with stylesheet.
    int virtualTab = 0;
    int currentWidth = 0;
    int navigationBarWidth = 0;
    if (ComponentUtil.getBooleanAttribute(component, TobagoConstants.ATTR_SHOW_NAVIGATION_BAR)) {
      navigationBarWidth = getConfiguredValue(facesContext, component, "navigationBarWidth");
    }
    for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
      if (tab instanceof UIPanelBase) {
        if (tab.isRendered()) {
          currentWidth += tabList.getWidthList().get(virtualTab);
          if (SWITCH_TYPE_CLIENT.equals(switchType) || virtualTab == activeIndex) {

            if (virtualTab != activeIndex) {
              HtmlRendererUtil.replaceStyleAttribute(component, "display", "none");
            } else {
              HtmlRendererUtil.removeStyleAttribute(component, "display");
            }

            writer.startElement(HtmlConstants.DIV, null);
            writer.writeComment("empty div fix problem with mozilla and fieldset");
            writer.endElement(HtmlConstants.DIV);

            writer.startElement(HtmlConstants.DIV, null);
            writer.writeIdAttribute(clientId);
            StyleClasses classes = (StyleClasses) component.getAttributes().get(ATTR_STYLE_CLASS);
            writer.writeClassAttribute(classes);
            renderTabGroupView(facesContext, writer, component, virtualTab,
                (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE),
                switchType, image1x1, navigationBarWidth, currentWidth, tabList);
            writer.endElement(HtmlConstants.DIV);

            if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
                && SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
              final String[] cmds = {
                  "new Tobago.TabGroup(",
                  "    '" + clientId + "', ",
                  "    '" + activeIndex + "', ",
                  "    '" + component.getChildCount() + "');"
              };
              HtmlRendererUtil.writeScriptLoader(facesContext, new String[0], cmds);
            }
          }
        }
View Full Code Here


        ResourceManagerUtil.getImageWithPath(context, "image/1x1.gif"),
        getConfiguredValue(context, component, "navigationBarWidth"), currentWidth, tabList);
  }

  public int getFixedHeight(FacesContext facesContext, UIComponent uiComponent) {
    UITabGroup component = (UITabGroup) uiComponent;
    int height =
        ComponentUtil.getIntAttribute(component, ATTR_HEIGHT, -1);

    int fixedHeight;
    if (height != -1) {
      fixedHeight = height;
    } else {
      fixedHeight = 0;
      for (UIComponent tab : (List<UIComponent>) component.getChildren()) {
        if (tab instanceof UIPanelBase && tab.isRendered()) {
          LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, tab);
          fixedHeight
              = Math.max(fixedHeight, renderer.getFixedHeight(facesContext, tab));
        }
View Full Code Here

  }

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


    UITabGroup component = (UITabGroup) uiComponent;

    HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, component);

    layoutTabs(facesContext, component);

    int activeIndex = ensureRenderedActiveIndex(facesContext, component);

    final String clientId = component.getClientId(facesContext);
    final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;

    final String switchType = component.getSwitchType();

    UIPage page = ComponentUtil.findPage(facesContext, component);
    final String[] scripts = new String[]{
        "script/tab.js",
        "script/tabgroup.js"
    };
    page.getScriptFiles().addAll(Arrays.asList(scripts));

    if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
      HtmlRendererUtil.writeScriptLoader(facesContext, scripts, new String[0]);
    }


    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlConstants.INPUT, null);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
    writer.writeAttribute(HtmlAttributes.VALUE, Integer.toString(activeIndex), false);
    writer.writeNameAttribute(hiddenId);
    writer.writeIdAttribute(hiddenId);
    writer.endElement(HtmlConstants.INPUT);

    String image1x1 = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");

    // if a outer uiPage is presend, the virtual tab will go over all
    // tabs and render it as they are selected, and it will
    // selected with stylesheet.
    int virtualTab = 0;
    //UIPanelBase[] tabs = component.getTabs();
    for (UIComponent tab: (List<UIComponent>) component.getChildren()) {
      if (tab instanceof UIPanelBase) {
        if (tab.isRendered() && (SWITCH_TYPE_CLIENT.equals(switchType) || virtualTab == activeIndex)) {

          if (virtualTab != activeIndex) {
            HtmlRendererUtil.replaceStyleAttribute(component, "display", "none");
          } else {
            HtmlRendererUtil.removeStyleAttribute(component, "display");
          }

          writer.startElement(HtmlConstants.DIV, null);
          writer.writeComment("empty div fix problem with mozilla and fieldset");
          writer.endElement(HtmlConstants.DIV);

          writer.startElement(HtmlConstants.DIV, null);
          writer.writeIdAttribute(clientId);
          renderTabGroupView(facesContext, writer, component, virtualTab,
              (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE),
              switchType, image1x1);
          writer.endElement(HtmlConstants.DIV);

          if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
              && SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
            final String[] cmds = {
                "new Tobago.TabGroup(",
                "    '" + clientId + "', ",
                "    '" + activeIndex + "', ",
                "    '" + component.getChildCount() + "');"
            };
            HtmlRendererUtil.writeScriptLoader(facesContext, new String[0], cmds);
          }
        }
        virtualTab++;
View Full Code Here

        ResourceManagerUtil.getImageWithPath(context, "image/1x1.gif"));
    context.responseComplete();
  }

  public int getFixedHeight(FacesContext facesContext, UIComponent uiComponent) {
    UITabGroup component = (UITabGroup) uiComponent;
    int height =
        ComponentUtil.getIntAttribute(component, ATTR_HEIGHT, -1);

    int fixedHeight;
    if (height != -1) {
      fixedHeight = height;
    } else {
      fixedHeight = 0;
      for (UIComponent tab: (List<UIComponent>) component.getChildren()) {
        if (tab instanceof UIPanelBase && tab.isRendered()) {
          LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, tab);
          fixedHeight
              = Math.max(fixedHeight, renderer.getFixedHeight(facesContext, tab));
        }
View Full Code Here

  }

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {

    UITabGroup tabGroup = (UITabGroup) uiComponent;

    int activeIndex = ensureRenderedActiveIndex(facesContext, tabGroup);

    final String clientId = tabGroup.getClientId(facesContext);
    final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;
    final String switchType = tabGroup.getSwitchType();
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.DIV, null);
    writer.writeIdAttribute(clientId);
    writer.writeClassAttribute(Classes.create(tabGroup));
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, tabGroup);
    writer.writeStyleAttribute(new Style(facesContext, tabGroup));
    writer.writeAttribute(HtmlAttributes.SWITCHTYPE, switchType, false);

    writer.startElement(HtmlElements.INPUT, null);
    writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
    writer.writeAttribute(HtmlAttributes.VALUE, activeIndex);
    writer.writeNameAttribute(hiddenId);
    writer.writeIdAttribute(hiddenId);
    writer.endElement(HtmlElements.INPUT);

    encodeHeader(facesContext, writer, tabGroup, activeIndex);

    int index = 0;
    for (UIComponent tab : (List<UIComponent>) tabGroup.getChildren()) {
      if (tab instanceof UITab) {
        if (tab.isRendered() && (UITabGroup.SWITCH_TYPE_CLIENT.equals(switchType) || index == activeIndex)) {
          encodeContent(writer, facesContext, (UITab) tab, index);
        }
        index++;
View Full Code Here

  }

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {

    UITabGroup tabGroup = (UITabGroup) uiComponent;

    int activeIndex = ensureRenderedActiveIndex(facesContext, tabGroup);

    final String clientId = tabGroup.getClientId(facesContext);
    final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;
    final String switchType = tabGroup.getSwitchType();
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.DIV, null);
    writer.writeIdAttribute(clientId);
    writer.writeClassAttribute(Classes.create(tabGroup));
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, tabGroup);
    writer.writeStyleAttribute(new Style(facesContext, tabGroup));
    writer.writeAttribute(HtmlAttributes.SWITCHTYPE, switchType, false);

    writer.startElement(HtmlElements.INPUT, null);
    writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
    writer.writeAttribute(HtmlAttributes.VALUE, activeIndex);
    writer.writeNameAttribute(hiddenId);
    writer.writeIdAttribute(hiddenId);
    writer.endElement(HtmlElements.INPUT);

    encodeHeader(facesContext, writer, tabGroup, activeIndex);

    int index = 0;
    for (UIComponent tab : tabGroup.getChildren()) {
      if (tab instanceof UITab) {
        if (tab.isRendered() && (UITabGroup.SWITCH_TYPE_CLIENT.equals(switchType) || index == activeIndex)) {
          encodeContent(writer, facesContext, (UITab) tab, index);
        }
        index++;
View Full Code Here

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


    UITabGroup component = (UITabGroup) uiComponent;

    HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, component);

    String image1x1
        = ResourceManagerUtil.getImageWithPath(facesContext, "image/1x1.gif");

    UIPanel[] tabs = component.getTabs();
    layoutTabs(facesContext, component, tabs);

    final int activeIndex = component.getActiveIndex();

    final String clientId = component.getClientId(facesContext);
    final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;

    final String switchType = component.getSwitchType();

    UIPage page = ComponentUtil.findPage(component);
    final String[] scripts = new String[]{
        "script/tab.js",
        "script/tabgroup.js"
    };
    for (String script : scripts) {
      page.getScriptFiles().add(script);
    }
    if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
      HtmlRendererUtil.writeScriptLoader(facesContext, scripts, new String[0]);
    }


    TobagoResponseWriter writer
        = (TobagoResponseWriter) facesContext.getResponseWriter();

    writer.startElement(HtmlConstants.INPUT, null);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", null);
    writer.writeAttribute(HtmlAttributes.VALUE, Integer.toString(activeIndex), null);
    writer.writeNameAttribute(hiddenId);
    writer.writeIdAttribute(hiddenId);
    writer.endElement(HtmlConstants.INPUT);

    // if a outer uiPage is presend, the virtual tab will go over all
    // tabs and render it as they are selected, and it will
    // selected with stylesheet.

    for (int virtualTab = 0; virtualTab < tabs.length; virtualTab++) {

      if (SWITCH_TYPE_CLIENT.equals(switchType) || virtualTab == activeIndex) {

        if (virtualTab != activeIndex) {
          HtmlRendererUtil.replaceStyleAttribute(component, "display", "none");
        } else {
          HtmlRendererUtil.removeStyleAttribute(component, "display");
        }

        writer.startElement(HtmlConstants.DIV, null);
        writer.writeComment("empty div fix problem with mozilla and fieldset");
        writer.endElement(HtmlConstants.DIV);

        writer.startElement(HtmlConstants.DIV, null);
        writer.writeIdAttribute(clientId);
        renderTabGroupView(facesContext, writer, component, virtualTab,
            (HtmlStyleMap) component.getAttributes().get(ATTR_STYLE),
            switchType, image1x1);
        writer.endElement(HtmlConstants.DIV);

        if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()
            && SWITCH_TYPE_RELOAD_TAB.equals(switchType)) {
View Full Code Here

        ResourceManagerUtil.getImageWithPath(context, "image/1x1.gif"));
    context.responseComplete();
  }

  public int getFixedHeight(FacesContext facesContext, UIComponent uiComponent) {
    UITabGroup component = (UITabGroup) uiComponent;
    int height =
        ComponentUtil.getIntAttribute(component, ATTR_HEIGHT, -1);

    int fixedHeight;
    if (height != -1) {
      fixedHeight = height;
    } else {
      UIPanel[] tabs = component.getTabs();
      fixedHeight = 0;
      for (int i = 0; i < tabs.length; i++) {
        UIPanel tab = tabs[i];
        RendererBase renderer = ComponentUtil.getRenderer(facesContext, tab);
        fixedHeight
View Full Code Here

  }

  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final UITabGroup component = (UITabGroup) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    if (actionListener != null) {
      component.addActionListener(new javax.faces.event.MethodExpressionActionListener(actionListener));
    }
    if (markup != null) {
      if (!markup.isLiteralText()) {
        component.setValueExpression("markup", markup);
      } else {
        component.setMarkup(org.apache.myfaces.tobago.context.Markup.valueOf(markup.getExpressionString()));
      }
    }
    if (action != null) {
      component.setActionExpression(action);
    }
    if (showNavigationBar != null) {
      if (!showNavigationBar.isLiteralText()) {
        component.setValueExpression("showNavigationBar", showNavigationBar);
      } else {
        component.setShowNavigationBar(Boolean.parseBoolean(showNavigationBar.getExpressionString()));
      }
    }
    if (tabChangeListener != null) {
      component.addTabChangeListener(new org.apache.myfaces.tobago.event.MethodExpressionTabChangeListener(tabChangeListener));
    }
    if (selectedIndex != null) {
      if (!selectedIndex.isLiteralText()) {
        component.setValueExpression("selectedIndex", selectedIndex);
      } else {
        component.setSelectedIndex(Integer.parseInt(selectedIndex.getExpressionString()));
      }
    }
    if (switchType != null) {
      component.setValueExpression("switchType", switchType);
    }

    if (immediate != null) {
      if (!immediate.isLiteralText()) {
        component.setValueExpression("immediate", immediate);
      } else {
        component.setImmediate(Boolean.parseBoolean(immediate.getExpressionString()));
      }
    }
    if (renderedPartially != null) {
      if (!renderedPartially.isLiteralText()) {
        component.setValueExpression("renderedPartially", renderedPartially);
      } else {
        component.setRenderedPartially(splitList(renderedPartially.getExpressionString()));
      }
    }
  }
View Full Code Here

  }

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {

    UITabGroup tabGroup = (UITabGroup) uiComponent;

    int activeIndex = ensureRenderedActiveIndex(facesContext, tabGroup);

    final String clientId = tabGroup.getClientId(facesContext);
    final String hiddenId = clientId + TabGroupRenderer.ACTIVE_INDEX_POSTFIX;
    final String switchType = tabGroup.getSwitchType();
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.DIV, null);
    writer.writeIdAttribute(clientId);
    writer.writeClassAttribute(Classes.create(tabGroup));
    writer.writeStyleAttribute(new Style(facesContext, tabGroup));
    writer.writeAttribute(HtmlAttributes.SWITCHTYPE, switchType, false);

    writer.startElement(HtmlElements.INPUT, null);
    writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
    writer.writeAttribute(HtmlAttributes.VALUE, activeIndex);
    writer.writeNameAttribute(hiddenId);
    writer.writeIdAttribute(hiddenId);
    writer.endElement(HtmlElements.INPUT);

    encodeHeader(facesContext, writer, tabGroup, activeIndex);

    int index = 0;
    for (UIComponent tab : (List<UIComponent>) tabGroup.getChildren()) {
      if (tab instanceof UITab) {
        if (tab.isRendered() && (UITabGroup.SWITCH_TYPE_CLIENT.equals(switchType) || index == activeIndex)) {
          encodeContent(writer, facesContext, (UITab) tab, index);
        }
        index++;
View Full Code Here

TOP

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

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.