Menubar - any way to make menubar "submenu" direct to page?

UI Components for JSF
Post Reply
burferd
Posts: 234
Joined: 01 May 2010, 16:15

04 May 2010, 05:23

I am new to PrimeFaces and am trying to put together a menubar where the first item on the menubar is a link to "Home".
The doucmentation implies that you can make a menuitem perform navigation, although I have not been able to do that.
Assuming I can make the menuitem navigation to a page work, it looks the only way could make a menu bar that navigates to a "home" page would be to have a submenu with a child menuitem. Like this:

Code: Select all

<p:menubar>
    <p:submenu label="Home" >
        <p:menuitem label="Home"  action="homePage.xhtml"  ></p:menuitem>
    </p:submenu >
 </p:menubar >
BTW, I can't get the menuitem in this example to navigate for some reason - obviously I am doing something wrong, but don't know what, maybe syntax?

What I would like to do is to be able to click on an item in the menubar to do the navigation without having to expand a submenu with a single item.
I'm looking for something like this:

Code: Select all

<p:menubar>
    <p:menuitem label="Home"  action="homePage.xhtml"  />
 </p:menubar >
I can't do this because I get a page error that says:
org.primefaces.component.menuitem.MenuItem cannot be cast to org.primefaces.component.submenu.Submenu

This is related question:
- How do I make a p:menuitem navigate to a page? The first sample code I inserted, does not work, I do not navigate to the homePage.xhtml when the I click on the Home menuitem.
I;m working in NetBeans 6.9, JSF2.0, Glsssfish 3.0.1 using facelets.

Could anyone post a menu example (or direct me to one) that works in my development environment?
I have tried to mimic the showcase examples and examples in the user's guide to no avail.

So, I have 2 questions:
1) Can I create a menubar item that allows direct navigation to another page without requiring a submenu with a single menuitem child?
2) How do I make a menuitem child navigate to a page in the project?

Thanks for any help.
Using PrimeFaces 3.4, Mojarra 2.1.6, Glassfish 3.1.2, NetBerans 7.2, Hibernate 3.2.5 (sometimes)
Windows 7.

alfonx
Posts: 93
Joined: 15 Mar 2010, 18:50
Contact:

11 May 2010, 00:33

In the showcase you can find the following code:

Code: Select all

     <p:menubar>
...
         <p:submenu>  
             <f:facet name="label">  
                 <p:menuitem value="Quit" url="http://www.primefaces.org" />  
             </f:facet>  
         </p:submenu>  
     </p:menubar>   
As you can see, the menuItem on the top level is inserted as a facet.

Steve
Greetings,
Steve

burferd
Posts: 234
Joined: 01 May 2010, 16:15

12 May 2010, 04:21

Thanks for the feedback.
I'll try that.
Using PrimeFaces 3.4, Mojarra 2.1.6, Glassfish 3.1.2, NetBerans 7.2, Hibernate 3.2.5 (sometimes)
Windows 7.

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

13 May 2010, 01:15

Yes for top level you need the label facet.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: basshamut and 26 guests