Testing if Object List Data Provider is transactional?
A question came up in the forum about ObjectListDataProvider, asking if ObjectListDataProvider is transactional?.
According to the Java Doc of ObjectListDataProvider:
This class implements
TransactionalDataProvider semantics, meaning that
all updates to existing fields, as well as inserted and deleted rows, are cached
until commitChanges() is called. Once that call
is made, any RowKey you have retrieved from this
instance is invalid, and must be reacquired.
So, I decided to test this and created a test project which can be downloaded from here.
This project is an extension of the sample project I put in my previous blog http://blogs.sun.com/roller/page/winston?entry=objectlistdp_sample_project. So the work around steps explained in that blog must be followed.
In this project, I additionally added two components and modified the Table component as follows
When the button is clicked and the page is submitted, the button event listener does the following
The code in the button action handler looks like this.
public String button1_action() {
Name addedName = new Name("Gabriel", "Galvao");
this.getSessionBean1().getNameListDataProvider().appendRow(addedName);
this.getSessionBean1().getNameListDataProvider().commitChanges();
List myList = getSessionBean1().getNameListDataProvider().getList();
for(int i=0; i< myList.size(); i++){
info("Full Name: " + ((Name)myList.get(i)).getFirst() + " " + ((Name)myList.get(i)).getLast());
}
return null;
}
Following images show the results before and after the page is submitted. Before submitting the page, I changed the last name of Jeff Hudson to Jeff Jackson which is correctly displayed in the MessageGroup along with the added name Gabriel Galvao after the page is submitted. So, as we see through this sample ObjectListDataProvider is indeed transactional.
Posted at 09:31AM Aug 05, 2006 | Permanent link to this entry
Posted by Gabriel Galvão on August 05, 2006 at 07:10 PM PDT #
Posted by Winston Prakash on August 06, 2006 at 08:50 AM PDT #
Posted by Connall on August 18, 2006 at 02:58 PM PDT #
Posted by Matt on November 28, 2006 at 05:35 PM PST #
Posted by eebora on January 10, 2007 at 12:53 AM PST #
Posted by Austin Fernandes on April 23, 2007 at 04:03 PM PDT #
The problem with objectListDataprovider in studio creator still persist in netbean 6.0?
I try to craate a test engine and retrieve question directly from database. The Cursornext method did not work. I created objects of my questions as suggested by you, and make that class a field in my sessionBean. When I try to bind that objectListDataProvider in my page, I cannot locate the object in the list property of my objectListDataProvider that I drop on the page. This was a problem in studio creator. I guess it must have been solved in netbean 6.0. Please, how can i move forward, this is delaying my work
Posted by Ogunfunminiyi Frankfurt on March 27, 2008 at 07:56 AM PDT #
The problem with objectListDataprovider in studio creator still persist in netbean 6.0?
I try to craate a test engine and retrieve question directly from database. The Cursornext method did not work. I created objects of my questions as suggested by you, and make that class a field in my sessionBean. When I try to bind that objectListDataProvider in my page, I cannot locate the object in the list property of my objectListDataProvider that I drop on the page. This was a problem in studio creator. I guess it must have been solved in netbean 6.0. Please, how can i move forward, this is delaying my work
Posted by Ogunfunminiyi Frankfurt on March 27, 2008 at 07:57 AM PDT #
Hi Ogunfunminiyi, did you try as I mentioned in my blog http://blogs.sun.com/winston/entry/nb6_table_binding_enhancement
Posted by 76.102.227.57 on April 01, 2008 at 07:52 AM PDT #
http://www.batteryfast.co.uk/toshiba/b404.htm toshiba b404 battery,
http://www.batteryfast.co.uk/toshiba/ba1405.htm toshiba ba1405 battery,
http://www.batteryfast.co.uk/toshiba/pa2487.htm toshiba pa2487 battery,
Posted by laptop battery on October 23, 2008 at 11:43 PM PDT #