I’m developping a Servoy plugin in Java.
I noticed that, whenever I wish to call this plugin to return an Object I created in Java, and then call methods upon this method there is no useful description of what the method does.
As I know from experience in Java, we use JavaDoc annotions for each method. When we call this method in Java, there is a ‘tooltip’ with the full description. Is there a way in Servoy to get this description too?
Example of what I wish to have:
var object = plugins.myPlugin.getMyObject();
object.executeMyMethod(1, 'test string', 'other test string');
So in Servoy, when I call the method ‘executeMyMethod()’ the auto-fill does => executeMyMethod(number, string, string);
But when I hover over this method, i don’t get any usefull description of what values need to be provided as parameters.
To avoid any confusion, it’s not the tooltip you get getToolTip() method of the IScriptObject Provider.
That is just the thing, that is to call methods withing the Provider class.
I’m calling a method in Servoy that returns an object (created completely in Java) that contains methods. After I do this:
var object = plugins.myPlugin.getMyObject();
I wish to call the methods provided by this object class doing so:
object.executeMyMethod(1, 'test string', 'other test string');
But when calling this method, I don’t have any indication what these variables mean. The only thing I get is
object.executeMyMethod(number, string, string);
I wish to descripe this number, string, string so the user knows what specific values need to be delivered. Something like
number = age
string = name
string = surname
This can’t be achieved with the getParametersName() method cuz that is only for methods you create in the Provider class, NOT in Java
also let that return object also implement “IScriptObject” interface
and implement there you stuff, Do return that one also in the getReturnTypes() of the main provider class.
jcompagner:
also let that return object also implement “IScriptObject” interface
and implement there you stuff, Do return that one also in the getReturnTypes() of the main provider class.
Better explanation Johan, that is what I meant to say. Thank you
In my main Provider class, there is the object ‘myObject’ in the ‘getAllReturnedTypes()’ method.
So in the Java class of myObject, this implements the IScriptObject and I added the required methods such as ‘getParametersName()’ and ‘getToolTip()’ etc…
Here I specified in the getParametersName() method the method i wish to call and the parameters this method needs. But when I try to call my method in Servoy, there still isn’t any description or tooltip that defines what the parameters are…
What am I doing wrong?
This is the main provider class. Here you can see I return the ProofHQObject.
public class ProofHQProvider implements IScriptObject {
public ProofHQObject js_getProofHQObject(String pEmail, String pPassword) {
ProofHQObject obj = new ProofHQObject(pEmail, pPassword);
return obj;
}
public String[] getParameterNames(String methodName) {
if (methodName == null)
return null;
if ("getProofHQObject".equals(methodName)) {
return new String[] { "Email", "Password" };
}
return null;
}
public String getSample(String arg0) {
return null;
}
public String getToolTip(String methodName) {
if ("getProofHQObject".equals(methodName))
return "Get a new ProofHQ object to login and begin transactions.";
return null;
}
public boolean isDeprecated(String arg0) {
return false;
}
public Class<?>[] getAllReturnedTypes() {
return new Class[] { ProofHQObject.class };
}
}
This object class implements IScriptObject and has the method ‘addProofReviewer’:
public class ProofHQObject implements IScriptObject{
...
...
public int addProofReviewer(String pFileID, String pRecipientEmail, String pRecipientName, ... ){
...
}
So in servoy I wish to call this addProofReviewer method to return the parameters.
Because this class implements the IScriptObject, i have the method getParameterNames:
public String[] getParameterNames(String method) {
if (method.equals("addProofReviewer")) return new String[] { "File ID", "Recipients Email" , "Recipients Name', ... };
...
}
Unfortunatly no success. I added the js_ prefix to the method, exported the jar, restarted servoy and when i wish to call the method, the intellisense gives me ‘string, string, string, string,…’
So, in ‘ProofHQObject.getParameterNames()’ you don’t prefix with ‘js_addProofReviewer’ (just to be sure)?
Do you use the correct # of arguments?
Does the tooltip work?
You must be doing something wrong but without seeing all your code it is hard to comment…