Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabMenuRenderer does not support containerStyle or containerStyleClass #1450

Closed
alainpannetier opened this issue May 25, 2016 · 4 comments
Closed
Assignees
Labels
enhancement Additional functionality to current component
Milestone

Comments

@alainpannetier
Copy link

org.primefaces.component.tabmenu.TabMenuRenderer does not support containerStyle and containerStyleClass
Proposed patch:

```

protected void encodeItem(FacesContext context, TabMenu menu, MenuItem item, boolean active) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    String containerClass = active ? TabMenu.ACTIVE_TAB_HEADER_CLASS : TabMenu.INACTIVE_TAB_HEADER_CLASS;
    if(item.getIcon() != null) {
        containerClass += " ui-tabmenuitem-hasicon";
    }

    // patch start
    String containerStyleClass = item.getContainerStyleClass();
    if(containerStyleClass != null) {
        containerClass = containerClass + " " + containerStyleClass;
    }
    // patch end

    //header container
    writer.startElement("li", null);

    writer.writeAttribute("class", containerClass, null);
    writer.writeAttribute("role", "tab", null);
    writer.writeAttribute("aria-expanded", String.valueOf(active), null);
    writer.writeAttribute("aria-selected", String.valueOf(active), null);

    // patch start
    String containerStyle = item.getContainerStyle();
    if(containerStyle != null) {
        writer.writeAttribute("style", containerStyle, null);
    }
    // patch end

    encodeMenuItem(context, menu, item);

    writer.endElement("li");
}
@Rapster
Copy link
Member

Rapster commented May 25, 2016

Either you have a style or a styleClass but not both, and I would suggest styleClass in that case. Anyway, I'm not sure about the relevance about these two options, but what about override .ui-tabmenu-nav .ui-tabmenuitem?

@alainpannetier
Copy link
Author

Be thanked for your wise insights... I have a few comments though.

  • There are plenty of cases when you might want both style and classes (like cascade priority). So I can have both if I so wish.
  • I'm talking about containerStyle and containerStyleClass (not style and styleClass), the formers apply to the <li>, the latters to the inner <a> element.
  • I'm not discussing the respective merits of css vs embedded style, this has been more than amply debated already and you and I probably have our own opinion by now. Instead, I'm proposing a patch related to a couple of advertised but not implemented feature. So I'm implementing both.
  • Overriding classes is definitely not what I want. For the record I want all tabs on the left except the "Help" tab on the right. Hence containerStyle="float:right".

@sudheerj
Copy link
Contributor

Actually these two attributes(containerStyle,containerStyleClass) available for menu,tiredmen,panelmenu etc menu components.It can be added to TabMenu component as well.

@sudheerj
Copy link
Contributor

PR is created here #1456

@tandraschko tandraschko added the enhancement Additional functionality to current component label Jun 11, 2016
@tandraschko tandraschko added this to the 6.1 milestone Jun 11, 2016
@tandraschko tandraschko self-assigned this Jun 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additional functionality to current component
Projects
None yet
Development

No branches or pull requests

4 participants