This page last changed on Dec 14, 2005 by donna@atlassian.com.

This page provides an example of how to extend the available types listed on the Configuring Plugins with Object Configurable Parameters reference page.

JIRA Source Note:

You must own a commercial license of JIRA to have access to JIRA's source code-- a necessary part of this modification.

In the Atlassian JIRA Source modify the following:

ObjectConfigurationTypes.java
public class ObjectConfigurationTypes
{
   public static final int CHECKBOX = 9;
      ...

   public static int getType(String typeStr)
   {
      ...

      else if (typeStr.toLowerCase().startsWith("checkbox"))
      {
          return CHECKBOX;
      }

      ...
   }

}

 

 

objectconfiguration_form.jsp
<webwork:elseIf test="objectConfiguration/fieldType(.)==9"><%-- CHECKBOX --%>
    <webwork:property value="." />
    <webwork:property value="paramValue(.)" />
    <ui:component name="." value="paramValue(.)" label="text(objectConfiguration/fieldName(.))" template="checkbox.jsp">
        <ui:param name="'description'"><webwork:text name="objectConfiguration/fieldDescription(.)" /></ui:param>
        <ui:param name="'fieldValue'"><webwork:property value="paramValue(.)" /></ui:param>
    </ui:component>
</webwork:elseIf>

 

 

Example Plugin Code

This example uses the Issue Creation Report example (com.atlassian.jira.plugin.report.example) provided in the JIRA Plugin Development Kit.

In your plugin source (e.g. a report plugin) add the following property:

atlassian-plugin.xml
<property>
   <key>checkbox</key>
   <name>report.issuecreation.checkbox</name>
   <description>report.issuecreation.checkbox.description</description>
   <type>checkbox</type>
   <default>true</default>  //If you would like the default to be checked
</property>

Generally, your atlassian-plugin.xml will refer to a properties file (e.g. issuecreation_report.properties) for configuration of field labels and descriptions. Add the following attributes:

issuecreation_report.properties
report.issuecreation.checkbox = CheckBox Label
report.issuecreation.checkbox.description = A simple checkbox for test purposes.

 

 

Modify your plugin java file to extract/work with the boolean checkbox value:

CreationReport.java
...

public String generateReportHtml(ProjectActionSupport action, Map params) throws Exception
{
        User remoteUser = action.getRemoteUser();
        I18nHelper i18nBean = new I18nBean(remoteUser);

        // Retrieve the project parameter
        Long projectId = ParameterUtils.getLongParam(params, "projectid");
        // Retrieve the start and end dates and the time interval specified by the user
        Date startDate = ParameterUtils.getDateParam(params, "startDate", i18nBean.getLocale());
        Date endDate = ParameterUtils.getDateParam(params, "endDate", i18nBean.getLocale());
        Long interval = ParameterUtils.getLongParam(params, "interval");
        boolean checkbox = (Boolean.valueOf(ParameterUtils.getStringParam(params, "checkbox"))).booleanValue();
     ...

        velocityParams.put("checkbox", new Boolean(checkbox));
 }
   ...

 

 

Document generated by Confluence on Oct 06, 2009 00:31