I am trying to mimic the PrimeFaces Dialog example. For some reason that I am not able to find, my PrimeFaces button does not seem to call the required managed bean method:
<h:form>
<p:commandButton value="Open" icon="ui-icon-extlink" actionListener="#{myController.createDialog()}" />
</h:form>
Managed bean:
@Named(value = "myController")
@ViewScoped
public class MyController implements Serializable {
public void createDialog() {
System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%");
...
The print statement is never executed, like if the Listener was not working. When I click the button, no response is given. No backend error, no JS error, nothing. I only see that some request is done because I log when a user passes the authorization layer. So something happens but seems to fail silently.
What I have tried:
- Move the button to other places in the page
Use an id:
<p:commandButton id="ex" value="Open" icon="ui-icon-extlink" actionListener="#{myController.createDialog()}" /> <h:message for="ex" />
Remove the
ViewScoped
Require a
javax.faces.event.ActionEvent
in the methodpublic void createDialog(ActionEvent event) { System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%");
Change the method signature
action="#{myController.createDialog(5)}"
and
public void createDialog(int s) { System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%");
I even tried to create a
WEB-INF/faces-config.xml
(which I would prefer not to, and according to PrimeFaces documentation I do not need it) with:<?xml version='1.0' encoding='UTF-8'?> <faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"> <application> <action-listener>org.primefaces.application.DialogActionListener</action-listener> <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler> <view-handler>org.primefaces.application.DialogViewHandler</view-handler> </application> <lifecycle> <phase-listener>org.primefaces.component.lifecycle.LifecyclePhaseListener</phase-listener> </lifecycle>
Other answers I have checked are: 1, 2, 3, 4, 5, 6
Apparently the use of actionListener
s in PrimeFaces is not as correct as it should be... Is there another way to use PrimeFaces components?