Last Updated: February 25, 2016
·
352
· sebastianconcpt

Get the url for a Seaside callback programmatically

Some times you need it from anywhere, not just a component.

This method here will return an object that will render the javascript function that will open a second tab in the browser navigating to the url and doing whatever the [ self onSelected ] block is doing:

onSelectedFunctionOn: html 

| selectedCallback actionUrl param fullUrl |

selectedCallback := WAActionCallback on:[ self onSelected ].
actionUrl := html actionUrl copy.
param := html callbacks store: selectedCallback.
actionUrl addField: param.
fullUrl := self session applicationUrl, actionUrl asString.

^ JSFunction new argument: 'anEvent';
    add: ('anEvent' asJSObject notNull then: 'anEvent.stop()' asJSObject);
    add: ('window.open("',fullUrl,'","_blank", "");return false') asJSObject;
    yourself