I have a Primefaces project with the following xhtml file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition>
<h:form>
<p:dataTable id="parameters" var="parameter" value="#{devTestController.parameters}"
editable="true" editMode="cell" widgetVar="parameterTable"
selection="#{devTestController.selectedRow}" selectionMode="single"
rowKey="#{parameter}">
<f:facet name="header">
Parameters
</f:facet>
<p:column headerText="Parameter Name" style="width:30%">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{parameter.label}" /></f:facet>
<f:facet name="input"><p:inputText id="parameterNameInput" value="#{parameter.label}" style="width:96%"/></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Parameter Value" style="width:60%">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{parameter.value}" /></f:facet>
<f:facet name="input"><p:inputText value="#{parameter.value}" style="width:96%" label="Parameter Value"/></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Action" style="width:10%">
<p:commandButton value="Button in table" action="#{devTestController.doAction()}"/>
</p:column>
</p:dataTable>
<p:commandButton value="Button outside table" action="#{devTestController.doAction()}"/>
</h:form>
<p:commandButton value="Button outside form" action="#{devTestController.doAction()}"/>
</ui:composition>
</h:body>
</html>
Here I have 3 commandButtons (p:commandButton). One is inside the dataTable (iterating component), one is outside the dataTable and one is outside h:form. Surprisingly, the only one working is the one outside the h:form (the last one). I've been searching the internet for 5 hours and already tried many things. I don't understand why this is happening. I read many posts regarding similar problems, but none of them solved my case. A pretty good one is this by BalusC. I have read all the cases and I can't find an answer. First I suspected that I have nested multiple UIForm components in each other (case 2) and I searched in the original xhtml file that includes the one above, but this is not the case. I have no other h:form tags in my code except this one. After all, if I completely remove the h:form tag, then no commandButton works and I also get the "The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within h:form" warning. What could go wrong here?