menuitem action attribute?

UI Components for JSF
Post Reply
serge_rehem
Posts: 1
Joined: 04 Feb 2010, 20:45

04 Feb 2010, 21:05

Hi all,

I'm trying to use menubar / menuitem components, but I don't want to use explicit URL like this:

Code: Select all

<p:menubar>
    <p:submenu label="CRUDs">
        <p:menuitem label="Client" url="client_list.jsf"/>
    </p:submenu>
</p:menubar>
I'd like to send an action to a ManagedBean method, returning a navigation-rule string, like this:

ClientMB.java

Code: Select all

class ClientMB ... {   ...
   public String list() {
      loadClientList();
      return "client+list";
    }     ...
}
faces-config.xml

Code: Select all

	<navigation-rule>
		<navigation-case>
			<from-outcome>cliente_list</from-outcome>
			<to-view-id>/private/pages/cliente_list.xhtml</to-view-id>
		</navigation-case>
                ...
	</navigation-rule>
client_list.xhtml

Code: Select all

<p:menubar>
   <p:submenu label="CRUDs">
     <p:menuitem label="Client" url="#{clientMB.list}"/>
  </p:submenu>
</p:menubar>
I tryed it using url and binding attributes, but I've got an exception saying "javax.el.PropertyNotFoundException: /private/pages/client_list.xhtml @128,59 url="#{clientMB.list}": Property 'list' not found on type org.sample.ClientMB". Of course, It's NOT a property!

It would be nice if menuitem had an action attribute, like RichFaces:

Code: Select all

     <rich:menuItem submitMode="ajax" value="New"  action="#{ddmenu.doNew}" icon="/images/icons/create_doc.gif"/>
Does anybody know how to solve this problem?

Thanks
Serge Rehem
javabahia.org

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

05 Feb 2010, 10:28

Hi,

You can use p:commandLink inside of p:menuitem.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

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

05 Feb 2010, 12:31

menuitem is generic to contain other components;

Code: Select all

<p:menubar>
   <p:submenu label="CRUDs">
     <p:menuitem label="Client">
          <p:commandLink action="#{ddmenu.doNew}" ... ajax="true|false"/>
     </p:menuitem>
  </p:submenu>
</p:menubar>

javaone9
Posts: 317
Joined: 06 Nov 2012, 20:50

07 Nov 2012, 07:36

optimus.prime wrote:menuitem is generic to contain other components;

Code: Select all

<p:menubar>
   <p:submenu label="CRUDs">
     <p:menuitem label="Client">
          <p:commandLink action="#{ddmenu.doNew}" ... ajax="true|false"/>
     </p:menuitem>
  </p:submenu>
</p:menubar>
Can I use model as following?

<p:menubar model="#{bean.menuModel}" var="item">
<p:menuitem label="#{item.name}">
<p:commandLink action="#{item.doSomething}" ... ajax="true|false"/>
</p:menuitem>

<p:subMenu label="#{item.name}"/>
</p:menubar>

p:tree can iterating over treeNode. Menu should provide var, but I did not see it in tag doc.
For using menu model, how to add action to menuItems? different menu items take different actions.

Thanks for info.
Dave

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 65 guests