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}"/>
</p:toolbarGroup>
</p:toolbar>
When I take a look at Primefaces Showcase my p:commandButton need
actionListener="#{myBean.myActionMethod}"
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}"/>
</p:remoteCommand>
In MyBean.java
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?
Try this
Bean.java
@ManagedBean
@ViewScoped
public class Bean {
public String testButtonAction() {
System.out.println("testButtonAction invoked");
return "anotherPage.xhtml";
}
public void testButtonActionListener(ActionEvent event) {
System.out.println("testButtonActionListener invoked");
}
}
page.xhtml
<p:toolbar>
<p:toolbarGroup>
<p:commandButton action="#{bean.testButtonAction}"/>
<p:commandButton actionListener="#{bean.testButtonActionListener}"/>
</p:toolbarGroup>
</p:toolbar>