Insert data in two tables

Hello people, I have doubts on how inserting data in two different tables, I have two forms, one person and another person physically, I know how to call the two forms on the screen and enter data in these two tables.

Can you explain your problem more exactly? How are the tables and forms related?

There’s a
new example
on binding a table and form to same data.

The description of the example the comments are a bit misleading with respect to the word “binding” May I suggest the following to make your description closer to the usual meaning of “binding” (associating a name or symbol with its value).

  1. You are binding the Form to an Item in the table, not to the Table as the description says. The trick is that the item shown in the form is the same as the one used for the row in the table.

  2. When at the beginning of the example you say “// Also bind a form…” you are not actually doing the binding there, you are just defining a form. The binding takes place much later, when you do “form.setItemDataSource”.

What the example does not explain, is how does the table know that someone else has modified an item it holds. Because there is no explicit notification of the table from the form, this looks like black magic. Something like “vaadin handles the fact that whenever an item in a datasource changes as a result of a user interaction, all displayed occurences of the same item will be updated on the screen during the display update that results from that interaction”

Without a clear description of the “Vaadin magic”, people can’t get their brain around the fact that changing a value on the right made the updated value appear on the left.

Understanding this example is actually key to understanding Vaadin ! In business applications, this pattern occurs over and over and over.

The same example in “immediate” mode would also be very nice.

Hello, so when inserting the first attempt to insert the table PFisica and then in person, do not understand how this insertion in the tables, if they can help me be grateful.
Here is the code I’m using when I call the form:

It’s a bit hard to see what your code does or tries to do, with the Portugese and a lot of strange classes.

So are PFisica and person tables or something that you want to put in the tables? Or do you want to put the tables in the objects?

I don’t see any Table objects in the code, unless you have extended Table.

Please describe your problem more clearly.

Marko, sorry if not well explained

You can always use Google Translate. It’s not perfect, but quite good with some languages and could help a lot.

I’ll start from scratch and tries to give you my goal.
In my database I have three tables, one person, a person of physical and juridical person of another, in my package will be created where my classes to communicate with the database I have three classes for each table in database data, Person, and PFisica PJuridica.
In my UI pack I have three classes that are built the forms for each type of person, PessoaForm, and PFisicaForm PJuridicaForm. when I enter the main screen and invoke the goal of these forms on screen, they’re separated in two tabs, the Individual and Corporate client base, I want to choose the tab, the form of call and PessoaForm PFisicaForm to the insertion of data, as I am showing the code, but do not know exactly how.

I still have a bit trouble understanding what your are trying to do there, but I think the code looks quite ok. I’d probably use an anonymous class to handle the button clicks from different sources, but your solution is just ok.

If I understood correctly, your question was about inserting the form data to the database tables. That’s not a Vaadin related question, so I can’t help you with that.

Looking at the code, you have not created and bound a bean for the PFisicaForm, yet you apparently try to save it with pfDao.Salvar(pesF);. I also do not understand why you rebind the forms to the beans after you have saved the data:

fPessoa.setItemDataSource(new BeanItem<Pessoa>(psd));
fPessoaFis.setItemDataSource(new BeanItem<PFisica>(pesF));

Dear everyone i am new Vaadin…
can you give me insert data to database