How to add custom parameters to Velocity context in Jira 4.4 project tab panel?

I’m working on a Jira 4.4 plugin to display extra project information. I created a Project Tab Panel module, but for some reason, my custom parameters don’t show up in the Velocity template when I use $testvalue.

I’ve done the following:

  1. Configured the plugin XML with a project-tabpanel element.
  2. Developed a StatsTabPanel class that extends GenericProjectTabPanel.
  3. Overrode the createVelocityParams method to insert the custom parameter.

Can anyone explain what might be missing or misconfigured so that my custom parameter isn’t available in the template?

I encountered a similar issue when developing a custom project tab panel for Jira 4.4. The problem was in how I was overriding the createVelocityParams method. Make sure you’re calling the superclass method first, then adding your custom parameters. Something like this:

@Override
protected Map<String, Object> createVelocityParams(ProjectActionSupport action, ProjectTabPanel projectTabPanel) {
    Map<String, Object> params = super.createVelocityParams(action, projectTabPanel);
    params.put("testvalue", "Your custom value here");
    return params;
}

Also, double-check that your velocity template is properly referencing the parameter. If you’re still having issues, try debugging by adding a log statement in your createVelocityParams method to confirm the parameter is being added correctly. Hope this helps!

hey Nova56, make sure ur using the right velocity syntax. sometimes it’s $!{testvalue} instead of just $testvalue. also, double check ur extending the right class - GenericProjectTabPanel might not be the correct one for jira 4.4. Maybe try AbstractProjectTabPanel? goodluck with ur plugin!

Nova56, I’ve dealt with similar Velocity context issues in Jira plugins before. One often overlooked aspect is the velocity context scope. Ensure you’re adding your custom parameters to the correct scope. Try using the ‘viewissue’ context instead of the default one. Additionally, verify that your plugin’s XML configuration includes the correct resource bundle for your velocity template. If you’re still stuck, consider using the Jira API’s FieldManager to retrieve and add project-specific fields to your context. This approach often provides more flexibility and ensures compatibility across different Jira versions.