I have a dataTable
with the data in front of each given a button, when I click the button a dialog
is opened so that I can do an edit in that data, however I can not get the object that was selected to pass as pro method parameter that does the editing.
How can I get the% of selected% of the table by clicking the edit button?
I'm doing it this way:
<p:dialog header="Pausar Atividade" widgetVar="dlg3"
modal="true" height="300" width="700">
<p:panelGrid columns="2" cellpadding="4" style="width:100%;margin-top:20px" columnClasses="rotulo, campo">
<p:outputLabel value="Motivo" />
<h:panelGroup>
<p:inputTextarea rows="5" cols="30" counter="display1"
maxlength="255" counterTemplate="{0} Caracteres Restantes."
autoResize="false" style="width:70%" value="#{tarefaBean.tarefa.comentario}" />
<br />
<h:outputText id="display1" />
</h:panelGroup>
</p:panelGrid>
<p:commandButton value="Pausar Tarefa" style="margin-left:25%;margin-top:20px;width:50%" actionListener="#{tarefaBean.pausarTarefa}" update=":msgGlobal: frmPrin"/>
</p:dialog>
The button in the dataTable:
<p:column headerText="Ações" style="text-align:center">
<p:commandButton icon="ui-icon-check" title="Finalizar" onclick="PF('dlg4').show();" />
<p:commandButton icon="ui-icon-pause" title="Pausar" onclick="PF('dlg3').show();" />
</p:column>
Method in bean:
public void pausarTarefa(){
try {
tarefa.setStatus("Pausado");
tarefa.setDataFim(new Date());
TarefaDAO tarefaDAO = new TarefaDAO();
tarefaDAO.editar(tarefa);
FacesUtil.adicionarMsgInfo("Solicitação Enviada com Sucesso");
} catch (RuntimeException e) {
FacesUtil.adicionarMsgErro("Erro ao Enviar Solicitação!");
e.printStackTrace();
}
}