Hi, I’m new in Vaadin and I’m doing a form for data processing.
I could not move much with jpa by the characteristics of the network (like proxy and others) so I had to do many things by hand.
I have a problem on a form, I could load the data, I works fine, I fill in the fields, but dont know how to process the form.
If it is a type ComboBox or NativeSelect fielt etc, I can capture fine but I can not capture the data loaded into the table.
step classes to see if I can help.
I hope you understand and can help me, I accept any suggestion
In the original form call a class that fills me tables
//---------------------------------
try {
new RellenarTablasIntegrantes(integrantesTable, AgregarIntegrantes);
} catch (Exception e) {
System.out.println(“no funciona la instanciación del RellenarCombos”);
}
//---------------------------------
This is the class that populates the tables
Instance others to do querys by hand.
public class RellenarTablasIntegrantes{
String LEGAJO = "Legajos";
String NOMBRE = "Nombre";
String CATEGORIA = "Categoría";
String ESCALAFON = "Escalafon";
String RESPONSABLE = "Responsable";
String BORRAR = "Borrar";
String NUMERO = "N°";
private int cont = 0;
public RellenarTablasIntegrantes(final Table integrantesTable, Button AgregarIntegrantes) {
integrantesTable.addContainerProperty(LEGAJO, ComboBox.class, null);
integrantesTable.setColumnWidth(LEGAJO, 100);
integrantesTable.addContainerProperty(NOMBRE, ComboBox.class, null);
integrantesTable.setColumnWidth(NOMBRE, 270);
integrantesTable.addContainerProperty(CATEGORIA, ComboBox.class, null);
integrantesTable.setColumnWidth(CATEGORIA, 150);
integrantesTable.addContainerProperty(ESCALAFON, ComboBox.class, null);
integrantesTable.setColumnWidth(ESCALAFON, 150);
integrantesTable.addContainerProperty(RESPONSABLE, CheckBox.class, null);
integrantesTable.setColumnWidth(RESPONSABLE, 130);
integrantesTable.addContainerProperty(BORRAR, Button.class, null);
integrantesTable.setColumnWidth(BORRAR, 50);
integrantesTable.addContainerProperty(NUMERO, Label.class, null);
integrantesTable.setColumnWidth(NUMERO, 50);
// Listener del boton agregar integrantes
AgregarIntegrantes.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
cont++;
setintegrantetable(cont, integrantesTable);
}
});
}
@SuppressWarnings("unchecked")
private void setintegrantetable(int cont, final Table integrantesTable) {
// integrantesTable.setImmediate(true);
try {
final Object itemId = integrantesTable.addItem();
// Insert the data and the additional component column
for (int i = 0; i < cont; i++) {
// cargo los tipos de dato
ComboBox legajo = new ComboBox(null);
legajo.setWidth("95px");
ComboBox nombre = new ComboBox(null);
nombre.setWidth("265px");
ComboBox categoria = new ComboBox(null);
categoria.setWidth("145px");
final ComboBox escalafon = new ComboBox(null);
escalafon.setWidth("145px");
CheckBox responsable = new CheckBox(null);
//Instancio el boton y le seteo el titulo
Button borrar = new Button("Borrar");
//creo un listener de boton para borrar esa linea segun el id seteado en el idemId
borrar.addClickListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
integrantesTable.removeItem(itemId);
}
});
// seteComboBoxo el numero del trabajo
String num = Integer.toString(cont);
Label numA = new Label(num);
// Relleno los Comboboxes con lo queComboBox traigo de la base.
FillcomboLegajo(legajo, nombre, categoria, escalafon);
//---------------- Encadenando Combos --------------------------
RellenarCombosEventos relleN = new RellenarCombosEventos();
relleN.RellComEvNom(legajo, nombre, itemId);
relleN.RellComEvLeg(legajo, nombre, itemId);
//-------------------------------------------
integrantesTable.getItem(itemId).getItemProperty(LEGAJO).setValue(legajo);
integrantesTable.getItem(itemId).getItemProperty(NOMBRE).setValue(nombre);
integrantesTable.getItem(itemId).getItemProperty(CATEGORIA).setValue(categoria);
integrantesTable.getItem(itemId).getItemProperty(ESCALAFON).setValue(escalafon);
integrantesTable.getItem(itemId).getItemProperty(RESPONSABLE).setValue(responsable);
integrantesTable.getItem(itemId).getItemProperty(BORRAR).setValue(borrar);
integrantesTable.getItem(itemId).getItemProperty(NUMERO).setValue(numA);
}
} catch (Exception e) {
System.out
.println("no funciona el rellenar tablas En rellenartablasIntegrantes");
}
try {
integrantesTable.setPageLength(integrantesTable.size());
} catch (Exception e1) {
e1.printStackTrace();
}
}
// legajo, nombre, categoria, escalafon
public void FillcomboLegajo(ComboBox area, ComboBox area1, ComboBox area2, ComboBox area3) {
SelectEmpleados emple = new SelectEmpleados();
try{
for (String nom1:SelectEmpleados.getLegajo()){
area.addItem(nom1.toString());
area.setValue(area.getItemIds().iterator().next());
}
}catch(Exception e){
System.out.println("error en legajo");
}
try{
for (String nom1:SelectEmpleados.getApellidoNombres()){
area1.addItem(nom1.toString());
area1.setValue(area1.getItemIds().iterator().next());
}
}catch(Exception e){
System.out.println("error en getApellidoNombres");
}
try{
for (String nom2:SelectEmpleados.getCategoria()){
area2.addItem(nom2.toString());
area2.setValue(area2.getItemIds().iterator().next());
}
}catch(Exception e){
System.out.println("error en getCategoria");
}
try{
for (String nom3:SelectEmpleados.getCodEscalafon()){
area3.addItem(nom3.toString());
// con esto queda seleccionado el primer valor y no queda el
// combo en blanco
area3.setValue(area3.getItemIds().iterator().next());
}
}catch(Exception e){
System.out.println("error en getEscalafon");
}
}
}