Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Calling WebWork Action function with parameters from velocity template

Alexej Geldt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 25, 2013

Hello. Im stuck with a strange problem.

I have a webwork module with an action class and velocity view. I can access action class methods from velocity template with $action.getIssueTypes(). This works fine until i need to pass parameters to the method. So when i use

$action.findTransitionsByIssueTypeId($issueTypeId)

it does not call the method, but instead prints the above instruction as text on the page. I have also tried

${action.findTransitionsByIssueTypeId($issueTypeId)}

${action.findTransitionsByIssueTypeId(${issueTypeId})}

$action.findTransitionsByIssueTypeId(${issueTypeId})

${action.findTransitionsByIssueTypeId(1)}

none of above works. As soon i have anything inside parameters bracket, it seems to be treaten as simple text by velocity.

i am sure that findTransitionsByIssueTypeId is working properly. It passes the tests. I am also sure, that there is an entry with id 1.

This is what i have

atlassian-plugin.xml
----------------------------

<webwork1 key="transitions-management-webwork" name="Transitions Management Webwork"
		i18n-name-key="create-and-link.components.transitions-management-webwork.name">
		<description key="create-and-link.components.transitions-management-webwork.description">The Successor Transition Management</description>
		<actions>
			<action
				name="com.bssnsoftware.jira.plugin.createandlink.actions.EditTransitionAction"
				alias="EditTransition">
				<view name="input">/views/edittransition/edit.vm</view>
			</action>
			<action
				name="com.bssnsoftware.jira.plugin.createandlink.actions.ManageTransitionsAction"
				alias="ManageTransitions">
				<view name="success">/views/managetransitions/view.vm</view>
			</action>
		</actions>
</webwork1>

ManageTransitionsAction.java

public class ManageTransitionsAction extends JiraWebActionSupport {

	private static final long serialVersionUID = -2086781953876101793L;
	@SuppressWarnings("unused")
	private static final Logger log = LoggerFactory.getLogger(EditTransitionAction.class);

	private final IssueTypeManager issueTypeManager;
	private final TransitionService transitionService;

	/* Constructor */
	public ManageTransitionsAction(final IssueTypeManager issueTypeManager, final TransitionService transitionService) {
		super();
		this.issueTypeManager = issueTypeManager;
		this.transitionService = transitionService;
	}

	@Override
	public String execute() throws Exception {

		return super.execute(); // returns SUCCESS
	}

	public Collection<IssueType> getIssueTypes() {
		return issueTypeManager.getIssueTypes();

	}

	public Collection<Transition> findTransitionsByIssueTypeId(final String issueTypeId) {
		Collection<Transition> transitions;
		final Long id = Long.valueOf(issueTypeId);

		transitions = transitionService.findTransitionByIssueTypeId(id);
		log.info("###" + transitions.size());
		return transitions;
	}

}


view.vm


#enable_html_escaping() ${webResourceManager.requireResourcesForContext("com.bssnsoftware.jira.create-and-link-plugin")} <h1>$action.getText('create-and-link.view.header')</h1> <table class="aui"> <thead> <tr > <th class="headrow" >Issue Type</th> <th>Transitions</th> </tr> </thead> #foreach($issueType in $action.getIssueTypes()) <tr> <td class="issuetype-column"><img src="$!{issueType.getCompleteIconUrl()}" /> $!{issueType.getName()}</td> <td class="transitions-column"> <span>${action.findTransitionsByIssueTypeId($issueType.getId())}</span> </td> </tr> #end </table> <a class="button aui-button" href="${req.contextPath}/secure/EditTransition!default.jspa" id="edit-transition-link">$action.getText('create-and-link.view.create-transition')</a> </div>

output

output

as you can see, calling $action.getIssueTypes() without parameters works fine. $action.findTransitionsByIssueTypeId($issueTypeId) does not get processed.
out of my disperation i have changed the signature of findTransitionsByIssueTypeId() to take no parameters and instead use a hardcoded id. So the call $action.findTransitionsByIssueTypeId() works.
When i touch the parameters, it does not.

Any ideas?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Alexej Geldt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 28, 2013

I've found a work around. Passing parameters as Strings and converting them to proper representation (Long in my case) seems to work.

example: $action.findTransitionsByIssueTypeId("$issueTypeId")

and in action

Long issueTypeId = Long.valueOf(issueTypeIdString);

TAGS
AUG Leaders

Atlassian Community Events