Thursday, August 18, 2005

BB : Updating your application via Desktop Manager

The trick to getting DM to recognize that an application has been updated and hence a new version needs to be downloaded is to change the "Version:" under "Project/Properties/General".



Monday, August 15, 2005

Misc : Programmatic Java scheduling cron

Had a need for some scheduling operations. I could have done it myself using java.util.Timer but then stumbled across Quartz, an open source component.

From their website, "Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components or EJBs. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering."

Nice one!


BB : Adding an icon to your program

Use .png format.

Add the image to your project, then right click on the image file in the IDE, "Properties / Use as application icon".



Friday, August 12, 2005

BB : Getting a guid for Event Log

Ensure you are not in debug mode.


long guidName

Drag the cursor to highlight "guidName" and then right click.

Select "Convert guidName to long"

"guidName" will be replaced by the generated guid xL

Just edit to add "guidName =" before the xL to create

long guidName = xL;



BB : Logging to Event Log

String myApp = "My App";
long appId = 0x8b979f96520ee725L;
EventLogger.register (appId, myApp, EventLogger.VIEWER_STRING);
String logMessage = "This is a test";
if (EventLogger.logEvent (appId, logMessage.getBytes()))
System.out.println ("Log successful");


Note: To see how to get the guid 0x8b979f96520ee725L see my next post.


BB : Getting selected RadioButton option

RadioButtonGroup rbg = new RadioButtonGroup ();
rbA = new RadioButtonField ("A", rbg, true); // Selected by default
rbB = new RadioButtonField ("B", rbg, false);
add (rbA);
add (rbB);

boolean isA = rbA.isSelected ();



BB : Getting selected item in ObjectChoiceField

String [] choices = {"A", "B", "C"};

ocfChoice = new ObjectChoiceField ("Select choice", choices, 0) ;
add (ocfChoice);

int index = ocfChoice.getSelectedIndex();
String selectedChoice = choices [index];