PrimeFaces 动态命令按钮和上下文菜单

PrimeFaces dinamic CommandButtons and ContextMenu

请帮助我解决 issue/question 如何为 CommandButtons 添加动态 ContextMenu(左键单击)的问题,这是通过 Java 动态添加的。命令按钮的数量是动态的(最少 50 个),但 ContextMenu 始终相同:

Column column = ...
ContextMenu contextmenu = ...

CommandButton button1 = new CommandButton();
//todo addContextMenu
CommandButton button2 = new CommandButton();
//todo addContextMenu
...
CommandButton button50 = new CommandButton();
//todo addContextMenu

column.getChildren().add(button1);
column.getChildren().add(button2);
...
column.getChildren().add(button50);

PS 我使用 Primefaces 5.3、Primefaces Extensions 4.0、Mojarra 2.2.5。提前致谢!

CommandButtons 通过左键单击激活它们的操作,因此您可能会寻找 MenuButtons,它有一个通过左键单击触发的菜单和一个箭头,显示动态菜单的可用性。

菜单的编程创建在 MenuView.java.

选项卡下的 Primefaces 菜单展示中进行了描述