Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

I can't retrieve parameters from velocity context

Giuseppe La Femina December 18, 2011

Hi I'm doing a project tab panel and I can't retrieve (or put) parameters from velocity context.

Here is my class and plugin.xml

package it.pride.jira.plugins;

import java.util.Map;
import com.atlassian.jira.plugin.projectpanel.impl.GenericProjectTabPanel;
import com.atlassian.jira.project.browse.BrowseContext;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.web.FieldVisibilityManager;
import com.atlassian.jira.plugin.projectpanel.ProjectTabPanel;



public class StatsTabPanel   extends GenericProjectTabPanel implements ProjectTabPanel
{

	public StatsTabPanel(JiraAuthenticationContext jiraAuthenticationContext,
			FieldVisibilityManager fieldVisibilityManager) {
		super(jiraAuthenticationContext, fieldVisibilityManager);
		// TODO Auto-generated constructor stub
	}


	public String testvalue="112002";
	
	
	

	public Map<String, Object> createVelocityParams (BrowseContext context) {
        Map<String, Object> contextMap = createVelocityParams(context);
        contextMap.put("testvalue", testvalue);
        contextMap.put("currentProject", new CurrentProject());
        contextMap.put("utility", new UtilityStatsPanel());
     
        return contextMap;
    }		
}

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
  <plugin-info>
    <description>${project.description}</description>
    <version>${project.version}</version>
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>
  </plugin-info>
  <project-tabpanel key="stats-tab-panel" name="Stats Tab Panel" i18n-name-key="stats-tab-panel.name" class="it.pride.jira.plugins.StatsTabPanel">
    <description key="stats-tab-panel.description">The Stats Tab Panel Plugin</description>
    <label key="stats-tab-panel.label"></label>
    <order>10</order>
    <resource type="velocity" name="view" location="templates/tabpanels/stats-tab-panel.vm"/>
  </project-tabpanel>
  <resource type="i18n" name="i18n" location="atlassian-plugin"/>
</atlassian-plugin>

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Giuseppe La Femina January 8, 2012

The class must extedend AbstractProjectTabPanel and must implement the getHtml method as follows:

import java.util.HashMap;
import java.util.Map;

import com.atlassian.jira.plugin.projectpanel.impl.AbstractProjectTabPanel;
import com.atlassian.jira.project.browse.BrowseContext;
import com.atlassian.jira.security.JiraAuthenticationContext;

public class StatsTabPanel   extends AbstractProjectTabPanel {
	
	public StatsTabPanel(JiraAuthenticationContext jiraAuthenticationContext
			) {
		super(jiraAuthenticationContext);
		// TODO Auto-generated constructor stub
		
	}


	final String testvalue="112002";
	
	@Override
	public boolean showPanel(BrowseContext context){
		return true;
	}
	
	/*@Override
	public Map<String, Object> createVelocityParams (BrowseContext context) {
        Map<String, Object> contextMap = createVelocityParams(context);
        contextMap.put("testvalue", testvalue);
        return contextMap;
    }*/

	
	public String getHtml(BrowseContext context){
		
				
		
		Map<String,Object> tmpParams =new HashMap<String,Object>();
		
		tmpParams.put("testvalue", testvalue);
		
		
		return descriptor.getHtml("view",tmpParams);
		
	}
}
Mizan
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.
January 8, 2012

Hi ,

i am trying to do something similar , can you please provide your vm file ? i want to add a new field in the version tab . right now i am creating a new project tab panel exactly similar to the version tab of a project and add my new field because i have no idea how i can add a new field in the version tab.

thanx :)

TAGS
AUG Leaders

Atlassian Community Events