Primefaces: commandButton ajax="false" は p:dataExporter と p:fileDownload で動作しません。
knowledge-article-header-disclaimer-how-to
knowledge-article-header-disclaimer
legacy-article
learn-legacy-article-disclaimer-text
問題
- Primefaces
<p:commandButton ajax="false" />
を p:dataExporter
と p:fileDownload
で使用すると、ページが正しくレンダリングされず、視覚的な問題が発生します。
環境
解像度
-
p:dataExporter
と p:fileDownload
をポートレットで使用する場合、それぞれ別のフォームに入れるのがベストプラクティスです。 非Ajax UICommand
コンポーネントが p:dataExporter
または p:fileDownload
を持つフォームに含まれている場合、JSFポートレットで失敗します。
下のようなものです:
<h:body>
<h:form>
<p:commandButton value="commandButton ajax=false doesn't work" ajax="false" />
</h:form>
<h:form>
<h1>not working example - contains PrimeFaces dataExporter</h1>
<p:dataTable id="tabledata" var="r" value="#{controller.tabledata}">
<h:outputText value="this is the header where the button was" />
<p:commandButton ajax="false" value="csv export">
<p:dataExporter target="tabledata" type="csv" fileName="tabledata" />
</p:commandButton>
</f:facet>
<p:column>
<h:outputText value="#{r}" />
</p:column>
</p:dataTable>
<p:commandLink value="switch to working example" action="working" />
</h:form>
なるように変更するものとする:
<h:body>
<h:form>
<p:commandButton value="commandButton ajax=false doesn't work" ajax="false" />
<h1>not working example - contains PrimeFaces dataExporter</h1>
<p:dataTable id="tabledata" var="r" value="#{controller.tabledata}">
<h:outputText value="this is the header where the button was" />
<p:commandButton ajax="false" value="csv export">
<p:dataExporter target="tabledata" type="csv" fileName="tabledata" />
</p:commandButton>
</f:facet>
<p:column>
<h:outputText value="#{r}" />
</p:column>
</p:dataTable>
<p:commandLink value="switch to working example" action="working" />
</h:form>
did-this-article-resolve-your-issue