次の xhtml ファイルを含む Primefaces プロジェクトがあります。
<!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>
ここには 3 つのコマンド ボタン (p:commandButton) があります。1 つは dataTable (反復コンポーネント) の内側にあり、1 つは dataTable の外側にあり、もう 1 つは h:form の外側にあります。驚いたことに、機能しているのは h:form の外側にあるもの (最後のもの) だけです。私は 5 時間インターネットを検索してきましたが、すでに多くのことを試しました。なぜこれが起こっているのかわかりません。同様の問題に関する多くの投稿を読みましたが、どれも私のケースを解決しませんでした。かなり良いものはBalusCによるこれです. 私はすべてのケースを読みましたが、答えが見つかりません。最初に、複数の UIForm コンポーネントを互いに入れ子にしたのではないかと疑い (ケース 2)、上記のコンポーネントを含む元の xhtml ファイルを検索しましたが、そうではありません。私のコードには、これ以外の h:form タグはありません。結局のところ、h:form タグを完全に削除すると、commandButton が機能せず、「The form component needs to have a UIForm in its ancestry. Suggestion: enclose the required components within h:form」という警告も表示されます。ここで何が問題になる可能性がありますか?