You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Sometime you may found that your plugin may need to make an AJAX call to retrieve data from an API that not come default with Joget Workflow v3. So, normally you will need to write a Servlet or Web Service to handle the call. In Joget, our plugin architecture provided an interface to enable you implement your Web Service in plugin.

For the example below, I will used Form Element Plugin as example but the interface can use with any other Plugin Types.

package org.joget.sample.lib;

import java.io.IOException;
import org.joget.apps.form.model.Element;
import org.joget.plugin.base.PluginWebSupport;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SimpleFormElement extends Element implements PluginWebSupport {

    //... Other Implemented Methods ...

    @Override
    public void webService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        // Get Parameter
        String text = request.getParameter("say_something");


        // Write to response
        response.getWriter().write(text);
    }
}

After you done your Web Service implemetation, you can access to it by the URL format as below:

{Context Path}/web/json/plugin/{Plugin Class Name}/service

Example:

http://localhost:8080/jw/web/json/plugin/org.joget.sample.lib.SimpleFormElement/service?say_something=Hello World

If your Web Service need to access to App Definition that make this call, the URL format will take extra parameter as below:

{Context Path}/web/json/app/{App Id}/{App Version}/plugin/{Plugin Class Name}/service

Example:

http://localhost:8080/jw/web/json/app/crm/1/plugin/org.joget.sample.lib.SimpleFormElement/service?say_something=Hello World

Then, you can get the App Definition in your implementation by code below

AppDefinition appDef = AppUtil.getCurrentAppDefinition();
  • No labels