Hi Thomas.
Thank you for your reply.
Yes. I took a look at the comment before my post but that example doesn’t fit my need, at least at first sight.
Think about a desktop email client application such as Outlook, Apple Mail App, Thunderbird, etc.
When you click
Inbox
, you see received messages. When you click
Sent
, you see sent messages. Simple. If we don’t talk about other details the applications have simply two
VerticalLayout
s in a
HorizontalLayout
. One for “master” and the other one for “detail”. I am trying to design similar layout for a client detail view.
Actually I hope Vaadin Framework has something similar to C#/XAML logic: Data inheritance, event tunneling/bubbling.
Well… This is what I am try to achieve:
ContactInformation.java
[code]
public class ContactInformation {
private String address;
private String phone;
public ContactInformation() {
this.address = null;
this.phone = null;
}
getters...
setters...
}
[/code]
Client.java
[code]
public class Client {
private String name;
private ArrayList<ContactInformation> contactInformation;
public Client() {
this.name = null;
this.contactInformation = new ArrayList<>();
}
getters...
setters...
}
[/code]I think the code pieces above are enough to explain the basic data structure.
ClientDetail.java
[code]
public class ClientView extends Window {
private final BeanFieldGroup<Client> bfgClient = new BeanFieldGroup<>(Client.class);
private final TextField txflName = new TextField();
private final ContactInformationView csflContactInformation = new ContactInformationView();
...
public ClientView() {
this.bfgClient.bind(this.txflName, "name");
this.bfgClient.bind(this.csflContactInformation, "ContactInformation");
...
}
[/code]There is a
ContactInformationView
which extends
CustomField
. The
ArrayList
which contains contact information items is passed to
ContactInformationView
by
setPropertyDataSource
overrider’s parameter (newDataSource). Contact information view is created for each item successfuly but then what? I am stuck here.
Should
BeanItem
(in the example of the link provided above) be instantiated for each item in the
ArrayList
and bound to the fields in
ContactInformationView
separately? If so, what about
commit()
method? Will
bfgClient
be aware of the data changes in
ContactInformationView
?
This is the simplest part of whole application. Changing design could solve this contact information problem but there are much more complex data structures must be shown in this logic.