Here's a quick one that I tried out for the first time today. Someone asked if it was possible for a CF app to have a desktop notification on the server it's running. CommandBox servers have a try icon that runs inside the JVM of the server that can create popups and even Swing windows. Turns out, it's actually really easy to tap into this to get a toaster popup on your desktop. Of course, this wouldn't work if you're running CommandBox as a Windows service or on a headless server like Linux with no GUI!
All we need to do is tap into a static displayMessage() method on an internal java class in the server.
lu = createObject( 'java', 'runwar.LaunchUtil'); lu.displayMessage( 'Just letting you know', 'INFO', 'The sky is still blue', 5000 ); lu.displayMessage( 'Hold on there', 'WARNING', 'You can''t talk to me like that', 5000 ); lu.displayMessage( 'STOP...', 'ERROR', 'Collaborate and listen', 5000 );
The 5000 is the number of ms until the message hides itself. Pass a 0 if you want the popup to stay until the user explicitly closes it. Here's what it looks like.
Have fun with this, but don't abuse it. This comes with no warranties and is probably only really useful for some sort of local development purposes where you want one of your local servers to be able to flag you down when it's done with a process.