I’ve thought on Christoffer’s suggestions a bit and I’m thinking to have execute() return a Velocity context. In that, I will load a .vm containing the (x)html for a button or picker. I will then have my jiraRequest() java method defined as a REST endpoint which can be the action of the button.
I’m currently having errors returning the Velocity context.
@ComponentImport
private final ApplicationLinkService applicationLinkService;
private final VelocityHelperService velocityHelperService;
@Autowired
public createInitiative(ApplicationLinkService applicationLinkService, VelocityHelperService velocityHelperService) {
this.applicationLinkService = applicationLinkService;
this.velocityHelperService = velocityHelperService;
}
public String execute(Map<String, String> parameters, String body, ConversionContext conversionContext) throws MacroExecutionException {
final Map<String, Object> contextMap = velocityHelperService.createDefaultVelocityContext();
return velocityHelperService.getRenderedTemplate("templates/createInitiative.vm", contextMap);
}```
I’m putting some basic html in createInitiative.vm to test. This is unfortunately giving me runtime errors.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘com.trustvesta.plugins.macro.createInitiative’: Unsatisfied dependency expressed through constructor argument with index 1 of type [com.atlassian.confluence.plugin.services.VelocityHelperService]: No qualifying bean of type [com.atlassian.confluence.plugin.services.VelocityHelperService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.confluence.plugin.services.VelocityHelperService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
I’m using Spring with plugins-version=“2”.
Is there something I’m missing to inject a VelocityHelperService?