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?
Community moderators have prevented the ability to post new answers.
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); } }
Where are you using testvalue and how?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
simply like this: <h3>$testvalue</h3>
just to check if it works or not
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks you a lot. I have searched for how to add a variable to velocity context for all afternoon.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.