Refresh table to display new record

Hi

I have create a dialog which displays form on submit of form those records need to refreshed in table.

The new record is displayed only when i move out of the page.

Is there any API to refresh the table which displays the new record on submit of the form.

I tried using

table.refreshCurrentPage();

But it doesn’t work for me.

Thanks

Hello,

what container do you use for prividing data to the table ?
Your container should generate a ItemSetChanged event…

André

Hi Azam,

The JSFUtils class that is used in many of Frank and others demo’s has a method to look up the UIComponent based on the componentid if you don’t already have that available to you.

Class containing misc helper methods for managing JSF Components. … UIComponent to generate JavaScript for: fieldId - Hidden field id to set value for … Parameters on table

Regards
Kevin Thomas
Attune Infocom Inc
http://www.attuneinfocom.com
Email : contact@attuneinfocom.com

Liferay Portlet

Hi Schild

I am using BeanItemContainer to display the record.

Hi,

pmfji but I have a very similar problem. I use a BeanItemContainer too, but my problem is a generated column in my table. This column contains a link and the label/text of that link has to change after the link has been clicked and the underlying data has been modified.
Unfortunately, the ItemSetChangeEvent of the BeanItemContainer is not fired. So I don’t know what I can do to get the table update the content without creating a new BeanItemContainer.

Any help is much apreciated

Andreas

How to you add the new record to the container ?
Can you show your code ?

André

Hi,

If you update the container using the container API, everything
should
work, i.e
container.getItem(itemId).getProperty(propertyId).setValue(newValue)
, but if you update the
bean
directly, the container
can not
know about this and thus does not send an event.

Might this be your problem? Of course I’m guessing a bit here, but it’s a common pitfall.

Best Regard,
Marc

Hi Marc,

thanks for your reply. I did modify the bean directly and I made the changes you suggested: still no change/update in my table. At least for a generated column it doesn’t work. Even the ItemSetChangeEvent is not fired.

My problem is probably the fact, that I modify a value of a column that’s not being displayed. When I update a visible column the table row gets updated. So my workaround is the following: even if you don’t need to update a visible column, update such a column with the value already displayed. This will cause an update of that row.

Hi Andre

This is the snippet which creates table.

BeanItemContainer<Person> personContainer= null;
final Table table = new Table("Person");
personContainer= new BeanItemContainer(employeeList);
table.setContainerDataSource(personContainer);



return table;

employeeList contains list of users.

Table is displayed as well as the records

My problem is I want to refresh the Table List whenever new record is added into DB.

Something like table.refreshCurrentPage(); Since this is deprecated i cannot use this

Thanks

Yeah, I think what’s going on is that Table does not know that your generated column depends on a property that is not displayed - it only reacts to properties that are displayed. So (if I understand your case correctly) it is actually working as planned, though you need to jump trough some hoops in your case…

// Marc

(BTW ItemSetChange should only occur when Items are added or removed, Property.ValueChange happens when you change the value of one ‘column’.)

If I understand your situation correctly, you need to update the
container
after you add to the DB - the container can not automatically get new stuff from the DB. This would mean getting a new
employeeList
and making a new
BeanItemContainer
with that, setting it as datasource for the table. Or maybe the best solution would be if you could add the new record to the
BeanItemContainer
at the same time you are updating the DB (using
personContainer.addBean(newPerson)
).

Hope I did not misunderstand your problem…

// Marc

Right. In fact, I think the update behaviour is kind of smart: only changes of visible columns will cause an update. Perfect.
To solve my problem, I only had to add one addiotional line of source code.

Thanks

Andreas

HI marc

yes you have understood the problem.
But i dont think its an ideal way of doing it beacuse for entire CRUD operation it may create problem

Have you looked in these messages ?

http://vaadin.com/forum/-/message_boards/view_message/198561
http://vaadin.com/forum/-/message_boards/view_message/408554
http://vaadin.com/forum/-/message_boards/view_message/359181
http://vaadin.com/forum/-/message_boards/view_message/341067

You must add the new item (you saved in the db) to the collection
with addBean (or addItem), then container does then trigger it’s attached
table to reflect the changes.

André

thanks…