JavaDoc in Servoy of plugin

Hi!

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.

Thanks in advance!

You can use getParameterNames(String arg) for that.

return new String { “arg1”, “[etc]” };

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

Can’t you wrap/extend that java method into a provider class?

I don’t think that you can do what you want without making it a provider.

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 :)

Hi!

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', ... };
	    ...
	  }

prefix the method name with ‘js_’ and you should be fine…

BTW did you read the tutorials or check out the plug-ins that Servoy included with source code included (I believe the mail plugin is one of them).

public int js_addProofReviewer(String pFileID, String pRecipientEmail, String pRecipientName, … ){

}

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,…’

I checked the mail plugin and did the exact same thing!

  • Object class implements IScriptObject
  • Method with js_ prefix
  • Tooltip same way
  • Removed the @Override annotations

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…

Here is the code of the ProofHQObject class:

The uploadFile method (prefixed with js_):

public int js_uploadFile(String pID, String pFileShareName, String pFilePath, String[] pRecipients, String pLanguage, 
			String pSubject, String pMessage, int pWorkspaceID)
{
		...

The methods of IScriptObject:

public String[] getParameterNames(String methodName) {
		if (methodName == null)
			return null;

		if ("uploadFile".equals(methodName)) {
			return new String[] { "ID", "FileShareName", "FilePath", "Recipients[]", "Language", "Subject", "Message", "WorkspaceID" };
		}
		return null;
	}
	
	public String getSample(String arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public String getToolTip(String methodName) 
	{
		if ("uploadFile".equals(methodName))
			return "Upload a file and get response.";
		
		return null;
	}

	public boolean isDeprecated(String arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	public Class<?>[] getAllReturnedTypes() {
		// TODO Auto-generated method stub
		return null;
	}

Well, that is hardly all code.
Also, you did not yet tell me if the tooltip works.

What happens when you change this ‘Recipients’ into this’Recipients’ (just searching)?

  • Tooltip not working either.
  • Changing Recipients to Recipients doesn’t change anything.

If that is the case I would not know how to help you without your code/project.
I am sorry.

Does your class have an empty constructor?

No it does not.
When creating the object, it’s mandatory to provide 2 parameters.
Should it work when I have a no-argument constructor?

Jep it works when adding a no-argument constructor! Thanks patrick ;)

patrick:
Does your class have an empty constructor?

I don’t think it is necessary anymore but it would not hurt either :)

public ProofHQObject() {
}

Oops too late :)