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

Can't retrieve / put paramaters from velocity context

Giuseppe La Femina December 15, 2011

I have the very same question as this one but this time I'm doing a new project panel item.

This is my class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
public class StatsTabPanel extends GenericProjectTabPanel
{
public StatsTabPanel(JiraAuthenticationContext jiraAuthenticationContext,
FieldVisibilityManager fieldVisibilityManager) {
super(jiraAuthenticationContext, fieldVisibilityManager);
// TODO Auto-generated constructor stub
}
public String testvalue="112002";
@Override
public Map<String, Object> createVelocityParams (BrowseContext context) {
Map<String, Object> contextMap = super.createVelocityParams(context);
contextMap.put("testvalue", testvalue);
return contextMap;
}
}

this is the plugin xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<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>

why i can't see testvalue in my context? What am i doing wrong this time?

3 answers

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);
		
	}
}

1 vote
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.
December 15, 2011

Where are you using testvalue and how?

Giuseppe La Femina December 15, 2011
simply like this: &lt;h3&gt;$testvalue&lt;/h3&gt;
just to check if it works or not

0 votes
Deniz Oğuz
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.
August 22, 2013

Thanks you a lot. I have searched for how to add a variable to velocity context for all afternoon.

TAGS
AUG Leaders

Atlassian Community Events