Primefaces p:commandButton with action not called


I've got some some troubles with Primefaces 3.2 and JSF 2.1.

My Code like this:

<p:toolbar id="jeditortoolbar" styleClass="jeditortoolbar">
      <p:toolbarGroup align="left" height="25" style="height:25px">
        <p:commandButton type="button" title="#{msg.beenden}"/>
        <p:commandButton type="button" title="#{msg.neu}"/>

When I take a look at Primefaces Showcase my p:commandButton need


and my Bean need a Method like

public void myActionMethod(){}

I have a h:form around my p:toolbar tag!

My Bean is ViewScoped.

My Workaround is
In *.xhtml File

<p:commandButton type="button" title="#{msg.neu}" onclick="addNewEmptyFile()"/>
<p:remoteCommand name="addNewEmptyFile" update=":codeTabForm">
   <f:setPropertyActionListener value="#{true}" target="#{myBean.myEvent}"/>


private String myEvent;

public void setMyEvent(String value){ myActionMethod();}

This works for me but I think this is very dirty code.

Can everyone help me?

Best Solution

Try this

public class Bean {

    public String testButtonAction() {
        System.out.println("testButtonAction invoked");
        return "anotherPage.xhtml";

    public void testButtonActionListener(ActionEvent event) {
        System.out.println("testButtonActionListener invoked");



    <p:commandButton action="#{bean.testButtonAction}"/>
    <p:commandButton actionListener="#{bean.testButtonActionListener}"/>
Related Question