The form is posted anyway, but the bean method referenced by the button action parameter only gets triggered if I don't put the form inside a ui:fragment
. I'm using Mojarra 2.2.5 on Tomcat 6.0.41.
(It also happens if I use primefaces' p:commandButton
instead)
view.xhtml?edit=true
:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:metadata>
<f:viewParam name="edit" id="edit" />
<ui:param name="editMode" value="#{not empty edit and edit eq 'true' and saveBean.contentEditable}" />
</f:metadata>
<h:head>
<title>Page title</title>
</h:head>
<h:body>
<ui:fragment rendered="#{editMode}">
</ui:fragment>
<h:form id="saveForm">
<h:commandButton
id="btn2"
type="submit"
value="Triggers POST but no action"
action="#{saveBean.saveAllAction}"
/>
</h:form>
</h:body>
</html>
Backing bean:
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedBean(name = "saveBean")
@ViewScoped
public class TestBean implements Serializable{
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(TestBean.class);
public String saveAllAction() {
log.info("Received save all command.");
return "success";
}
public TestBean() {}
public String getContentEditable() {
return contentEditable;
}
public void setContentEditable(String contentEditable) {
this.contentEditable = contentEditable;
}
private String contentEditable = "true";
}