File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Dynamically adding rows to an input data table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Dynamically adding rows to an input data table" Watch "Dynamically adding rows to an input data table" New topic

Dynamically adding rows to an input data table

Abbhinav Sharma

Joined: Jan 12, 2012
Posts: 6
Hi Guys

Have a very elementary problem in my initial learning in JSF.
I intend to have a table on my form to capture rows of data and to bind them with corresponding Java variables.
The challenge I face is being able to add rows of fields to my table dynamically, as in:

If I am to capture data about a customer and his family the form might look like:

Name Age Ph No Relationship
Andrew Greene 47 09402934234 Self
Marie Greene 45 23234923800 Wife
Jake Greene 17 23948209840 Son

Now if I wish to add another member of the family on the form, I would probably have an add button that would generate another row of input fields in a row:

Anna Greene 16 23482304800 Daughter

I am wondering how it might be possible for me to keep adding rows for each member of the family on the form dynamically, without having to submit the form?

Would appreciate any help.

P.S.: Please pardon the elementary nature of my question, as I am yet at a very stage of exploring these topics.

It would be very helpful to know if there is a live chat option available (here or any other forum) to be able to interact with others from whom I can learn.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

If you do not submit the data, then the server will never see the new data. The submit process is the only way that client and server can communicate.

You can do a partial submit using AJAX, but it's still a submit and the rules are almost identical to a full-page submit.

Adding rows to a table is done by adding them to the Model that backs the table and re-rendering the table. The re-rendering can be done by doing a full-page submit (which will redraw the entire page) or a partial-page submit using AJAX,

An IDE is no substitute for an Intelligent Developer.
Abbhinav Sharma

Joined: Jan 12, 2012
Posts: 6
Hi Tim

Thanks for taking time to attend to my query.
Using AJAX sounds like an alternative I could certainly try. As I go about doing it, I will most likely have more questions, and I certainly know where to reach out for help

Further to my postscript, it would be very helpful to know of a live chat forum, where it would perhaps be possible to interact with adept progammers to seek help in clearing my concepts interactively.
I am still to come to grips with exactly how the flow of control works in JSF based applications i.e. a micro level understanding of when are instances actually created and how exactly the interactions with the server take place.

Would greatly appreciate any suggestions to help with that.

Thanks once again for the help.


I agree. Here's the link:
subject: Dynamically adding rows to an input data table
It's not a secret anymore!