Skip to content

Commit

Permalink
Merge pull request #1456 from sudheerj/master
Browse files Browse the repository at this point in the history
  • Loading branch information
tandraschko committed Jun 11, 2016
2 parents 2ca5200 + b6274df commit faf9c83
Showing 1 changed file with 15 additions and 3 deletions.
Expand Up @@ -17,9 +17,11 @@

import java.io.IOException;
import java.util.List;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

import org.primefaces.component.menu.AbstractMenu;
import org.primefaces.component.menu.BaseMenuRenderer;
import org.primefaces.model.menu.MenuElement;
Expand All @@ -41,9 +43,9 @@ protected void encodeScript(FacesContext context, AbstractMenu abstractMenu) thr
protected void encodeMarkup(FacesContext context, AbstractMenu component) throws IOException {
ResponseWriter writer = context.getResponseWriter();
TabMenu menu = (TabMenu) component;
String clientId = menu.getClientId(context);
String styleClass = menu.getStyleClass();
styleClass = styleClass == null ? TabMenu.CONTAINER_CLASS : TabMenu.CONTAINER_CLASS + " " + styleClass;
String clientId = menu.getClientId(context);
String styleClass = menu.getStyleClass();
styleClass = styleClass == null ? TabMenu.CONTAINER_CLASS : TabMenu.CONTAINER_CLASS + " " + styleClass;
int activeIndex = menu.getActiveIndex();
List<MenuElement> elements = menu.getElements();

Expand Down Expand Up @@ -75,18 +77,28 @@ protected void encodeMarkup(FacesContext context, AbstractMenu component) throws

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

if(containerStyleClass != null) {
containerClass = containerClass + " " + containerStyleClass;
}

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

if(containerStyle != null) {
writer.writeAttribute("style", containerStyle, null);
}

encodeMenuItem(context, menu, item);

writer.endElement("li");
Expand Down

0 comments on commit faf9c83

Please sign in to comment.