This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 2, 2011, 11:59 AM
2 Posts

I loose scripts in html

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 6
Hi,
I got a very irritating problem: I have a link wich changes a sessionScope variable via Server Side script (it hides or opens disgnated fields). It worked for some time, but then out of sudden it just stopped working! When I tried to debug, it turned out that when I see the source code of the page in html there is NO script attached to the link at though I have not changed anything.
The script goes here:

if (sessionScope.get("docToCollapse")=="Expand") {
    sessionScope.put("docToCollapse","Collapse")
}
else{
sessionScope.put("docToCollapse","Expand")
};
 
And besides, I got another issue. When I copy pasted one link from one Xpage to anohter I got load of errors poping up - it turned out that some how all the scripts (both serverside or client) got doubled in the source code of the xpage. How it happened - I have no idea, because I found scripts doubled on the entire page, all of them.

Pls, help me out, I am getting desperate with it.
Thank you!
Apr 4, 2011, 7:20 AM
261 Posts
Re: I loose scripts in html
Hi,
 
  • When you looked at the source of the page: did you only look at the link-tag (<a href=) ? It's normal that you don't see any events attached there: all events are attached at the end of the XPage using (XSP.attachEvent) calls.
  • Regarding the duplicate scripts: I've experienced that myself a couple of times too. It occurred by me to when copy-pasting code. Only fix I know of is to manually delete the duplicates.
Mark
 
PS: if you want to make your code a little more compact, you can use a shorthand JS expression for IF-statements:

( <if statement> ? <true result> : <false statement> )

Your function would then look like this:

sessionScope.put("docToCollapse", (sessionScope.get("docToCollapse")=="Expand" ? "Collapse : "Expand") );
Apr 4, 2011, 10:39 AM
29 Posts
Re: I loose scripts in html
Mark, Thank you for the advise on the syntax, I will use that!
 
Regarding the  script itself, I also looked at xsp.attachEvent, and I saw the following:
 
 XSP.addOnLoad(function() {
XSP.attachEvent("view:_id1:_id2:_id4", "view:_id1:_id2:image1", "onclick", null, true, false);
XSP.attachEvent("view:_id1:_id11", "view:_id1:_id10", "onclick", null, true, false);
XSP.attachEvent("view:_id1:_id12", "view:_id1:link11", "onclick", view__id1__id12_clientSide_onclick, true, false);
XSP.attachPartial("view:_id1:_id13", "view:_id1:link12", null, "onclick", function(){}, false, "view:_id1");
XSP.attachEvent("view:_id1:_id14", "view:_id1:link13", "onclick", null, true, false);
XSP.attachEvent("view:_id1:_id15", "view:_id1:DealsLink", "onclick", null, true, false);}
Maybe I do not understand smth, but it looks like, as if there were no code written in designer, which is not true.
Apr 5, 2011, 11:00 PM
122 Posts
Re: I loose scripts in html
I've seen some issues with duplication of code when pasting into the Design pane in Designer. As far as I know it doesn't occur if you paste into the Source pane. Another tool that may be of use is, if you're in the Source pane, you can right-click and there is a menu option Compare With -> Local History. This allows you to access and compare prior versions of your XPage to retrieve the working code. This is updated every time you save and tied on the XPage/Custom Control name. It's standard Eclipse functionality, so something that comes natively because Domino Designer is now on Eclipse.
Apr 6, 2011, 6:03 AM
29 Posts
Re: I loose scripts in html
 Thank you, Paul! I will also use that feature.
But the issue with the vanishing script bothers me more, since I cannot use any script at all. 
Apr 6, 2011, 10:05 AM
122 Posts
Re: I loose scripts in html
Check to ensure the event handler is in the right place, i.e. a child of the correct XPages control. I've had that problem before, where my event wouldn't trigger because it was attached to the wrong control. I eventually worked it out by using Compare With\Local History from the right-click menu in the Source pane and rolling back to a previous version. 
 
I've seen something like that with client-side javascript script not getting rendered to the browser at all though. The strange thing was it was a basic error page I'd copied across. In one database the section expanded, in another it didn't. The code was identical. I think I ended up deleting the XPage and pasting the code into a new version. It may be that something gets broken in the underlying conversion to Java (in the case it never gets rendered to the browser at all). In that case I'd probably try copying and pasting the code into something like NotePad from the Source pane, then copying and pasting it back into a new XPage, just to ensure it's definitely just plain text you're pasting in. One of the beauties of XPages is we can do something like that, which was not possible in forms-based design.
Apr 13, 2011, 8:07 AM
29 Posts
Re: I loose scripts in html
 In fact it was the second time I encountered this problem and I tried to solve it with copy-pasting into a new XPage.
Actually I resolved the issue - I also have a dojox widjet on the page (graphs) and the "compressed" file (i.e. the one where the code is compressed into single line) was loaded with an error. But when I totally deleted the widjet and the source link to dojox, everything went just fine. 
It seems that this error just blocked all the other scripts. 
 
Anyway, thanks for help! 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal