How I lost a project and rebuilt it very quick.

March 28, 2008

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();
dba.setCursorRow(ask);
RecordID=(BigInteger) dba.getValue("id");

}

// Get the current Grid Row and save its id

public void EditDBRow(CachedRowSetDataProvider dba,RowKey ask) {
dba.setCursorRow(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);
dba.setCursorRow(ask);
}

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

Add new record button above the grid.

getSessionBean1().AddDBRow(dataprovider)

Edit DB Row Button on the Grid.

getSessionBean1().EditDBRow(coursesDataProvider,tableRowGroup1.getRowKey());

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

Lastly

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

cachedRowSetDataProvider1.commitChanges();
cachedRowSetDataProvider1.refresh();

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

6.1 Netbeans 12 hours later

March 21, 2008

Well I was going to update the 6.1 Netbeans thing I posted yesterday, but I spent a solid 12 hours developing with it. I made a massive amount of progress with a large project I was working on.

Although I had a few crashes that was largly due to the massive project I have been working on. It’s  a huge web project and is hooked up to the glassfish server. Although relogging into my Solaris Box fixed it.

I am really really ENJOYING writing Netbeans based code under Solaris. I think the Netbeans community have developed something very special and once you get “under the hood” and work out how to do basic things it is soon really great developing large projects with it.

I am going to enter my blog entries into Sun’s competition but this is honestly from the heart and I hope that as a developer (if you’re reading this) you’ll go ahead and try Netbeans out. I’m just looking forward to the full release of it.

Good job! Please catch up with me in Second Life (pnc Blessed) if you fancy a chat.


Netbeans 6.1 and why I’m a Bannana

March 19, 2008

Ok So I downloaded Netbeans 6.1

I loaded up my faces application. I added a text box and then tried to reference it. Could I see it? No, so me being a bannana thought I’d done something wrong, but thats because you now have to Add Binding Attribute by right clicking the component and then I could use the componant in the Java code.

This makes PERFECT sense, it saves it loading all the components and increases performance of not only the design view but I’m sure the application itself as there are no getters and setters for things we don’t need them for. Sleek!

My thanks to Roman Strobl (AGAIN) for stopping me from jumping from a tall building (if there were any tall buildings in Chalfont St Peter).

Once I’d loaded up my old 6.0.1 app I got the can’t compile problem (http://www.netbeans.org/issues/show_bug.cgi?id=129316 ) which I fixed by following the instructions there - fine.

My project I was developing in 6.0.1 seems to run a LOT faster. I don’t know why it just does. I have implemented a woodstock Wizard Component, it’s perfect for dealing with complex data entry in stages. In this case a course booking system where you may have multiple trainers, delegates and courses on the same course and multiple courses on the same day. The wizard allows me to make it simple for a user to click through each stage.

I will be adding more to this post as today goes b. It’s now 6:13 am. I hardly slept with excitement at getting my hands on this release of Netbeans. (Sad I know but for those of you who’ve never stepped out of the Microsoft Campsite you are missing out).


Solaris 10

March 19, 2008

Right

1. Take one DVD copy of Solaris 10
2. Find a machine it will mostly run on - older machines tend not to work (use UBUNTU, that runs on any old dog).
3. Install
4. Install WEBMIN (PLEASE save yourself any grief )
5. Use webmin (http://localhost:10000) to set up your users (use root and your root password to login)
6. Login as the new user

Now you’re ready to work

Running Virtual Box

I couldn’t for the life of me be bothered to faff around with getting Virtual Box running. If Sun own it, it should just install and go on a Sun operating system. So instead after some whining at the purchasing manager here I got a copy of win4solaris which runs FAULTLESSLY, its fast, looks amazing and allows me to work on the sad Microsoft Access projects I have to deal with.

Running everything else

Well I’ve been using Solaris for about a week now so here goes with the things to cheer about and the things to complain about!

Cheers! Hooray!

It’s very very stable, very very very stable. It runs as fast when you turn it on as it does when you’ve been running for hours. Even with Second Life, Netbeans and other things running.

This makes my life a joy because I’m not constantly crashing or having problems.

Its FREE.

It runs Second Life (very important).

Runs Netbeans beautifully.

Has great desktop backgrounds (little things please little minds!).

Networking speed - it ROCKS when the windows users are complaining its going slow again mine is running like the proverbial wind. (perhaps greedy Solaris is stealing all the bandwidth from the Windows users).

Sad! Boohoo!

Come on Sun! Install a CONTROL PANEL. Somewhere to manage users, groups, etc like Windows has! The problem with Solaris is that you have to be willing to get inside the box and dig to use it. This could be (like Ubuntu which I think is awesome) a first rate operating system. Ok I can install webmin, fine - so bundle webmin and have a link to it from the desktop.

Also it should have something like the “APT-GET” utility in Ubuntu. (I’m not linking it again ok, just use the link above). Like a software search facility gui which also installs the packages… ok ok I’ll write somethig when I get time.

There’s a couple of projects for me when I get some spare time! (IF I ever get any spare time).


Second Life Book Launch - Kicking Butt with MIDP and MSA: Creating Great Mobile Applications.

March 18, 2008

I had some time out from RL (real life) work to attend a book launch with Jonathan Knudsen talking about his new book (title above), there was a short presentation about the book (during which Mr Knudsen dissappeared for a break when his computer decided he would have “Technical Problems”, It’s ok Jonathan, everone has to go to the toilet sometimes).

I thought the presentation was good but could have been longer. The biggest problem I guess is you want to communicate what’s in the book without actually giving the book away (kind of “Hands up who’s not here”).

Anyway - after the presentation they let us, the angry crowd loose with questions which was VERY interesting and this is actually one of the things I really like about Second Life events put on by Sun. The Q&A sessions. After the baying crowd had squeezed every ounce of interesting topics from Jonathon we retired to the Live 2.0 event on the Dr Dobbs Islands where I met a very nice guy called Dan from Sun Microsystems (sheesh they get everywhere), who asked me some more interesting questions which I’ll discuss further on..

booksigning1.jpgSo - Will I buy the book? YES why? I think because I will be doing a mobile app (or two) and I think that I’ve had enough of an introduction to have the “I’m safe spending money” feeling.

More about Jonathan’s book:
See http://kickbutt.jonathanknudsen.com/ for full table of contents
Purchase at http://www.sun.com/books (30% discount for non-Sun employees, lucky wotsits)

Over to Dan, now Dan from Sun (/me waves!) asked me some great questions, what 3 things could make developers lives easier. I am talking from a commercial developer point of view trying to show people how good Net beans actually is. I think my answers were something like this…

1. Sort out that jolly form on the Sun Developer Support site - I have Paid for Developer support, the support is fantastic BUT every time you want to submit a ticket you have to enter a whole bunch of information over and over again. I asked Dan if we could have a knowledgebase kind of system where I could log in and see my old tickets. Also the whole mode of support - if it’s a Netbeans problem with an enterprise system I really don’t want to send them my project and all the data. Especially since some projects are not allowed to be released. Why not get the guys to use the Awesome built in collaboration tools!

2. Provision of a commerce facing website. I’m won over to the “SUNny” way of thinking. But a lot of CTO’s CEO’s are still afraid of Java (like it’s some kind of monster that will bite them). I think what’s needed is a commercial facing website showing large and medium businesses running with java based solutions. This would make life easier for the poor develoepers who are won over to Java and Glassfish/Sun App server but then can’t use it in their work environment simply because “The Boss likes Windows”.

3. A free netbeans t-shirt

duke_2.jpg
Courtesy of Roman Strobl’s Blog http://blogs.sun.com/roumen/category/Duke+with+Megaphone

(3 was easy)

Anyway you know what I liked, I liked being asked the questions. That is why if you are a developer you should go into Second Life, find other developers and get in with the community, join the Java Users Group and you get invited to some really good events, that you don’t have to even leave the comfort of your office or home for.

Look me up when you’re in there! Pnc Blessed

PS Oh and by the way - the presentation screen in the picture I built when I was working for another company. :-)
PPS Sorry about the picture quality apparantly the Solaris version of Second Life has bad eyesight when it comes to taking pictures.


Solaris 10… next views

March 15, 2008

Ok so Friday I spent a whole hour in Windows (just doing some very sad access stuff). Then I had netbeans work to do so I switched to Solaris, also having Second Life running in it PLUS running over two screens after install the Latest NVIDIA driver from their site.

I found a java remote desktop tool so I can look after some windows boxes and all in all I was very impressed with the speed of the system during the day. Especially the Internet connection - I don’t know why (perhaps because I’m running IPV6) but when the windows users were complaining their internet was running slow I was still getting solid high speed.

I got the Email system talking to our works exchange server with no problem which was great.

I am running the Sun Solaris 10 rather than the open source version, mainly because we are in a production environment.

Upsides

One of the windows users asked me how many times it has crashed.. NONE I said - oh, he said I’m on about 3 times with Vista. (I make no commment here)

Its fast

Second Life runs well in it

It hooks up to my works Exchange server perfectly allowing me to work with my email. 

I’ve got access to my Windows Partition and it is happy talking to the Windows network which has been brilliant.

I do have the feeling some  of the users who walk past my desk are starting to get a bit jealous. 

When I installed Solaris it automatically set up the Grub Boot loader for me which was very cool.

Netbeans 6 runs like a dream its amazing. Far better than under windows.

Downsides

Firstly - Printing…we have a windows shared printer running on a Windows 2003 server. At present I’ve not managed to make this work.

Virtual Box - I’m getting  a silly error on this and I’m sure I’ll crack it but it really needs to be install and go folks. Once I have vbox running I’ll back up my windows system and set it up to run as a Virtual Machine under Solaris. - I’ll let you know how that goes. Because once thats done I doubt I’ll use Windows in raw mode at all. Simply no need.

I don’t like using windows now.

Summary (so far)

Solaris needs to do a NetBeans and come of age, it needs a “Control Panel” type system that makes it easy to administer things. It needs a nice program for installing software (although the terminal software is good it is better if you can just download and “RUN” a download rather than having to go into terminal and play).

But saying that it was worth the install and as a day to day os it’s rock solid and fast.


Sun Solaris…First Impressions…

March 13, 2008

OK - so having met with Sun and been doing Netbeans I decided to give Solaris a try on my Toshiba Tecra Laptop. (having used the amazing GPARTED to shrink down the Windows Partition).

First impressions.

IT’S VERY FAST considerably faster, booting takes about 12 seconds from scratch, the web is like lightening. Netbeans loads very very quickly.

So I’ve got a dual boot system but I reckon if I run up windows in a Virtual machine it could actually be JUST AS FAST as running it locally. Now - problems, this is actually the 4th machine I tried to install Solaris on, but the others world old and cranky like me.

As I tend to work 90% in Netbeans I’ll go ahead and use Solaris for a few days and report back to you all!  I’m installing updates at the moment as well so this could affect what’s going on.

I’ve not found the “APT-GET” equivalent yet in Solaris being used to Linux. But GOOD JOB SUN! I feel like I’m back on the Sunny side of the street with this!


Faces Grid selecting a single Row

March 10, 2008

How to make a Java Faces Table select just one row.
 
Thanks to Sun Developer Support for this - except for they left out an iddy bit that would stoping working.  By the way Sun Developer Support is definitely worth the money.
 
1.Create a new Web Application project, name it Row, and enable the Visual Web JavaServer Faces framework
 
2.Drag and drop a table component and a button on to the visual designer.

3.From the Servers tab drag and drop Data Sources->Travel->Tables->Person on to the table component.

4.Right Click on the Table Component and Select Table Layout.
Click on the “New” button to add a new column.
Using “Up” button move the newly added column to the top of the list.
Remove the header text.
Select Radio Button for component type and remove the text in Value Expression Field.

5.Add the following code to the page bean:
 public String getCurrentRow() {
        return tableRowGroup1.getRowKey().getRowId();
    }
  
    public void setCurrentRow(int row) {
    }
  
    private Object lastSelected=”0″;
  
    public Object getRBSelected() {
        String sv = (String)radioButton1.getSelectedValue();
        return sv.equals(lastSelected) ? sv : null;
    }
  
    public void setRBSelected(Object selected){
        if (selected != null) {
            lastSelected = selected;
        }
    }

6. In either the Outline window or the Visual Designer, select radioButton1.

7. In the Data section for radioButton1, click the … button for the selected property. A dialog box appears.
Select Use Binding, Click the Bind to an Object tab, select  RBSelected, and click OK.
The application will now use the getRBSelected() and setRBSelected() methods to display and save user input for this component.
Now change the Name property to buttonGroup
8.In the Advanced section of the Properties sheet, click the … button for the selectedValue property.
Select Use Binding, Click the Bind to an Object tab, select  currentRow, and click OK.
The application will now use the getCurrentRow() method to return the selected value for this component.

9.Drag a static text component on to the visual designer and add the following code in a button action method:

public String button1_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        String aRowId = (String)RadioButton.getSelected(
                “buttonGroup”);
        RowKey aRowKey = personDataProvider.getRowKey(aRowId);
      staticText1.setText(”You Selected ” +
                personDataProvider.getValue(”PERSON.NAME”,aRowKey));
        return null;
    }

10.Build and run the application.


Netbeans 6.1 Beta is announced

March 7, 2008

Well today I’ve loaded up Netbeans 6.1, fantastic  as usual, it’s no wonder they one that award!

So Netbeans 6.1 is here. It’s much faster than the last one at loading, which I have to say is slightly annoying as it used to take just under the time it took to make a cup of tea. Now I can barely get the milk from the fridge. Ah well.

I’ve not actually had time to dig into some of the new features but the speed of it is fantastic. I’m too busy building 4, yes 4 enterprise apps in it. In a few days I’ll write a more complete review but it seems very stable and works like a dream.

Just one thing. I’m getting bored of not coding anything substantial because the web apps are just being laid out. I am one of those programmers who likes to be challenged not given something that is too easy. They are words I never thought I’d use let alone think about anything to do with Java.


Connection to two MYSQL databases through glassfish at once.

March 5, 2008

This one had me foxed for a bit, I had to connect to two different MYSQL databases in the same app.

The problem was that the MYSQL driver that I had installed with Glassfish was an old one. As soon as I updated it and then changed the database links in Netbeans (so they would roll out to Glassfish) and then it works like a dream, in fact I noticed that the latest MYSQL driver is considerably faster being that I have a remote database coming into a netbean and out to the client.

On the topic of Netbeans, they are WONDERFUL. I love writing code in beans and having it pull the data, sort it out and send it to whatever-client-I-so-decide whether web based, app based or mobile (or something else).

Lastly I’ve installed the latest Woodstock web componants into NB for a new project I’m doing and they are really great.