Custom Form Permission Plugin did Not Work
Confluence User - 14 Oct, 2016
Dear Expert,
I am creating a simple permission plugin to disable a section if the user using a Mobile View. by "MobileUtil.isMobileView()"
And I build the Plugin successfully. but it is not able to install it with the joget Console.
here is the Source Code.
Activator.java
package org.joget.tutorial;
import java.util.ArrayList;
import java.util.Collection;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
public class Activator implements BundleActivator {
protected Collection<ServiceRegistration> registrationList;
public void start(BundleContext context) {
registrationList = new ArrayList<ServiceRegistration>();
//Register plugin here
registrationList.add(context.registerService(NotMobileView.class.getName(), new NotMobileView(), null));
}
public void stop(BundleContext context) {
for (ServiceRegistration registration : registrationList) {
registration.unregister();
}
}
}
NotMobileView.java
package org.joget.tutorial;
import org.joget.apps.app.service.AppPluginUtil;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.FormPermission;
import org.joget.apps.userview.model.UserviewPermission;
import org.joget.apps.app.service.MobileUtil;
public class NotMobileView extends UserviewPermission
implements FormPermission
{
public NotMobileView()
{
}
@Override
public String getName()
{
return "Not MobileView";
}
@Override
public String getVersion()
{
return "5.0.0";
}
@Override
public String getDescription()
{
return AppPluginUtil.getMessage("org.joget.tutorial.NotMobileView.pluginDesc", getClassName(), "messages/NotMobileView");
}
@Override
public String getLabel()
{
return AppPluginUtil.getMessage("org.joget.tutorial.NotMobileView.pluginLabel", getClassName(), "messages/NotMobileView");
}
@Override
public String getClassName()
{
return getClass().getName();
}
@Override
public String getPropertyOptions()
{
return AppUtil.readPluginResource(getClassName(), "/properties/NotMobileView.json", null, true, "messages/NotMobileView");
}
@Override
public boolean isAuthorize()
{
boolean isAuthorize;
isAuthorize = false;
if (!MobileUtil.isMobileView()) {
isAuthorize = true;
}
return isAuthorize;
}
}
NotMobileView.json
[{
"title":"@@userview.notmobileview.config@@",
"properties":[{
"name":"permission",
"label":"@@userview.notmobileview.permission@@",
"type":"elementselect",
"options_ajax":"[CONTEXT_PATH]/web/property/json/getElements?classname=org.joget.apps.userview.model.UserviewPermission",
"url":"[CONTEXT_PATH]/web/property/json[APP_PATH]/getPropertyOptions"
}]
}]
NotMobileView.properties
org.joget.tutorial.NotMobileView.pluginLabel=Not MobileView org.joget.tutorial.NotMobileView.pluginDesc=Return True if not using mobile view userview.notmobileview.config=Configure Not Mobile View userview.notmobileview.permission=Permission
and the Jar folder structure is
-org -joget -tutorial *Activator.class *NotMobileView.class -messages *NotMobileView.properties -properties *NotMobileView.json
Any Idea what I am doing Wrong ?
Best Regards
Tony Chu
permission;plugins;customization;mobileview