To your first question:
have a look at: Project Tab Panel Module
the class you have to set there is responsible for rendering the project tab panel. in normal cases you render some velocity templates there. have look at one of the interfaces VersionsProjectTabPanel implements (com.atlassian.jira.plugin.browsepanel.TabPanel). there you will find a method named getHtml(...). Jira will call this Method before the Panel is displayed in the web page.
So what you would have to do:
- define a class that implements the TabPanel interface AND set this class in the project tab panel module descriptor in your atlassian-plugin.xml
- overwrite the method getHtml(...) with your own template rendering process
in your overwritten method you have to get a reference to the VelocityManager:
VelocityManager velocityManager = ComponentManager.getInstance().getVelocityManager();
Write velocity template and render it with getBody(...) Method:
String renderedText = velocityManager.getBody("<PATH_TO_TEMPLATE>", "templatename.vm", context);
If you want to pass content to that template, do that via the context variable of the getBody(...) Method. The Map is of type
Map<Object, Object>
. Usually you will put in there a String/Object Entry. The Key-String will be declared as variable in the template and the Value-Object is the value of the variable:Map<String, Object>
give that renderedText as return-Value to the caller of getHtml(...) and it will be displayed on the page.
Some Q&A and tutorial pages to that topic:
To your second question:
Just declare a <form>...</form>
tag in your velocity template. The action-attribute in there should point to your webwork action url. In the getHtml(...) Method you have overwritten, you have to access the HttpServletRequest context via ServletActionContext:
HttpServletRequest request = ServletActionContext.getRequest();
String someRequestParam = request.getParameter("paramName");
Pass the request param content to your velocity template via template context map we spoke before or do some business logic with it.