-
I just squandered FOUR HOURS getting a relative path to work for a script library under this.resources. FOUR HOURS for something that should have been brain-dead trivial, but it’s an XPage, where what used to be impossible is simple, and what used to be simple is impossible. Here’s the final result, so anyone interested can see it without having to wade through the rant first:
<xp:script clientSide=“true” type=“text/javascript”>
<xp:this.src><![CDATA[#{javascript:
var url=context.getUrl();
var path:String=url.toString()
var parts=path.split(‘/’);
var newpath=“”
for(ndx=3; ndx<parts.length; ndx++) newpath+=‘/’+parts[ndx];
url.setPath(newpath+‘//<path to .js>’);
url.toString();
}]]></xp:this.src>
</xp:script>
- Is that just about a nightmarish load of bull or what? For one relative path!
-
NOTHING indicates xp:this.src even exists: I stumbled upon it entirely by accident. I found a post here on Notes.net that had xp:this.contents here, and what that does is provide a literal value. No execution takes place. Seeing one magically unrevealed subordinate tag, literally on a whim I replaced that with xp:this.src, and it worked! Near two years after XPages are released and still the “documentation” pathetic, competing with low-end Asian products for the most useless instructions possible.
-
@DbName() is near useless: This keeps returning the fully qualified name, and even if one does @Name() on it, there is still the question of the protocol. Is it http, or https?
-
The automagic escapes @DbName(): So ignore Item 1 above and play with the db path. @Subset(@DbName(), -1) is automagically escaped, so the / are converted to %5D “for” me. WHAT??? This is a SOURCE URL. What drooling moron put that in? To rub salt in it, escape=false does not work on xp:script. So the most obvious solution is completely useless.
-
split()'s return is broken: The next obvious thing is to split() and take the parts needed. While in my particular instance “parts.length” returns 5, putting “parts[parts.length-2]” in a statement causes index out of bounds: -1 every single time.
-
The automagic rapes you in the end: Finally, after working around the outright bugs, I get newpath to contain a full path, protocol and all, to my resource. Naturally if one does ndx=0 in the for(), one gets the entire path. But Domino automagically prepends the path to the current database to this value even if the protocol is present, raping it utterly. This is about ignorant.
-
But wait, there’s more: The old-school trick was to put the url in square brackets: . This is a nightmare. Not only does it suddenly automagically escape the URL just like @DbName, but the leading [ is missing (as expected) and the trailing ] is escaped as well. This is not about ignorant. It is pathetically ignorant.
-
The automagic is inconsistent: The “fix” is to set just the path to the resource on the url, then do toString(). This should be identical to returning a string but it is not.
-
DDE randomly fails to update code: After all was said and done I thought it was failing even though the generated URL was correct. On second look I noticed the generated URL was not correct, it was the value computed just before the last save, while I was still fiddling with it. This happened to me about four times during that four hours; I would change something, hit CTRL-S, it would look like it saved, the editor would show the updated code, but the server would not use it. Build automagically was enabled. Clean & Build did not fix it. What is the point of “Clean” if it’s going to keep stale code on the server??? I could close the editor and reopen it; the updated code was right there but the server would not execute it!!
The ONLY way to fix it was to change something dramatic, like delete an entire block of code, save it, run it to be sure that block was missing, then restore that block of code and save it again. After all the other crap this was about infuriating, especially the third or fourth time.
- Two, four, five, six and seven are prime examples of why automagic sucks. Automagic always has sucked. Automagic always will suck. This is Lotus RAD: REALLY ANNOYING DEVELOPMENT.