emscroger
Contributor
Contributor

callActionsController is not a function


While testing our plugin, we try to invoke an action to our service layer from our javascript client code, but the request fails saying callActionsController is undefined, and 'is not a function'.   I know other parts of our client code using callActionsController to 'login' to our plugin and that works fine.  Also, we can call WEB_PLATFORM.getObjectId() and that works, but the next call to invoke callActionsController fails.


If we look at the source for WEB_PLATFORM.js, you can see the other methods that work are clearly defined.  However, callActionsController() is not declared in the javascript source.  I see that WEB_PLATFORM is bound to an element id named 'container_app'.  I imagine that container_app must provide the callActionsController call in a some sort Flash/Flex type object.   Could this be a Flash player issue? 


E

0 Kudos
8 Replies
laurentsd
VMware Employee
VMware Employee

callActionController is only available inside a dialog initiated by an action or when using the new openModalDialog() function in 6.0.

To call your service layer from a regular html view you need to use regular rest calls.

0 Kudos
emscroger
Contributor
Contributor

So we are using our own dialogs to call the actions controller directly via REST, but we get 401 unauthorized failure.  What do we need for a proper request?

I've crafted some javacript to send the following information:

  • actionUid -> our action
  • targets -> objectId
  • webClientSessionId -> from WEB_PLATFORM.getUserSession(), get session key from server?   What do we send here?
  • locale -> from WEB_PLATFRM.getLocale()
  • json -> our request as before
0 Kudos
laurentsd
VMware Employee
VMware Employee

By "your own dialog" I assume you are not using the dialog associated with an action in plugin.xml and are not using either the openModalDialog from 6.0. You cannot have your action controller invoked from such custom code.

You need to refactor your code so that your custom dialog calls a simple java service which in turns calls the logic from your action controller.

0 Kudos
emscroger
Contributor
Contributor

We figured it out and got it to work using the session id from WEB_PLATFORM.

0 Kudos
msoni11
Contributor
Contributor

Do callActionController method have callbacks after success ?

0 Kudos
laurentsd
VMware Employee
VMware Employee

There is no javascript callback because you are supposed to close the modal dialog after invoking callActionsController.   In that model your javascript code is very short lived and you can use the ActionResult utility class to report object creation or errors as shown in the chassisA sample code (see also "Headless actions" in docs/html-bridge.html).  If you really need a call back to do further processing you must use your own implementation, i.e. make an http call from your dialog and handle the callback in the dialog, which forces you to keep the dialog opened to display success or error messages inside.

0 Kudos
msoni11
Contributor
Contributor

I've tried but it didn't work for me.

Where can I check callActionsController definition ?

Msoni

0 Kudos
laurentsd
VMware Employee
VMware Employee

what didn't work?   Check callActionsController in the HTML bridge doc and in the chassisA and chassisB sample code.

0 Kudos