We have an issue with the h:commandLink inside t:dataTable, which are not working anymore after upgrading to JSF 2.1 (Mojarra 2.1.28), Tomahawk20-1.1.14, PrimeFaces 5.2. (The old stack was JSF 1.2, Tomahawk-1.1.10, RichFaces 3.4). The issue is action & actionListener methods do not get invoked at all. It submits the form; but remders the same page again. Basically it's a custom component for context menu - it's a row specific context menu, that is shown after an icon in each row is clicked by user. The menu items are generated programmatically as below -
private List<HtmlCommandLink> createMenuItems(FacesContext facesContext) {
List<HtmlCommandLink> menuItems = new ArrayList<HtmlCommandLink>();
...
ValueExpression actionsVE = extractActionsValueExpression();
Set<ActionDefinition> menuOptions = (Set<ActionDefinition>)actionsVE.getValue(facesContext.getELContext());
...
for (ActionDefinition selectItem : menuOptions) {
HtmlCommandLink menuItem = new HtmlCommandLink();
menuItem.setValue(selectItem.getLabel());
menuItem.addActionListener(new SetPropertyActionListener());
String actionEl = String.format("#{%s}", selectItem.getActionValue());
menuItem.setActionExpression(createMenuItemActionMethodExpression(facesContext, actionEl));
menuItems.add(menuItem);
}
...
return menuItems;
}
Then this list is added to the menu panelGroup, in encodeBegin() method -
panelGroup = new HtmlPanelGroup();
getChildren().add(panelGroup);
icon = createIcon(panelGroup);
panelGroup.getChildren().add(icon);
...
menu = new HtmlPanelGroup();
...
menu.getChildren().addAll(createMenuItems(facesContext));
menu.setId(generateId());
menu.setOnmouseover("clear_popup();");
menu.setOnmouseout("close_timer();");
panelGroup.getChildren().add(menu);
...
icon.setOnmousedown("open_popup('" + menu.getClientId(facesContext) + "', this);");
icon.setOnmouseout("close_popup();");
...
I have checked Stackoverflow for similar issues and all relevant pre-requisites have been verified (there is one single form; the list is created in PostConstruct). Also have checked BalusC's this post - commandButton/commandLink/ajax action/listener method not invoked or input value not updated; and have ensure all points mentioned.
Here is the generated HTML for reference -
<a href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('form'),{'form:myDataTable:0:j_id159':'form:myDataTable:0:j_id159'},'');}return false" class="context-menu-row">Create Letter</a>
(Also, this is old HTML on JSF 1.2 -
<a class="context-menu-row" onclick="mojarra.jsfcljs(document.getElementById('form'),{'form:myDataTable:0:j_id126':'form:myDataTable:0:j_id126'},'');return false" href="#">Create Letter</a>
).
Any help / pointers to resolve it will be appreciated.
Note: 1. This custom context menu component is part of a larger framework, and so simply rewriting it using p:contextMenu is not a viable option.