Wednesday, April 28, 2010

How to invoke a Java method from JavaScript

It's surprisingly easy. Basically the applet you declare in the <applet> tag sets up the Java class as an object that can be referenced with standard DOM calls.

For the purpose of this example, I'm not displaying anything with the sample applet, only returning values from method calls, so the code doesn't import awt or Swing, only java.applet.Applet.

Here is a sample java class that exposes two methods, add and subtract:
package cea.demos;

import java.applet.Applet;
public class Arithmetic extends Applet {

  public int add(int x, int y) {
    return x + y;

  public int subtract(int x, int y) {
    return x - y;

Tuesday, April 27, 2010

Using File-AID Batch to update multiple PDS members

Today at work I found I had multiple members of a partitioned data set that I wanted to update from a batch job. I had previously written an RPF to do this, but post-Sarbanes/Oxley fallout has caused us to change our dataset permissions and procedures somewhat, so I needed to update with JCL this time.

I was trying to fool around with using TSO edit commands to update the files using IKJEFT01 to invoke a TSO shell, and my boss saw what I was doing and suggested File-AID instead. File-AID is very flexible and fast, but the documentation is a little daunting, and I've never taken a class on it or found any tutorials that I could tolerate. However, with some trial and error I was able to get it to update my dataset members without any problems, and my final JCL read pretty well, unlike some of the more unintelligible arcana I've submitted to the mainframe in the past.

Sunday, April 25, 2010

DHTML events - blast from the past

Back in 2003, I was working on JavaScript code that would function as a text editor/web page authoring tool. It worked within a browser without textarea or other input fields (text you typed appeared in the main body of the page). It was semi-functional, including pop-up right-click menus that let you paste in a few HTML tags, a Java applet to read and write files to disk, and instructions for the user to allow the applet disk access. The whole thing was pointless, as even back then there were better rich text/WYSIWYG web page editors out there, but it was a fun programming exercise. The original source for it is available here if you want to download it and toy with it. It works with IE8, but I think there was a new problem introduced with modern Firefox versions that I never got around to fixing. I also just tried it in Chrome and it just silently fails. Bummin'.

Here are a few screenshots of it in action, showing how to start with blank page, open the right-click menu to add some stuff, and testing the results:

Monday, April 19, 2010

Tax-time blues ain't so bad

I've been away from the blog for a while, due mainly to not having anything I wanted to share, and also being low on creative energy. My work has been draining my batteries for a change, which is good. This week should afford me renewed blogging time and energy, as I'm in a training class that gives frequent breaks, and has frequent problems sharing desktops and application servers with remote students.

So Liberty got laid off, which has so far not had a dramatic impact on us. She gets to spend more time with Scout and her mom, and has been pretty relaxed at home. I no longer get my two nights per week alone with Scout, which I have mixed feelings about. Liberty is also stumbling through the beauracracy of Job & Family Services again to attempt to get unemployment benefits. They seem to be using the fact that she is in school to avoid paying benefits, so she's in the process of job hunting.

My work may also be going into the laying off business pretty soon. (news article) That would put us in an interesting position after a few months, namely being hobos. Or selling off all our garage and basement crap on ebay while scrambling for new jobs.

Tax season was pretty bad, but not life-altering. I owed more money than I got in my annual bonus, and had been unable to save up for the IRS because of the extra financial burdens I've talked about in previous posts. So I made a deal to pay what I could up front, and pay up in full (plus a modest penalty) within 120 days. So no playing for a while, but no debtor's prison either. So it goes.