JiraWebActionSupport does not add usual context variables (e.g. textutils, jirautils) to velocity

I have created a servlet that renders a table. Every row of this table has on its right side a button. This button has a onclick event defined:

onclick=window.location='../../../jira/secure/PersonUpdateAction.jspa?action=update&id=$id'>

The PersonUpdateAction is a webwork item that exends the JiraWebActionSupport. The doExecute method is invoked:

@Override
	public String doExecute() {
		try {
			HttpServletRequest request = this.getHttpRequest();
			IInsertUpdateHelper insertUpdateHelper = InsertUpdateHelperFactory.getInstance(i18nHelper, userManager);

			Map<String, Object> context  = insertUpdateHelper.doAction(request);
			this.personBean = (PersonBean)context.get("personBean");
		} catch (DataAccessException e) {
			LOGGER.debug("catastrophe2: ", e);
		}
		return SUCCESS;
	}

My problem is that after the doExecute in my velocity for testing:

<html>
  <head>
    <meta name="decorator" content="atl.admin">
  </head>
  <body>context: ${requestContext.baseUrl}</body>
</html>

nothing is shown. The requestContext.baseUrl is empty, the decorator does not show anything. I can not access anything that Jira normally provides.

1 answer

1 accepted

Seems like the servlet context does not have everything I need. The following seems to work for me:

final Map<String, Object> defaultParams = JiraVelocityUtils.getDefaultVelocityParams(jiraAuthenticationContext);
    	final Map<String, Object> additionalParams = new HashMap<String, Object>(defaultParams);
    	additionalParams.put("baseurl", this.applicationProperties.getString(APKeys.JIRA_BASEURL));
        response.setContentType("text/html;charset=utf-8");
        templateRenderer.render("contacts.vm", additionalParams, response.getWriter());

Then I access it via ${baseurl}. The decorator works also now.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

135 views 5 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you