Page 1 of 1

Bug: TabMenu not allowing p:repeat

Posted: 28 Dec 2016, 17:10
by Melloware
I have the following where I want to dynamically create menu items for timezones using <p:repeat>

Code: Select all

<pa:menu widgetVar="customize_menu">
   <p:submenu id="mnuTimezone" label="#{appmsg['customize.timezone']}" icon="fa fa-fw fa-clock-o">
      <p:repeat value="#{availableTimezones}" var="timezone">
         <p:menuitem value="#{timezone.label}" icon="fa fa-fw fa-clock-o"  actionListener="#{applicationUser.setTimezone(timezone.value)}"          ajax="false" />
      </p:repeat>
    </p:submenu>
...
And the Menu blows up with this stack trace:

Code: Select all

java.lang.ClassCastException: org.primefaces.component.repeat.UIRepeat cannot be cast to org.primefaces.model.menu.MenuElement
	at org.primefaces.atlantis.component.MenuRenderer.encodeElements(MenuRenderer.java:51)
	at org.primefaces.atlantis.component.MenuRenderer.encodeSubmenu(MenuRenderer.java:129)
	at org.primefaces.atlantis.component.MenuRenderer.encodeElement(MenuRenderer.java:89)
	at org.primefaces.atlantis.component.MenuRenderer.encodeElements(MenuRenderer.java:51)
	at org.primefaces.atlantis.component.MenuRenderer.encodeMarkup(MenuRenderer.java:41)
	at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:114)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
	at org.primefaces.atlantis.component.TabMenuRenderer.encodeEnd(TabMenuRenderer.java:83)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)

Re: Bug: TabMenu not allowing p:repeat

Posted: 02 Jan 2017, 09:48
by aragorn
<pa:menu>, <pa:tabMenu> or <pa:tab> is not a PrimeFaces component. They are special components created for atlantis. Therefore, p:repeat is not supported by pa:menu. Maybe, you can use model attribute of pa:menu to create dynamic menu.