My solution to this problem was to add my new fields to the logwork.jsp. This is code for a text field, and a drop-down.
<page:applyDecorator name="auifieldgroup">
<aui:textfield id="'numberOfDefects'" label="text('Number Of Defects')" mandatory="'false'" name="'numberOfDefects'" size="'short'" theme="'aui'" /><br>
</page:applyDecorator>
<page:applyDecorator name="auifieldgroup">
<label for="select-example">Development Phase</label>
<select class="select" id="developmentPhase" name="developmentPhase">
<option>testing</option>
<option>configuration</option>
<option>development</option>
</select>
</page:applyDecorator>
Then I used the Servlet-Filter plugin module provided by Atlassian, and the filter was configured to apply to urls matching the pattern /secure/CreateWorklog.jspa. This is in atlassian-plugin.xml.
<servlet-filter name="Create Worklog Servlet Filter" i18n-name-key="create-worklog-servlet-filter.name" key="create-worklog-servlet-filter" class="com.pelletier.jira.servlet.filter.CreateWorklogServletFilter" location="before-dispatch" weight="200">
<description key="create-worklog-servlet-filter.description">The Create Worklog Servlet Filter Plugin</description>
<url-pattern>/secure/CreateWorklog.jspa</url-pattern>
<dispatcher>REQUEST</dispatcher>
</servlet-filter>
In my Servlet-Filter class, I was then able to get the new parameters from the request, and write them to my database. (Not the Jira one, unfortunately, I hear that is frowned upon)
public class CreateWorklogServletFilter implements Filter {
private JdbcTemplate jdbcTemplate = null;
//OSGi injects the JdbcTemplate
public CreateWorklogServletFilter(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
chain.doFilter(request, response);
//do stuff with new params from modified jsp
}
@Override
public void destroy() {
}
I am familiar with spring, so I put a spring.xml file in the META-INF/spring/ directory of my plugin, and jars needed for my DataSource, and database driver in the META-INF/lib directory. The JdbcTemplate configured in spring.xml gets put in the OSGi bundle (I think) which then injects it into the constructor of my ServletFilter implementation.