I am working on a project where the UI is being generated from the Vaadin designer. I have the html generated and the corresponding .java file.
I extend the java file and bind my data to the view of the design. The basic code to display my data is working as each field on the form has a corresponding pojo variable. Now I want to display two fields together on the form much like you would combine first and last name to show a full name.
My pojo has a toString method that returns the two values combined but I can’t figure out how to set the label in the design ( named propertyNoName() ) to the value of aPropertyProfile.toString() .
Below is the relevant code…
public class PropertyProfileDesign extends VerticalLayout
{
private VerticalLayout propertyProfileHeader;
private Label propertyNoName;
private TextField propertyMgr;
private TextField propertyMgrPhone;
private TextField propertyMgrCellular;
private TextField propertyMgrHome;
private TextField regionalMgr;
private TextField regionalMgrPhone;
private TextField regionalMgrCellular;
private TextField regionalMgrHome;
private VerticalLayout propertyProfileBodyFooter;
public PropertyProfileDesign()
{
Design.read( this );
}
public VerticalLayout getPropertyProfileHeader()
{
return propertyProfileHeader;
}
public Label getPropertyNoName()
{
return propertyNoName;
}
public TextField getPropertyMgr()
{
return propertyMgr;
}
public TextField getPropertyMgrPhone()
{
return propertyMgrPhone;
}
public TextField getPropertyMgrCellular()
{
return propertyMgrCellular;
}
public TextField getPropertyMgrHome()
{
return propertyMgrHome;
}
public TextField getRegionalMgr()
{
return regionalMgr;
}
public TextField getRegionalMgrPhone()
{
return regionalMgrPhone;
}
public TextField getRegionalMgrCellular()
{
return regionalMgrCellular;
}
public TextField getRegionalMgrHome()
{
return regionalMgrHome;
}
public VerticalLayout getPropertyProfileBodyFooter()
{
return propertyProfileBodyFooter;
}
}
public class PropertyProfileView extends PropertyProfileDesign
{
private static final long serialVersionUID = 7454308982717559970L;
private Binder<PropertyProfile> binder = new Binder<>( PropertyProfile.class );
public PropertyProfileView()
{
}
public PropertyProfileView( final PropertyProfile aPropertyProfile )
{
this();
binder.bindInstanceFields( this );
binder.readBean( aPropertyProfile );
// How to update the label field propertyNoName with aPropertyProfile.toString()?
}
}