Menubar with menuitems and submenus

UI Components for JSF
Post Reply
davideagen
Posts: 13
Joined: 16 May 2009, 05:34

17 May 2009, 17:06

I'd like to have a <p:menubar with <p:submenu for some elements and p:menuitem for other entries. For instance, I want the user to be able to just click on Logout and be taken to the logout page. I don't want them to have to select Log Out from the top menu and then Log Out again from a submenu.

Something like this:

Code: Select all

<p:menubar >
	<p:menuitem label="Home" url="/home.jsf"/>
			
	<p:submenu title="Submenu 1">
		<p:menuitem label="Item A" 
			url="/a.jsf"/>
		<p:menuitem label="Item B" 
			url="/b.jsf"/>
	</p:submenu>

	<p:submenu title="Submenu 2">
		<p:menuitem label="Item C" url="/c.jsf"/>
		<p:menuitem label="Item D" url="/d.jsf"/>
	</p:submenu>
			
	<p:menuitem label="Log Out" url="/logout.jsf"/>
</p:menubar>
But, when I do that I get this error:
java.lang.ClassCastException - org.primefaces.ui.component.menuitem.MenuItem cannot be cast to org.primefaces.ui.component.submenu.Submenu
Is it possible to mix the two or must all elements of a menubar be submenus?

-Dave

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

17 May 2009, 20:52

MenuBar always requires submenus so the menu you've defined will not work. For now there's no way to define urls for submenu's with no menuitem.

See this issue: http://code.google.com/p/primefaces/issues/detail?id=90

MenuBar will be improved in the upcoming 0.9.0 release. Thanks.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 May 2009, 00:49

Ok, changes and some improvements are checked in. Now you can use it like;

Code: Select all

<p:menubar >
   <p:submenu label="Home" url="/home.jsf"/>
         
   <p:submenu label="Submenu 1">
      <p:menuitem label="Item A" url="/a.jsf"/>
      <p:menuitem label="Item B" url="/b.jsf"/>
   </p:submenu>

   <p:submenu label="Submenu 2">
      <p:menuitem label="Item C" url="/c.jsf"/>
      <p:menuitem label="Item D" url="/d.jsf"/>
   </p:submenu>
         
   <p:submenu label="Log Out" url="/logout.jsf"/>
</p:menubar>
Note that submenu title attribute is changed to label. Also url attribute is added for submenus without menuitems. You can grab a 0.9.0-snapshot from prime repo to get these changes.

davideagen
Posts: 13
Joined: 16 May 2009, 05:34

18 May 2009, 23:47

I tried the snapshot 0.9.0 but get this error:

/includes/menu.jsp(4,3) PWC6339: Cannot find a setter method for the attribute label of the tag handler org.primefaces.ui.component.submenu.SubmenuTag

Caused by:
org.apache.jasper.JasperException - /includes/menu.jsp(4,3) PWC6339: Cannot find a setter method for the attribute label of the tag handler org.primefaces.ui.component.submenu.SubmenuTag

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 May 2009, 00:59

Well, just checked again, it's definitely there. Redeploying your app, or cleaning server cache should fix it.

You may want to try with the latest build as well: http://repository.prime.com.tr/org/prim ... -SNAPSHOT/

davideagen
Posts: 13
Joined: 16 May 2009, 05:34

19 May 2009, 02:47

I grabbed the latest snapshot and redeployed. Either this one fixed something or I had something cached. Regardless, it's working now.

Thanks!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 May 2009, 10:51

Great, btw helpText and item icon features are also ready with that release. See demo: http://www.rehberharitam.com/prime-show ... enubar.jsf

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 53 guests