XPage automagic.java file contains stale code

  • I code in a local template, then refresh to a remote server, then hit that server using a browser like an actual user would. Every now and then, quite sporadically, updates done to an XPage simply do not “take”.

  • This just happened while fiddling with a sample application for a PMR. In this instance I have a script block at the bottom of the XPage, and I stripped most of the code out of this script block, leaving it there but with only a few lines of JS that really do nothing other than have something to run.

  • When I “Build Project” and applied changes, the old script block code keeps running. I know this because the deleted code contained a reference to an Agent that doesn’t exist in the sample, and the server console keeps complaining that the Agent can’t be found.

  • When I search for code that would touch off that Agent, I find it … in the .java file. When I look, I see a private UIComponent createScriptBlock() method in that .java file, and it clearly contains code that no longer exists on the XPage.

Here’s the script block:

<xp:scriptBlock>

	<xp:this.value escape="false"><![CDATA[

window.onunload=function() {

if(!userClick) {	

	userClick=false;									// Only skip once

} // !userClick

} // onunload

var userClick=false;

var debug=true;

	]]></xp:this.value>

</xp:scriptBlock>

Here’s the corresponding .java after building it:

    private UIComponent createScriptBlock(FacesContext context, 

            UIComponent parent, PageExpressionEvaluator evaluator) {

        XspOutputScript result = new XspOutputScript();

        String sourceId = "/xp:view[1]/xp:scriptBlock[1]/xp:this.value[1]/text()";

        String valueExpr = "window.onunload=function() {\n\tif(!userClick) {\t\t\t\t\t\t\t\t\t\t// User button click prevents this\n\t\tdoAjax({\n\t\t\t\"OP\" : \"Unlock\",\n\t\t\t\"User\" : \"#{javascript:@UserName();}\",\n\t\t\t\"UNID\" : \"#{javascript:doc.getDocument().getUniversalID();}\"\n\t\t}, \"(doIt)\", -1, \"File unload\", \"#{id:catsMsg}\");\n\t\tuserClick=true;\t\t\t\t\t\t\t\t\t// User click consumed\n\t} else {\n\t\tif(debug) console.log(\"* File: User click unlock bypass *\");\n\t\tuserClick=false;\t\t\t\t\t\t\t\t\t// Only skip once\n\t} // !userClick\n} // onunload\nvar userClick=false;\nvar debug=true;";

        ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);

        result.setValueBinding("value", value);

        return result;

    }
  • When I build this after entering all the above, the .java is correct.

  • At this point I would normally abandon this post on the assumption that I simply forgot to build it, but I know this script block is all I edited, and when I look at the status bar history, I see the Xpage was the only thing updated. This means either DDE updated only this one Xpage without any changes to it, in which case I did forget to rebuild it, or I did in fact rebuild it and DDE’s automagic failed. At this point it’s impossible to prove one or the other, unless it’s in a log somewhere.

Thanks for your time…

Subject: Did autobuild switch off?

I have only ever seen autobuild switch itself off outside of the 8.5 beta (which happened a lot back then).

Normally you get a popup warning you though.

If something did go wrong it should have something in the trace logs in the help menu, or in the IBM_TECHNICAL_SUPPORT folder.

Subject: Thanks Simon…

  • I wasn’t aware the Help menu had trace viewing. Nice.

  • I see scads of errors here, many of which say “SEVERE” in the second column, but none of them appear around 1300 when I posted this. There are a series of font-related WARNING entries at 1148. View Log & View Trace appear very similar, except Log has more data about WARNING, and Trace has more data about SEVERE. At least that’s what I see at this moment.

  • I don’t use automagic build. I have only one database open and do “Build All” when I’m done with all the editing I will do that go-round, then I refresh the server from my development template and check it out. I’ve had a simply mind-boggling amount of trouble with DDE, and one of the things I’ve discovered is not using automagic build reduces the number of Exception dialogs I get. I prefer doing manual builds, anyway.

  • I have seen automagic build turn itself off dozens of times. That’s another reason I don’t use it … I can’t count how many hours I’ve wasted trying to figure out some issue, when what’s happened is automagic build turned itself off so my code isn’t being updated any longer. Doesn’t take much of that to be enough. (shrug) I’ve experienced this up through FP2, which I’m using right now.

  • That’s why my post indicates either DDE updated inappropriately, or I failed to build it, as opposed to DDE updated inappropriately, or DDE failed to build it. If automagic build were supposed to be on, but turned itself off again, I wouldn’t post about a build issue. I’d chalk it up automagic biting me in the rear again and drive on. But I’m pretty sure I did build it, and refresh history on the status bar supported that, so I posted anyway.

  • For some reason the SUPPORT directory contains a whole pile of console files, all of which contain 1K of … mess. It’s like the logger thinks the file should only be 1k and is doing wrap-around logging, so newer entires appear on top and older ones are one the bottom, but never more than 1K of actual log. I seem to recall I set up some sort of debug logging way back when, for a PMR, and that utterly borked client logging. That’s never been addressed. I’d be delighted to have the normal logging back again.

  • Just poked around in my notes.ini and don’t see anything out of the ordinary, other than an HTTPJVMMaxHeapSize entry, which seems out of place in a client’s configuration. There is not one single entry concerning console log file, console log enabling, debug setting, or anything of that nature anywhere, by visual inspection or regexp search. Any ideas what’s going on there?

Thanks for your time…