Action fired twice on datalist action plugin
Confluence User - 20 Nov, 2017
I'm implementing a datalist action plugin. I can compile the plugin and correctly load it using the plugin manager. However when I add it to a datalist and press the associated link the executeAction() function is executed twice. Why is it happening? Am I doing something wrong?
This is a link to the test application
This is a link to the jar of the plugin.
This is the code of the plugin (I kept it the more minimal as possible for the sake of clarity):
package org.joget.tutorial;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import org.joget.apps.app.service.AppPluginUtil;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.datalist.model.DataList;
import org.joget.apps.datalist.model.DataListActionDefault;
import org.joget.apps.datalist.model.DataListActionResult;
import org.joget.apps.form.service.FileUtil;
import org.joget.commons.util.LogUtil;
public class GenerateNewDocumentVersionDatalistAction extends DataListActionDefault {
private final static String MESSAGE_PATH = "messages/GenerateNewDocumentVersionDatalistAction";
private static int execution = 0;
public DataListActionResult executeAction(DataList arg0, String[] arg1) {
LogUtil.info("CollboartiveEditing - Plugin creating new document version", "Generating test document: run " + execution);
execution++;
return null;
}
public String getConfirmation() {
//LogUtil.info("Collaborative Editing - Generate new document version plugin", "getConfimation: " + getPropertyString("confirmation"));
//return getPropertyString("confirmation"); //get confirmation from configured properties options
return null;
}
public String getHref() {
//LogUtil.info("Collaborative Editing - Generate new document version plugin", "getHref: " + getPropertyString("href"));
return getPropertyString("href"); //Let system to handle to post to the same page
//return null;
}
public String getHrefColumn() {
//LogUtil.info("Collaborative Editing - Generate new document version plugin", "getHrefColumn: " + getPropertyString("recordIdColumn"));
//return getPropertyString("hrefColumn"); //Let system to set the primary key column of the binder
return null;
}
public String getHrefParam() {
//LogUtil.info("Collaborative Editing - Generate new document version plugin", "getHrefParam: " + getPropertyString("hrefParam"));
//return getPropertyString("hrefParam"); //Let system to set the parameter to the checkbox name
return null;
}
public String getLinkLabel() {
//LogUtil.info("Collaborative Editing - Generate new document version plugin", "getLinkLabel: " + getPropertyString("label"));
return getPropertyString("label"); //get label from configured properties options
//return null;
}
public String getTarget() {
////return "post";
//LogUtil.info("Collaborative Editing - Generate new document version plugin", "getTarget: " + getPropertyString("target"));
//return getPropertyString("target");
return null;
}
public String getClassName() {
return getClass().getName();
}
public String getLabel() {
return AppPluginUtil.getMessage("org.joget.tutorial.GenerateNewDocumentVersionDatalistAction.pluginLabel", getClassName(), MESSAGE_PATH);
}
public String getPropertyOptions() {
return AppUtil.readPluginResource(getClassName(), "/properties/generateNewDocumentVersionDatalisAction.json", null, true, MESSAGE_PATH);
}
public String getDescription() {
return AppPluginUtil.getMessage("org.joget.tutorial.GenerateNewDocumentVersionDatalistAction.pluginDesc", getClassName(), MESSAGE_PATH);
}
public String getName() {
return "New Document Generator Datalist Action";
}
public String getVersion() {
return "5.0.0";
}
}
When I click on the action link in the datalist in the log file I get the following output:
INFO 20 Nov 2017 14:55:01 CollboartiveEditing - Plugin creating new document version - Generating test document: run 0 INFO 20 Nov 2017 14:55:01 CollboartiveEditing - Plugin creating new document version - Generating test document: run 1
plugins;datalists;action