VMware {code} Community
Sumit_Tyagi
Enthusiast
Enthusiast
Jump to solution

How to expose java objects in javascript so that javascript objects show method signatures with <ctrl> space in scripts

Hi All,

I am exposing java objects in javascript, but the methods and attributes does not show up in context help menu (<ctrl> + space) when I use those javascript objects.

How should I write my vso.xml so that the javascript objects are aware of the methods in the javascript context help menu.

eg:-

vso.xml entry:

<enumerations>

  <enumeration type="TestEnum">

   <description>Defines values for boolean xml Managed Object attributes</description>

   <entries>

    <entry id="test1" name="TEST1">value for Test1.</entry>

    <entry id="test2" name="TEST2">value for Test2.</entry>

   </entries>

  </enumeration>

</enumerations>

<scripting-objects>

<object script-name="MyObject" java-class="com.test.MyObject">

   <description>This is a test Object</description>

   <attributes>

    <attribute java-name="attr1" return-type="String" script-name="Attr1" show-in-api="true"/>

    <attribute java-name="attr1" return-type="String" script-name="Attr1" show-in-api="true"/>

   </attributes>

   </attributes>

   <methods>

<method java-name="testMtd" return-type="String" script-name="testMtd" show-in-api="true">
<parameters>
  <parameter name="param1" type="Any"/>
  <parameter name="param2" type="String"/>
  <parameter name="param3" type="boolean"/>
</parameters>
</method>

   </methods>

  </object>

</scripting-objects>

JavaScript:-

var myObj = new MyObject();

myObj.<ctrl>+space does not popup any context menu, as it does for string objects or System object.

myObj.testMtd("abc", TestEnum.<ctrl>+space - Enums also do not pop up values.

Any help will be greatly appreciated.

Best Regards,

Sumit Tyagi

Reply
0 Kudos
1 Solution

Accepted Solutions
tschoergez
Leadership
Leadership
Jump to solution

I see the use case, and it would make sense to have autocompletion for it, but AFAIK that's not possible right now.

(I think it's comparable to the VcPlugin object. Nice helpful methods in there, but no autocompletion)

View solution in original post

Reply
0 Kudos
4 Replies
tschoergez
Leadership
Leadership
Jump to solution

Hi Sumit,

auto completion AFAI only works for objects that have been bound as parameters for that scriptable task, not for the "plain" javascript objects.

Cheers,

Joerg

Sumit_Tyagi
Enthusiast
Enthusiast
Jump to solution

Hi Joerg,

Thank you for your assistance. I got the point now.

Actually I have a class with static utility functions, which I would like to show up in context menu without making it as parameter.

I saw that System class does the same, so thaught if there is some way to expose my object in that same way.

Best Regards,

Sumit Tyagi

Reply
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

I see the use case, and it would make sense to have autocompletion for it, but AFAIK that's not possible right now.

(I think it's comparable to the VcPlugin object. Nice helpful methods in there, but no autocompletion)

Reply
0 Kudos
Sumit_Tyagi
Enthusiast
Enthusiast
Jump to solution

Thanks Joerg! Smiley Happy

Reply
0 Kudos