I have faced a small bug. You said recently p:menuitem in p:menubar can have p:commandLink inside. Well, it works. Now I use p:menuitem in p:breadCrumb. But in this case we can not put p:commandLink as child component of p:menuitem. For me p:menuitem either be able or not be able to contain children components (like p:commandLink) - independent of its parent component (which it's included in).
I have looked into the source code. MenuItem doesn't have own renderer. In MenubarRenderer you do
Code: Select all
private void encodeMenuItem(FacesContext facesContext, MenuItem menuItem) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
if(menuItem.getChildCount() > 0) {
renderChildren(facesContext, menuItem); // !!!!! RIGHT !!!!!
}
else {
String menuitemStyleClass = .....;
writer.startElement("a", null);
writer.writeAttribute("class", menuitemStyleClass, null);
writer.writeAttribute("href", menuItem.getUrl(), null);
if(menuItem.getStyle() != null) writer.writeAttribute("style", menuItem.getStyle(), null);
if(menuItem.getTarget() != null) writer.writeAttribute("target", menuItem.getTarget(), null);
if(menuItem.getOnclick() != null) writer.writeAttribute("onclick", menuItem.getOnclick(), null);
if(menuItem.getLabel() != null) writer.write(menuItem.getLabel());
if(menuItem.getHelpText() != null) {
writer.startElement("em", null);
writer.writeAttribute("class", "helptext", null);
writer.write(menuItem.getHelpText());
writer.endElement("em");
}
writer.endElement("a");
}
}
Code: Select all
for (Iterator<UIComponent> iterator = breadCrumb.getChildren().iterator(); iterator.hasNext();) {
UIComponent child = iterator.next();
if(child.isRendered() && child instanceof MenuItem) {
MenuItem menuItem = (MenuItem) child;
writer.startElement("li", null);
writer.startElement("a", null);
writer.writeAttribute("href", menuItem.getUrl(), null);
if(menuItem.getTarget() != null) writer.writeAttribute("target", menuItem.getTarget(), null);
if(menuItem.getOnclick() != null) writer.writeAttribute("onclick", menuItem.getOnclick(), null);
if(menuItem.getLabel() != null) writer.write(menuItem.getLabel());
writer.endElement("a");
writer.endElement("li");
}
}
Thanks in advance!
Oleg.