This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSF and the fly likes PrimeFaces dynamic cotextmenu and actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "PrimeFaces dynamic cotextmenu and actions" Watch "PrimeFaces dynamic cotextmenu and actions" New topic
Author

PrimeFaces dynamic cotextmenu and actions

Gert Jan Kruizinga
Greenhorn

Joined: May 09, 2010
Posts: 16
Hi all,


I am working on a application using the context menu in the datatable from PrimeFaces 3.0.M4

If i define the context menu in the xhtml i can use the following:


But i need to generate the context menu from the backingbean, i use the following:


But MenuItem#addActionListener takes a class impementing ActionListener as parameter. How can i assign the dynamically generated menuItem to my simple method #{agenda.doEditButton} like i do from the xhtml?



Gert Jan Kruizinga.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

I don't think a direct linkage is possible there. More likely, you're going to have to build up some EL infrastructure and bind the actions as EL expressions just as you did in the raw XML version of the control definition. A bit ugly, but not an uncommon practice.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gert Jan Kruizinga
Greenhorn

Joined: May 09, 2010
Posts: 16
Thank you for your answer Tim but i'm not sure that i understand it.

All i want to do is call the public method "doEditButton()" from my bean named "agenda" and you tell me that that is not (easely) possible from a dynamicly generated menu while it is common practice if i do it from xhtml?

I used the #{a.b} format to illustrate that i want to call that function, like i do in xhtml. does not work.
 
 
subject: PrimeFaces dynamic cotextmenu and actions