, Jan 3, 2012 12:27:27 AM
Steve Pridemore , Dec 12, 2011 10:03:15 AM
Would you be willing to post this code to the XSnippets site?
http://openntf.org/XSnippets.nsf/home.xsp
David Gilmore, Jun 19, 2011 8:59:39 PM
- I'm using a stripped-down version of this on a custom control to link a XPage event handler to a djit.form.ComboBox. It appears to work, in that it does refresh the page, but two things:
1. print() in the SSJS of the eventHandler() never produces output on the console as expected.
2. After reloading the page, the dijit.form.ComboBox tosses an error in d._toDom, which it does not do on intial load.
- If I take out the XSP._partialRefresh() the page reloads without error. I suspect that's changing the DOM in some manner that's incompatible with dojo, but I haven't figured out how.
Any clues would be greatly appreciated!...
Sergey, Aug 31, 2010 9:22:39 AM
Jeremy,
I just want to say: thank you a LOT for this great sharing! I've implemented this technic in my project and it works great.
kester simm, Jul 22, 2010 6:34:38 AM
Just noticed an error put the function in an variable t.ex utils and it will work:
var utils={
getComponentID:function(id){
var componentID='';
dojo.query('[id*=\"'+id+'\"]').forEach(function(node, index, arr){
var result=node.id.split(':');
if(result[result.length-1]==id){
componentID=node.id;
}
});
return componentID;
}
}
kester simm, Jul 21, 2010 8:47:37 AM
Really usefull code. I had one problem though with the partial uppdate id.
if you only have one node which has in the id "refreshTarget" then it will work
e.g.
dojo.query('[id$="refreshTarget"]')[0].id
otherwise if you have serveral nodes containing "refreshTarget" then this could be a problem
i wrote the following code to get exact the write node:
getComponentID:function(id){
var componentID='';
dojo.query('[id*=\"'+id+'\"]').forEach(function(node, index, arr){
var result=node.id.split(':');
if(result[result.length-1]==id){
componentID=node.id;
}
});
return componentID;
}
if you did the code direct in a script block then you only need:
dojo.byId('#{id:refreshTarget}').id or XSP.getElementById("#{id:refreshTarget}");
but we all use script libs so that's not available. :-)
i also wrote a function which gets the node:
getComponent:function(id){
var component='';
dojo.query('[id*=\"'+id+'\"]').forEach(function(node, index, arr){
var result=node.id.split(':');
if(result[result.length-1]==id){
component=node;
}
});
return component;
}
JJTB Somhorst, Jun 24, 2010 10:57:37 AM
Thanks for this tip Jeremy. I just tested it a bit around and was able to create an custom control with it that listens real time to the progress of an agent. So the agent does its calculations and saves the progress in a document. While the agent is running that document is read by a timed refresh of a custom control.
I dont run into the problem that buttons and comboboxes loose their focus / control ?
Jeremy Hodge, May 11, 2010 12:57:36 PM
Hello Antonio, you can see an example @ the XPages Blog samples site:
http://www.xpagecontrols.com/xpagesblog.nsf/programmatically-triggering-an-xpages-server-side-event-hand.xsp
This has a demo and all the sample code posted.
Antonio, May 11, 2010 12:50:36 PM
Hi :
I am trying to implement this example but I have some problems, Could you please send me this code implemented ? thanks in advance
David Gilmore, Apr 23, 2010 10:19:35 PM
- Thanks Jeremy. I've had continual, random, and recurrent issues with sever-side actions simply not working. I suspect I'm back in that boat, if you see it triggering, and what you see is quite frankly what I would have expected, since the |saveDocument| is the same in either case. (sigh) There it is. Still a brilliant bit of work!
Jeremy Hodge, Apr 23, 2010 7:37:35 PM
It appears to be triggering the postSaveDocument without issue.
You can reference this example to see what I mean:
http://www.xpagecontrols.com/xpagesblog.nsf/programmatically-triggering-an-xpages-server-side-event-hand.xsp
The example edits a document, and when you click a button, it uses the executeOnServer function to execute the event, which does a simple xp:saveDocument ... then the postSaveDocument increments a click counter, and the counter is returned to the browser, incremented. The example has a slightly updated version of the executeOnServer function that fixes an issue with executing an event handler in a custom control, but you need to send the full id of the event handler, not just the name. It's covered in detail in the example.
David Gilmore, Apr 23, 2010 7:19:34 PM
Sadly I don't see a |saveDocument| triggered in this manner firing |postSaveDocument| automagically like it does when I put |saveDocument| on clickable event handler (a link for example). I put two |eventHandler| on initially, one exactly as your example and one with submit="true". I called the latter, and Firebug shows the server hit, but nothing else runs. Did I do something wrong?
David Gilmore, Apr 23, 2010 6:25:34 PM
BRILLIANT! I knew there had to be some simple way as well, and simply hadn't dug in the right place, I guess. Hat's off to this bit of work...
stephen hood, Apr 15, 2010 5:28:33 PM
Jeremy I have been checking out Xpages in 8.5.1 using the free designer and right out of the box started having problems with some basic controls on just a simple test page.
It looks as if standard controls like the combo boxes lose their keyboard functionality IF they are the target of a partial refresh.
I HAVE to use the mouse to get the keyboard control back on track. Problems manifest differently depending on browser.
Take out partial refresh and everything works as expected but then I obviously lose the cascading lookup, enable/disable features I'm looking to incorporate by just refreshing part of the page those controls are contained by.
Have you been seeing this kind of stuff or am I going insane :).
Trying to get some feedback from people that are obviously getting deeper into the Xpages stuff. Right now it's feeling like Xpages is a waste of time on really straight forward requirements.
My first impressions are the client-side js, server side js, partial refreshes, documents, XSPDocuments, JSF lifecycle, dojo widget complexity is resulting in an unstable event model for even relatively simple requirements in the UI.
Which kind of defeats the point of Xpages. Really appreciate any thoughts on your xp. Privately if necessary.
Jeremy Hodge, Apr 15, 2010 11:05:33 AM
@Patrick ... Good ol' reverse engineering ... I figured there has to be some way for the client side to notify the server side which handler to execute since you can have multiple handlers within a refresh area ... so from there its diving into the uncompressed javascript files on the server (in the data/domino/js/dojo-1.3.2/ibm/... folder) and then experimentation with the domino generated code to see how/where it identified the event handler.
Patrick Picard, Apr 15, 2010 10:56:32 AM
That is extremely cool stuff and goes a long way towards MVC. Since there is so little Xpages documentation, how do you manage to dig things up like that?
Paul Wthers, Apr 15, 2010 7:01:32 AM
As you say, it's very pwoerful and a great trick