how can I get my instance of issue in custom field type constructor?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

how can I get my instance of issue in custom field type constructor?

forums-5
public class MyPlugin extends SelectCFType
{
    public MyPlugin(...)
          //here i need the instance of current issue
    }...
--
Post by dr6den - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
You can't get the current issue context there. MyPlugin here is a custom field type and hence cannot be associated with a single issue. You can only get the current issue in some of the methods like getVelocityParameters which are invoked in the context of the Issue.
--
Post by jobinkk - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
Thanks Kuruvilla! answer was helpful, I need instance of issue before finish instantiation of my custom field. Which metod help me? I cant without issue, because creation of new options for selectCFType requires it. What should you do?
--
Post by dr6den - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
Depends on what you are trying to achieve. For example, if you want new options created while editing an issue, you can do so by overriding the getVeloctyParameters method.
--
Post by jobinkk - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
I just have written such code:

  public Map getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)
    {
        FieldConfig fieldConfig = null;
        Map parameters = super.getVelocityParameters(issue, field, fieldLayoutItem);
        if(issue == null)
        {
            fieldConfig = field.getReleventConfig(new SearchContextImpl());
        } else
        {
            fieldConfig = field.getRelevantConfig(issue);
           
     
        }
         Options options = optionsManager.getOptions(fieldConfig);
            options.addOption(null, "zero ufo");
            optionsManager.updateOptions(options);

        return parameters;
    }


And when I am creating a issue in jira It isnt working new option isnt appiering
--
Post by dr6den - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
I use the createOption method. should work for you as well..!

{code}
Option option = this.optionsManager.createOption(fieldConfig, null, null, "new Option");
{code}
--
Post by jobinkk - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
Oh thanks. I have already tried this way:
do you mean?:
public  class MyPlugin extends SelectCFType
{
private final OptionsManager optionsManager;

pulic MyPlugin(OptionsManager optionsManager, ...) {
super(...);
this.optionsManager = optionsManager;
}

public Map getVelocityParameters(...){
....
Option option = this.optionsManager.createOption(fieldConfig, null, null, "new Option");
}


and I got NullPointerException. I tried the same in constructor.
--
Post by dr6den - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
Can you check if the fieldconfig you are passing is null or not? What is the full stacktrace?
--
Post by jobinkk - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

forums-5
thanks all works write:
SelectCFType's method looks like this:

 public Map getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)
    {
        Map parameters = super.getVelocityParameters(issue, field, fieldLayoutItem);

         FieldConfig fieldConfig = null;
        if(issue == null)
        {
            fieldConfig = field.getReleventConfig(new SearchContextImpl());
        } else
        {
            fieldConfig = field.getRelevantConfig(issue);
        }
   
        Option option = this.optionsManager.createOption(fieldConfig, null, null, "newYalsl");
        return parameters;
    }
--
Post by dr6den - online at:
http://forums.atlassian.com/thread.jspa?forumID=46&threadID=52301
_______________________________________________
Jira-user mailing list
[hidden email]
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-user
Reply | Threaded
Open this post in threaded view
|

Re: how can I get my instance of issue in custom field type constructor?

dhavalsoni
This post has NOT been accepted by the mailing list yet.
Hi,

I want to create custom field as below:
Month select list and year select list pair three times.

Field Name: <Month List (static - no configuration required)><Year List (Options configuration in admin> | <Month List (static - no configuration required)><Year List (Options configuration in admin> |<Month List (static - no configuration required)><Year List (Options configuration in admin>

so, when user selects from select list then it appears as below:
Filed Name: <March><1999>|<April><2013>|<March><2011>

Can any one suggest me which custom field type i should prefer to extend.
i have tried by extending "AbstractCustomFieldType<SelectCFType,SelectCFType>"
but did not get Configuration options in admin.


any example stuff will be helpful !