It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira Plugin for Custom Field: Radio Buttons Edited

Hi everyone,

I am developing a custom field plugin that allows me to create a custom field that allows me to display the description beside the radio buttons. This is a requirement to suit my use case, and I do not have the luxury to purchase ready-made plugins from the marketplace.Screenshot from 2019-09-12 16-48-53.png

Therefore, making it work like a single custom field for a checklist.


However, I am not proficient in java, velocity templates and writing plugins in general. I was following the admin editable custom field tutorial. Really need someone to walk me through developing such a custom field type plugin.

This is the velocity template for the admin editable custom field tutorial. The input has the property value, hence it is able to display ${value}. However, for my case, I am using radio buttons. How do I determine which radio button was selected? and be able to display the value of the selected option?Screenshot from 2019-09-12 16-59-17.png

My current velocity template (uncompleted and unsure of how to proceed)

Screenshot from 2019-09-12 17-02-12.png

Also, the tutorial dealt with the persistence of the data. How do I go about writing the java code to persist my data? I'm pretty sure GenericTextCFType is not applicable here, do I use SelectCFType? How do I get the selected option and persist it as the custom field of an issue?
Admin editable custom field type (tutorial's) java code:

Screenshot from 2019-09-12 17-08-28.png

2 answers

#controlHeader ($action $ $ $fieldLayoutItem.required $displayParameters.noHeader)#if ($jiraUserUtils.getGroupNamesForUser($'jira-administrators'))<table style="width:100%"> <tr> <th colspan="2">Task Description</th> <th>Result/Job Done</th> </tr> <tr> <td colspan="2">$customField.description</td> <td> <form class="aui"> <fieldset class="group"> <div class="radio"> <input class="radio" type="radio" checked="checked" name="radiobuttons" id="yes" > <label for="yes">Yes</label> </div> <div class="radio"> <input class="radio" type="radio" name="radiobuttons" id="no" > <label for="no">No</label> </div> </fieldset> </form> </td> </tr></table>

#if($value && ! $value.equals("")) #set ($displayValue = ${value}) #else #set ($displayValue = 'N/A') #end<span title="This field is editable only by JIRA administrators">$!displayValue</span><input type="hidden" name="$" value="$!value" />#end#controlFooter ()

package com.example.plugins.tutorial.customfields;
import com.atlassian.jira.issue.customfields.impl.GenericTextCFType;import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;import com.atlassian.jira.issue.fields.TextFieldCharacterLengthValidator;import;import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;import com.atlassian.plugin.spring.scanner.annotation.imports.JiraImport;

Scannedpublic class JiraCustomField extends GenericTextCFType {
  public JiraCustomField(      @JiraImport CustomFieldValuePersister customFieldValuePersister,      @JiraImport GenericConfigManager genericConfigManager,      @JiraImport TextFieldCharacterLengthValidator textFieldCharacterLengthValidator,      @JiraImport JiraAuthenticationContext jiraAuthenticationContext) {    super(customFieldValuePersister, genericConfigManager, textFieldCharacterLengthValidator , jiraAuthenticationContext);  }}

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Keep your team in the loop with Team @mentions in Jira Software!

Hi everyone! My name is Jenny, a Product Manager at Atlassian. After launching Team @mentions in Confluence, we heard a lot of positive feedback from customers that they love how easy it is to @men...

225 views 4 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you