Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Sometime you may found that your plugin 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();