Inserting records into the database only after the insertion into a List

Asked

Viewed 88 times

0

I do not know if I was very specific in the title, but I will try to be more in the description. I have in my database a table of Disciplines that contains:

  1. id
  2. name
  3. workload

I would like these disciplines to be added in a table (in the primefaces) where I could click and it go to a second table, a table of "chosen" for example. And only after I complete the choice, can I click Submit and the records be recorded in the bank. I’m using Java, Hibernate and Primefaces, I’ve seen something similar but I can’t find the component in Showcase.

  • There is no component that does all this. You need to use the dataTable with multiple selection. Take a look at: http://www.primefaces.org/showcase/data/datatable/selection.xhtml. In this case the question is quite wide whether you expect a ready-made code to be used from start to finish.

  • No no, I don’t want everything. I just need a real north, because I saw it in a video once and I saw that it was possible. I’ll take a look and see what I can do with the table. Thanks!

  • @Wakim I can do more or less like this: Build two Datatales, on the first I use the data coming from the database and on the second a list of selected? Ai as I add in one, I update in the other? More or less like this? Just do not know how to update the second table as the first is being used.

  • Yes, my suggestion is to have the first table populated and configured with the selection. Using the selection clientBehavior (p:ajax with event of rowSelectCheckbox or rowSelect, just see in the documentation the correct event) or with a button (remembering the selection, which is a bean list), to add the items in the template of the other table. Assuming that the button would be done with ajax (if it is by Submit, the update is automatic), just set the update/render with the id of the other table.

  • Hmmm, I’ll try to do that @Wakim, it was very helpful, thank you =)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.