Getting error while using TextCFType for custom field

Saurabh Rajendra September 23, 2013

I am trying to develop a custom field using below Java code :


public class ReadOnlyUserCF extends TextCFType{ private final JiraAuthenticationContext authContext; public ReadOnlyUserCF(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter, GenericConfigManager genericConfigManager, JiraAuthenticationContext authContext) { super(customFieldValuePersister, stringConverter, genericConfigManager); this.authContext = authContext; } @Override public Map getVelocityParameter(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem){ Map params = super.getVelocityParameters(issue, field, fieldLayoutItem); params.put("currentUser", authContext.getLoggedInUser().getName()); return params; } }

But I am getting below error :

The method getVelocityParameter(APKeys.JiraIndexConfiguration.Issue, CustomField, FieldLayoutItem) of type ReadOnlyUserCF must override or implement a supertype method.

Also TextCFType is showing deprecated.

Please share your knowledge.

Thanks

5 answers

1 accepted

0 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 24, 2013

Why is the first parameter APKeys.JiraIndexConfiguration.Issue?

It should be Issue object.

0 votes
Saurabh Rajendra September 25, 2013

You are absolutely right.

I tried that and got success.

Thanks for your help.

0 votes
Saurabh Rajendra September 25, 2013

Actually I was using APKeys.JiraIndexConfiguration.Issue.

But i tried with Issue object and got Success.

Thank you so much for your inputs.

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2013

In the latest versions use GenericTextCFType instead of TextCFType.

Saurabh Rajendra September 24, 2013

Which method I need to override if I use GenericTextCFType?

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 24, 2013

Same getVelocityParameters method. Override the method first and then start working in it.

Saurabh Rajendra September 24, 2013

I tried that one but getting below error:

The method getVelocityParameters(APKeys.JiraIndexConfiguration.Issue, CustomField, FieldLayoutItem) of type ReadOnlyUserCF must override or implement a supertype method

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2013

yes the above code should work. where you are getting the above mentioned error?

Saurabh Rajendra September 24, 2013

I am getting error on getVelocityParameter.

The error is:

The method getVelocityParameter(APKeys.JiraIndexConfiguration.Issue, CustomField, FieldLayoutItem) of type ReadOnlyUserCF must override or implement a supertype method

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 24, 2013

the method is getVelocityParameters(...) if I am not wrong. Just check

Saurabh Rajendra September 24, 2013

You are right, the name is getVelocityParameters(...).

I tried that one also and got the same error.

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2013

public class ReadOnlyUserCF extends TextCFType{

private final JiraAuthenticationContext authContext;

public ReadOnlyUserCF(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter,

GenericConfigManager genericConfigManager, JiraAuthenticationContext authContext) {

super(customFieldValuePersister, stringConverter, genericConfigManager);

this.authContext = authContext;

}

@Override

public Map getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem) {

Map params = super.getVelocityParameters(issue, field, fieldLayoutItem);

params.put("currentUser", authContext.getUser().getName());

return params;

}

}

this code(which exactly mentioned by you in the question except getVelocityParameters name) is working for me.

I could able to compile it properly with no errors.

Also the import statement for Issue should be

import com.atlassian.jira.issue.Issue;

# The same getVelocityParameters(Issue issue,CustomField field, FieldLayoutItem fieldLayoutItem) you need to override even you use GenericTextCFType

hope this should solve your problem

Suggest an answer

Log in or Sign up to answer