AbstractJavaScriptComponent: How to add Javascript function as class member

In our subclass of AbstractJavaScriptComponent we need to be able to set a member of this implemented class to a Javascript function. I have tried using JSNI to do this, by implementing a native method like this:

public native JavaScriptObject myFunc() /-{
$doc.myFunc(date, ‘hour’, 1);

public MyComponent extends AbstractJavaScriptComponent {

private JavaScriptObject funcMember;

public MyComponent() {
funcMember = myFunc();

However I get an UnsatisfiedLinkError. I read elsewhere in these forums that one cannot use JSNI in this way. Can someone recommend an alternative solution?

You’re trying to execute Javascript/JSNI in the Server side of your Javascript Component. The code inside MyComponent will only be executed on the Server.
As you’re making a custom Javascript Component you should have a Javascript connector file where you can do all of your clientside programming.
So also things like:

function foo(str){