Java

iBatis – Mapping Database NULL

Posted in iBatis, Java, Programming on March 29th, 2009 by Nick – 4 Comments

iBatis is a framework used to map a SQL database to POJOs (Plain Old Java Objects).  iBatis is one framework of many out there, others include Hibernate.  Recently I’ve been tasked with a new webapp which will connect to a very old legacy database.  One of the first things I decided to do was look through the database and figure out what data I needed, and then design and create java objects to hold said data.  I chose iBatis for this particular project because I was dealing with a legacy database which I had little control over, and iBatis can give me the flexibility I need in case I need to write complex and specific SQL to construct my objects. 
read more »

Quick Tomcat https SSL Config

Posted in Java, web-dev on March 10th, 2009 by Nick – 3 Comments

Setting up your webapp to work with https and SSL encryption when using Tomcat is easier than most people think.  Here’s a very quick HOW-TO to get you up and running…
read more »

GWT Right-click Context Menu

Posted in GWT, Java, Programming on February 17th, 2009 by Nick – 52 Comments

The Google Web Toolkit has been out for a while now, and yet there is still basic functionality that is missing from the toolkit.  Don’t get me started on the lack of draggable/resizable columns for the FlexTable, because that’s a rant and a half.  Given that GWT’s event handling model isn’t bad, you’d think they’d have included from the get-go the ability to handle right-clicks and bringing up a context menu or popup menu.  Well, even with 1.6 on the doorstep it seems they forgot again or just don’t care.   Now some people will spout out “web apps don’t need or shouldn’t have right-clicks handled or context menus overridden”……and for those I say STFU!  Web apps are used for more than just banking, news, forums and dare I say blogs.  The browser is becoming the new medium for running applications and just because an application is running in a browser doesn’t mean we should limit functionality.  That’s about as narrow minded as saying that we’ve only had one mouse button for this long, why add a second one?  Duh!

Anyway, enough with the blabbing.  I’ve put together a simple example to add a right click context menu and override the default browser context menu using GWT. 
read more »

GWT Yellow Fade Technique (YFT)

Posted in GWT, Java, Programming on February 9th, 2009 by Nick – 3 Comments

This is a quick example of a fading technique which notifies that a change or update in your GWT app has happened. read more »

Inserting javascript into GWT using JSNI

Posted in GWT, Java, Programming on January 27th, 2009 by Nick – 4 Comments

Sure the whole point of using GWT is so you don’t have to mess with that abortion known as javascript, but sometimes you may need (or actually want) to use javascript for something in your GWT application.  For this we use JavaScript Native Interface (JSNI).  JSNI uses the native keyword, so if you’ve used JNI (Java Native Interface) in the past you’ll have little to get used to.

I needed to use JSNI recently.  Since GWT doesn’t provide a way to bring the browser to the front or top like javascript does with it’s self.focus(); I was able to use JSNI to call that line of javascript.  Here’s a quick example:

public static native void bringToFront() /*-{
  self.focus();
}-*/;

Then all you need to do is call the bringToFront() method like you normally would.  Along with noticing in the native keyword, you’ll immediate see that the block looks commented out.  JSNI has two tokens to mark the beginning and end of your javascript the /*-{ marks the begin and }-*/ marks the end.  Everything in between those tokens are assumed to be javascript.

There are more examples on GWT JSNI site.