Skip to content

Instantly share code, notes, and snippets.

@thiagofa
Created February 26, 2016 16:59
Show Gist options
  • Save thiagofa/d03341104427ffe39140 to your computer and use it in GitHub Desktop.
Save thiagofa/d03341104427ffe39140 to your computer and use it in GitHub Desktop.
Como fazer com que o menu lateral do layout da AlgaWorks fique com o item selecionado, ao navegar para outra página?
<li class="#{menuBean.getItemCssClass('PesquisaClientes')}">
<h:link><i class="fa fa-fw fa-user"></i>Clientes</h:link>
</li>
<li class="#{menuBean.getItemCssClass('Relatorios')}">
<h:link><i class="fa fa-fw fa-file-text"></i>Relatórios</h:link>
</li>
@RequestScoped
@ManagedBean
public class MenuBean {
public String getItemCssClass(String viewId) {
FacesContext context = FacesContext.getCurrentInstance();
String currentViewId = context.getViewRoot().getViewId();
viewId = "/" + viewId + ".xhtml";
return currentViewId.equals(viewId) ? "is-selected" : null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment