VMware vCenter

 View Only
  • 1.  How to expose java objects in javascript so that javascript objects show method signatures with

    Posted Jul 11, 2013 06:21 AM

    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



  • 2.  RE: How to expose java objects in javascript so that javascript objects show method signatures with

    Broadcom Employee
    Posted Jul 19, 2013 07:35 PM

    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



  • 3.  RE: How to expose java objects in javascript so that javascript objects show method signatures with

    Posted Jul 22, 2013 08:10 AM

    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



  • 4.  RE: How to expose java objects in javascript so that javascript objects show method signatures with
    Best Answer

    Broadcom Employee
    Posted Jul 23, 2013 10:51 PM

    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)



  • 5.  RE: How to expose java objects in javascript so that javascript objects show method signatures with

    Posted Jul 24, 2013 10:37 AM

    Thanks Joerg! :smileyhappy: