How I lost a project and rebuilt it very quick.

OK –

I’ve been using Netbeans 6.1 now and its perfect, really brilliant. But I decided (why I don’t know) to update to the latest nightly release of 6.1. When I loaded up my HUGE project that I’m working into 6.1 it crashed good and proper. The whole application went crazy.

So what went wrong. Well I had loaded up the latest Woodstock components because I wanted to use the excellent Wizard Facility. Unfortunately when I upgraded I failed to realise that the version with Netbeans 6.1 is NOT the latest release. Thus my project was damaged.

Now – To make things faster when rebuilding, a lot of times I use a nice grid which connects through to a form to edit the record (you know the sort of thing)….

So to make things faster I wrote some stuff into the Session Bean so that I could move between pages and make sure I was referencing the right record.

Firstly creating a variable to store the record ID:

public BigInteger RecordID;

// note that .my database ID's are all BIGINTS

// Add a new row to a recordset and save the ID

public void AddDBRow(CachedRowSetDataProvider dba) {
RowKey ask=dba.appendRow();
RecordID=(BigInteger) dba.getValue("id");


// Get the current Grid Row and save its id

public void EditDBRow(CachedRowSetDataProvider dba,RowKey ask) {
RecordID=(BigInteger) dba.getValue("id");


// Set the data provider to the right place in the database for editing
// note that this will not work if your ID field is not a BIG INTEGER (which it should be in my opinion)
// So you might need to change it to new Long(xx)

public void LoadEditPage(CachedRowSetDataProvider dba) {
RowKey ask=dba.findFirst("id", RecordID);

Ok so these 3 routines can be called within a JSF page.

Add new record button above the grid.


Edit DB Row Button on the Grid.


Then in the INIT function of the edit page that is linked to from the ADD NEW button and the EDIT button

 getSessionBean1().LoadEditPage(cachedRowSetDataProvider1); // The cachedRowSetDataProvider1 is hooked up to the Row set data provider


When you save your record sometimes you MAY need to do a refresh() afterwards...e.g


If you get a synchronisation error this will solve the problem - if not don't bother.

About Paul C

I am a Senior Java programmer/Web Technologies, Play in a band called Mandolin Monday, I have a cat and I live on a boat.

Posted on March 28, 2008, in Howto. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: