First I select two rows or more of a JTable and when I record those selected rows, I get several messages "" The Document "+ doc +" was requested correctly "", (doc is the name of the document), and so on the documents that have been recorded continue to come out, as it would do so that only a confirmation message appears saying that the documents (That the names of the documents that have been selected and recorded in the message come out) have been recorded successfully. I share the code that I am using:
protected void btnEnviarActionPerformed(ActionEvent arg0) {
//se crea una variable para que contenga la fila seleccionada de la tabla
int[] selectedRow = tbDocTransferir.getSelectedRows();
int i = tbDocTransferir.getSelectedRow();
//hacemos una condicion de que si la varialbe i es -1 es que no se ha seleccionado ninguna
//fila
if (i == -1){
JOptionPane.showMessageDialog(null,"Seleccione la fila que desea solicitar");
}
else{
for (int t : selectedRow){
String codArchivo = (String) tbDocTransferir.getValueAt(t, 0);
String codCentroCosto = (String) tbDocTransferir.getValueAt(t, 1);
String tipoArchivo = (String) tbDocTransferir.getValueAt(t, 4);
String doc = (String) tbDocTransferir.getValueAt(t, 6);
String nivelArchivo = (String) tbDocTransferir.getValueAt(t, 8);
String lote = (String) tbDocTransferir.getValueAt(t, 10);
String fila = (String) tbDocTransferir.getValueAt(t, 11);
String usuarioSolicita = Constante.idUsuario;
String fechaSolicita = txtFechaSolicita.getText();
Objeto object = (Objeto) cboCentroCostoDestino.getSelectedItem();
String centroCostoDestino = ((Objeto)object).getCodigo();
String centroCostoOrigen = Constante.c_ccosto;
MovimientoArchivoDTO x = new MovimientoArchivoDTO();
x.setC_c_archivo(codArchivo);
CentroCostoDTO c = new CentroCostoDTO();
c.setC_ccosto(codCentroCosto);
c.setC_ccosto(centroCostoOrigen);
x.setC_ccosto(c);
x.setC_ccosto_origen(c);
x.setC_ccosto_destino(centroCostoDestino);
x.setC_tipo_doc(tipoArchivo);
x.setC_t_doc(doc);
x.setC_c_nivel_archivo(nivelArchivo);
x.setLote(lote);
x.setFila(fila);
x.setC_c_usuario_solicita(usuarioSolicita);
x.setD_dt_solicita(fechaSolicita);
int estado = xy.RegistrarSolicitudArchivo_SA(x);
if (estado == 1){
mensaje("El Documento "+doc+" se solicitó correctamente");
// ListarDocumento(Constante.c_ccosto, Integer.parseInt(txtFlgEnvia_0.getText()));
lblDestinoDelDocumento.setVisible(false);
cboCentroCostoDestino.setVisible(false);
// cboCentroCostoDestino.setSelectedIndex(0);
}
else
mensaje("Error en enviar");
}
}
}
void mensaje(String m){
JOptionPane.showMessageDialog(null, m);
}