protected void encodeElements(FacesContext context, Menu menu, List<MenuElement> elements) throws IOException{
ResponseWriter writer = context.getResponseWriter();
int elementCount = elements.size();
for (int i = 0; i < elementCount; i++) {
MenuElement element = elements.get(i);
if(element.isRendered()) {
if(element instanceof MenuItem) {
writer.startElement("li", null);
encodeMenuItem(context, menu, (MenuItem) element);
writer.endElement("li");
}