Manejo de Binder en formulario con campos ComboBox pertenecientes a otra ta

Hola

Recien empiezo con Vaadin en el momento tengo un formulario con campos para registrar una nueva entidad(Alianzas), el formulario carga en dos comboBox las instituciones disponibles que pueden registrarsen para dicha entidad.


Aquí la relación entre tablas

Ocupo un Binder para enlazar los campos del fomulario con su respectiva clase(Alianzas), sin embargo para los componentes comboBox que muestran el listado de Instituciones no tengo claro que procedimiento realizar, provisionalmente he creado otro binder para ellos esta vez de tipo instituciones_alianzas que es la tabla intermedia, esto debido a incompatibilidad de tipos.

Estoy utilizando ademas Vadin design, Version vaddin: 8.0.5

Aqui el codigo donde establezco los diferentes binder:

[code]
[code]
[code]
...
        binderInstitucionAli.forField(frmAlianza.cbPrimeraInsti)
        .asRequired("Debe seleccionar una institucion")
        .bind
        (
                co.sirceer.model.InstitucionesAlianzas::getInstitucionInstituciones,
                co.sirceer.model.InstitucionesAlianzas::setInstitucionInstituciones
                );
        
        binderInstitucionAli.forField(frmAlianza.cbSegundaInsti)
        .bind
        (
                co.sirceer.model.InstitucionesAlianzas::getInstitucionInstituciones,
                co.sirceer.model.InstitucionesAlianzas::setInstitucionInstituciones
                );
        
        
        //Campos para Alianzas
        binder.forField(frmAlianza.txtNombre).asRequired("Nombre no ingresado").bind
        (
                co.sirceer.model.Alianzas::getNombre,
                co.sirceer.model.Alianzas::setNombre
                );

        
        binder.forField(frmAlianza.dfFechaInicio).asRequired("Debe ingresar una fecha de inicio")
        .withConverter(new LocalDateToDateConverter())
        .withValidator(value -> (java.sql.Date.valueOf("2015-12-31")).before(value),
                  "La fecha debe ser mayor al año 2015")
        .bind
        (
                co.sirceer.model.Alianzas::getFechaInicio,
                co.sirceer.model.Alianzas::setFechaInicio
                );
[/code]
[/code]
[/code]

.
.
.

Class: Alianzas

public class Alianzas implements Serializable {

    /** serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /** id. */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    

    /** nombre. */
    private String nombre;

    /** fechaInicio. */
    private Date fechaInicio;

    /** fecha_final. */
    private Date fechaFinal;

    /** cupos. */
    private Integer cupos;

//    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
//    private List<co.sirceer.model.Instituciones> instituciones = new ArrayList<co.sirceer.model.Instituciones>();

    /**
     * Constructor.
     */
    public Alianzas() {    }
    
    public Alianzas(Alianzas elDato) {
        
        this.id = elDato.getId();
        this.nombre = elDato.getNombre();
        this.fechaInicio = elDato.getFechaInicio();
        this.fechaFinal = elDato.getFechaFinal();
        this.cupos = elDato.getCupos();
    }

    public Alianzas(/*long id,*/ String nombre, Date fechaInicio, Date fechaFinal, Integer cupos) {
        
        //this.id = id;
        this.nombre = nombre;
        this.fechaInicio = fechaInicio;
        this.fechaFinal = fechaFinal;
        this.cupos = cupos;
    }



    /**
     * Set the id.
     * 
     * @param id
     *            id
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * Get the id.
     * 
     * @return id
     */
    public long getId() {
        return this.id;
    }

    /**
     * Set the nombre.
     * 
     * @param nombre
     *            nombre
     */
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    /**
     * Get the nombre.
     * 
     * @return nombre
     */
    public String getNombre() {
        return this.nombre;
    }

    /**
     * Set the fechaInicio.
     * 
     * @param fechaInicio
     *            fechaInicio
     */
    public void setFechaInicio(Date fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    /**
     * Get the fechaInicio.
     * 
     * @return fechaInicio
     */
    public Date getFechaInicio() {
        return this.fechaInicio;
    }

    /**
     * Set the fecha_final.
     * 
     * @param fechaFinal
     *            fecha_final
     */
    public void setFechaFinal(Date fechaFinal) {
        this.fechaFinal = fechaFinal;
    }

    /**
     * Get the fecha_final.
     * 
     * @return fecha_final
     */
    public Date getFechaFinal() {
        return this.fechaFinal;
    }

    /**
     * Set the cupos.
     * 
     * @param cupos
     *            cupos
     */
    public void setCupos(Integer cupos) {
        this.cupos = cupos;
    }

    /**
     * Get the cupos.
     * 
     * @return cupos
     */
    public Integer getCupos() {
        return this.cupos;
    }

    

Class: Instituciones

public class Instituciones implements Serializable {

    /** serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /** id. */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    /** nombre. */
    private String nombre;

    /** telefono. */
    private String telefono;

    /** email. */
    private String email;

    /** direccion. */
    private String direccion;
    
    
    

    /**
     * Constructor.
     */
    public Instituciones() {
        
    }
    
    public Instituciones(Instituciones elDato) {
        
        this.id = elDato.getId();
        this.nombre = elDato.getNombre();
        this.telefono = elDato.getTelefono();
        this.email = elDato.getEmail();
        this.direccion = elDato.getDireccion();
    }

    public Instituciones(/*long id,*/ String nombre, String telefono, String email, String direccion) {
        
        //this.id = id;
        this.nombre = nombre;
        this.telefono = telefono;
        this.email = email;
        this.direccion = direccion;
    }



    /**
     * Set the id.
     * 
     * @param id
     *            id
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * Get the id.
     * 
     * @return id
     */
    public long getId() {
        return this.id;
    }

    /**
     * Set the nombre.
     * 
     * @param nombre
     *            nombre
     */
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    /**
     * Get the nombre.
     * 
     * @return nombre
     */
    public String getNombre() {
        return this.nombre;
    }

    /**
     * Set the telefono.
     * 
     * @param telefono
     *            telefono
     */
    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    /**
     * Get the telefono.
     * 
     * @return telefono
     */
    public String getTelefono() {
        return this.telefono;
    }

    /**
     * Set the email.
     * 
     * @param email
     *            email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * Get the email.
     * 
     * @return email
     */
    public String getEmail() {
        return this.email;
    }

    /**
     * Set the direccion.
     * 
     * @param direccion
     *            direccion
     */
    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    /**
     * Get the direccion.
     * 
     * @return direccion
     */
    public String getDireccion() {
        return this.direccion;
    }

    

y class: InstitucionesAlianzas

public class InstitucionesAlianzas implements Serializable {

    /** serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /** id. */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    /** instituciones. */
    private Instituciones institucionInstituciones;

    /** alianzas. */
    private Alianzas alianzas;

    /** fechaVinculacion. */
    private Date fechaVinculacion;

    /**
     * Constructor.
     */
    public InstitucionesAlianzas() {
    }

    public InstitucionesAlianzas(InstitucionesAlianzas elDato) {
        
        this.id = elDato.getId();
        this.institucionInstituciones = elDato.getInstitucionInstituciones();
        this.alianzas = elDato.getAlianzas();
        this.fechaVinculacion = elDato.getFechaVinculacion();
    }

    
    
    public InstitucionesAlianzas(/*long id,*/ Instituciones institucionInstituciones, Alianzas alianzas,
            Date fechaVinculacion) {
        super();
        //this.id = id;
        this.institucionInstituciones = institucionInstituciones;
        this.alianzas = alianzas;
        this.fechaVinculacion = fechaVinculacion;
    }



    /**
     * Set the id.
     * 
     * @param id
     *            id
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * Get the id.
     * 
     * @return id
     */
    public long getId() {
        return this.id;
    }

    /**
     * Set the instituciones.
     * 
     * @param institucionInstituciones
     *            instituciones
     */
    public void setInstitucionInstituciones(Instituciones institucionInstituciones) {
        this.institucionInstituciones = institucionInstituciones;
    }

    /**
     * Get the instituciones.
     * 
     * @return instituciones
     */
    public Instituciones getInstitucionInstituciones() {
        return this.institucionInstituciones;
    }

    /**
     * Set the alianzas.
     * 
     * @param alianzas
     *            alianzas
     */
    public void setAlianzas(Alianzas alianzas) {
        this.alianzas = alianzas;
    }

    /**
     * Get the alianzas.
     * 
     * @return alianzas
     */
    public Alianzas getAlianzas() {
        return this.alianzas;
    }

    /**
     * Set the fechaVinculacion.
     * 
     * @param fechaVinculacion
     *            fechaVinculacion
     */
    public void setFechaVinculacion(Date fechaVinculacion) {
        this.fechaVinculacion = fechaVinculacion;
    }

    /**
     * Get the fechaVinculacion.
     * 
     * @return fechaVinculacion
     */
    public Date getFechaVinculacion() {
        return this.fechaVinculacion;
    }

Muchas gracias, quedo atento.

Hola,

No logro entender tu prengunta. Si lo que quieres es implementar un formulario vinculado (binding) a un
Entity
que tiene una relación
one-to-many
y quieres presentar un
ComboBox
para esta relación, no necesitas un
Binder
adicional. Simplemente pudes establecer los items del
ComboBox
con el método
setItems(Collection)
.

Hola

Practicamnete

Hola

Practicamente asi es, lo que estaba haciendo es manejar un Binder adicional para la Entity que tiene la relacion many-to-many y para vincular los combox a esta. Tratare de hacer lo que dices manejar los comboBox sin un Binder adicional haber como me va.

Muchas gracias por responder Alejandro