我的代码就像de PF Showcase,但它不起作用......当我点击我的commandLink
时没有任何反应。有人可以帮帮我吗?我已经添加了Apache POI和iText。
<h:form id="form">
<p:commandButton value="Novo" icon="ui-icon-document"
actionListener="#{controleBean.novoReservatorio()}" process="@this"
update="dataTable reservatorio-dialog"
oncomplete="PF('reservatorioDialog').show()" class="botaoDataTable">
<p:resetInput target="reservatorio-dialog" />
</p:commandButton>
<p:commandButton icon="ui-icon-pencil" id="btnEditar" title="Editar"
disabled="#{controleBean.reservatorio == null}"
class="botaoDataTable" process="@this" update="dataTable :form"
oncomplete="PF('reservatorioDialog').show()">
<p:resetInput target="reservatorio-dialog" />
<f:setPropertyActionListener target="#{controleBean.reservatorio}"
value="#{controleBean.reservatorioSelecao}" />
</p:commandButton>
<p:commandButton icon="ui-icon-trash" id="btnExcluir"
title="Excluir" disabled="#{controleBean.reservatorio == null}"
class="botaoDataTable" action="#{controleBean.excluirReservatorio}"
process="@this" update="dataTable btnExcluir btnEditar" />
<p:dataTable var="r" value="#{controleBean.reservatorios}"
paginator="true" rows="30" id="dataTable"
emptyMessage="Nenhum Reservatorio Cadastrado"
paginatorPosition="bottom"
selection="#{controleBean.reservatorioSelecao}"
selectionMode="single" rowKey="#{r.idReservatorio}">
<p:ajax event="rowSelect"
update=":form:btnEditar :form:btnExcluir" />
<p:ajax event="rowUnselect"
update=":form:btnEditar :form:btnExcluir" />
<p:column headerText="Nome">
<h:outputText value="#{r.nomeReservatorio}" />
</p:column>
<p:column headerText="Capacidade (Lt)">
<h:outputText value="#{r.capacidadeReservatorio}" />
</p:column>
<p:column headerText="Tipo">
<h:outputText value="#{r.tipoReservatorio}" />
</p:column>
<p:column headerText="Observação">
<h:outputText value="#{r.obsReservatorio}" />
</p:column>
</p:dataTable>
<p:commandLink>
<p:graphicImage library="img" name="xlsx.png" width="32" title="Exportar para Excel"/>
<p:dataExporter type="xls" target="dataTable" fileName="Relatorio" />
</p:commandLink>
<h:commandLink>
<p:graphicImage library="img" name="pdf.png" width="37" title="Exportar para PDF"/>
<p:dataExporter type="pdf" target="dataTable" fileName="Relatorio"/>
</h:commandLink>
<p:commandButton value="Exportar para PDF" ajax="false">
<p:dataExporter type="pdf" target=":form:dataTable" fileName="dataTable" />
</p:commandButton>
<p:dialog header="Reservatório" widgetVar="reservatorioDialog"
id="reservatorio-dialog" resizable="false" modal="true"
closeOnEscape="true">
<p:messages style="font-size:70%;" />
<p:panelGrid styleClass="semBorda">
<p:row>
<p:column>
<h:outputLabel for="nomeReservatorio" value="* Nome: "
class="componentePF label" />
</p:column>
<p:column>
<p:inputText id="nomeReservatorio" required="true"
value="#{controleBean.reservatorio.nomeReservatorio}"
requiredMessage="É necessário atribuir um nome à reservatorio"
class="componentePF text" />
</p:column>
</p:row>
<p:row>
<p:column>
<h:outputLabel for="capacidadeReservatorio"
value="* Capacidade (Lt): " class="componentePF label" />
</p:column>
<p:column>
<p:spinner id="capacidadeReservatorio" size="30"
value="#{controleBean.reservatorio.capacidadeReservatorio}"
min="0" stepFactor="1" required="true"
requiredMessage="É necessário atribuir uma capacidade à reservatorio"
class="componentePF text" />
</p:column>
</p:row>
<p:row>
<p:column>
<h:outputLabel for="tipoReservatorio"
value="* Tipo de Reservatório: " class="componentePF label" />
</p:column>
<p:column>
<p:selectOneMenu id="tipoReservatorio" style="font-size:75% !important;"
value="#{controleBean.reservatorio.tipoReservatorio}"
class="componentePF text bold" required="true"
requiredMessage="É necessário atribuir um tipo ao reservatório">
<f:selectItem itemLabel="Escolha um Tipo para o Reservatório"
noSelectionOption="true" />
<f:selectItem itemLabel="Escoamento" itemValue="Escoamento" />
<f:selectItem itemLabel="Reserva" itemValue="Reserva" />
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
<h:outputLabel for="obsReservatorio" value="Observação: "
class="componentePF label" />
</p:column>
<p:column>
<p:inputText id="obsReservatorio"
value="#{controleBean.reservatorio.obsReservatorio}"
class="componentePF text" />
</p:column>
</p:row>
<p:row>
<p:column colspan="2">
<p:commandButton value="Cadastrar" icon="ui-icon-disk"
action="#{controleBean.cadastrarReservatorio}"
id="cadastrarReservatorio" ajax="false"
class="componentePF button" />
</p:column>
</p:row>
</p:panelGrid>
</p:dialog>
</h:form>
答案 0 :(得分:1)
第一个<p:commandLink>
不起作用,因为它发送了一个ajax请求。只需添加ajax="false"
即可解决问题。
有关根本原因的解释,请参阅https://stackoverflow.com/a/7740280/1980659。
根据您提供的内容,其他两个按钮应该可以正常工作。