Problems with dataTable and confirmDialog

UI Components for JSF
Post Reply
iuriamatos
Posts: 9
Joined: 07 Oct 2011, 15:34

07 Oct 2011, 16:02

Hello,
I have a problem with my dataTable with a delete button... when I click in the delete button my manageBean save the reference of my rowData and open my confirmDialog..
My problem is when i click in the button YES at my confirmDialog I lose my reference of rowData.
I'm sorry for my english.

my xhtml
<f:form prependId="false">
<p:dataTable id="expeditionNoteView"
style="text-align: center;"
paginator="true"
paginatorPosition="botton"
widgetVar="expeditionNoteView"
var="expeditionNote"
value="#{indexBean.resultFluxosSearch}">
<p:column headerText="Ptcl Envio">
<h:outputText value="#{expeditionNote.nuPtclEnvioMsgeEmsr}" />
</p:column>
<p:column headerText="Pátio Origem">
<h:outputText value="#{expeditionNote.patioOrigem.sgPatioFrvr} - "/>
<h:outputText value="#{expeditionNote.patioOrigem.nmPatioFrvr}" />
</p:column>
<p:column headerText="Terminal Origem">
<h:outputText value="#{expeditionNote.terminalOrigem.nmTermFrvr}" />
</p:column>
<p:column headerText="Pátio Destino">

<h:outputText value="#{expeditionNote.patioDestino.sgPatioFrvr} - " />
<h:outputText value="#{expeditionNote.patioDestino.nmPatioFrvr}" />
</p:column>
<p:column headerText="Terminal Destino">
<h:outputText value="#{expeditionNote.terminalDestino.nmTermFrvr}" />
</p:column>
<p:column headerText="Estado Envio">
<h:outputText value="#{expeditionNote.icStatMsgeEltc}" />
</p:column>
<p:column headerText="Tipo Envio">
<h:outputText value="#{expeditionNote.icTipoMsgeEltc}" />
</p:column>
<p:column headerText="Forma Envio">
<h:outputText value="#{expeditionNote.icFormaRbtoMsgeEltc}" />
</p:column>
<p:column headerText="Versão">
<h:outputText value="#{expeditionNote.nuVersMsgeEltc}" />
</p:column>
<p:column headerText="Ptcl Recebimento">
<h:outputText value="#{expeditionNote.nuPtclRbtoMsgeEltc}" />
</p:column>
<p:column headerText="Fluxo Transporte">
<h:outputText value="#{expeditionNote.fluxoTransporte.nuFluxoTrpt}" />
</p:column>
<p:column>
<h:commandLink action="fluxoVisualizacao" actionListener="#{indexBean.defineNota()}">
<h:graphicImage value="imagens/view.png" alt="Visualizar" title="Visualizar" style="border: none" />
</h:commandLink>
</p:column>
<p:column>
<h:commandLink action="fluxos"
actionListener="#{indexBean.defineNota()}">
<h:graphicImage value="imagens/edit.png" alt="Editar" title="Editar" style="border: none" />
</h:commandLink>
</p:column>
<p:column>
<p:commandLink actionListener="#{indexBean.rowToDelete}"
onclick="confirm.show()"
immediate="true">
<h:graphicImage value="imagens/delete.gif" alt="Excluir" title="Excluir" style="border: none" />
</p:commandLink>
</p:column>
</p:dataTable>
</p:panel>
<p:confirmDialog message="Tem certeza que deseja excluir o registro?"
header = "Excluir registro" severity="alert" widgetVar="confirm">
<p:commandButton value ="YES"
actionListener="#{indexBean.deleteNote}"
onclick="confirm.hide()"
immediate="true"
update="panelResultSearch">
</p:commandButton>
<p:commandButton value ="NO" onclick="confirm.hide();"/>
</p:confirmDialog>
</h:form>

my ManageBean:
@ManagedBean(name = "indexBean")
@RequestScoped
public class IndexBean implements Serializable {

private AtributosPesquisa atributosPesquisa = new AtributosPesquisa();
private DataModel resultFluxos;
private List<PatioFerroviario> resultPatioFerroviario;
private List<String> listMensagem;
private RecebimentoNota recebimentoNota;

public IndexBean() {
System.out.println("AAAAAAAA");
System.out.println("BBBBBBBB");
}

public RecebimentoNota getRecebimentoNota() {
return recebimentoNota;
}

public void setRecebimentoNota(RecebimentoNota recebimentoNota) {
this.recebimentoNota = recebimentoNota;
}

public void rowToDelete() {
recebimentoNota = (RecebimentoNota) resultFluxos.getRowData();
}

public void deleteNote() {
RecebimentoNotaDao dao = new RecebimentoNotaDao();
try {
dao.destroy(recebimentoNota.getPid());
} catch (NonexistentEntityException ex) {
ex.printStackTrace();
}
getResultFluxosSearch();
}

public DataModel getResultFluxosSearch() {
RecebimentoNotaDao recebimentoNotaDao = new RecebimentoNotaDao();
resultFluxos = new ListDataModel(recebimentoNotaDao.findResultNotaSearch(atributosPesquisa));
return resultFluxos;
}
}

Thanks

User avatar
leventgny
Posts: 238
Joined: 24 May 2011, 16:49
Contact:

07 Oct 2011, 17:27

Please use separate code tags to make your cases understandable.
PrimeFaces Team Member

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 38 guests