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

How to use GeneralUtil in atlassian-plugin.xml

Eric Koepfle July 31, 2013

Hello,

I was mimicing the Confluence Space IA plugin to create a space admin button in our template.

the line:

<link id="spacebar-settings-link">/spaces/spacetools.action?key=$generalUtil.urlEncode($helper.spaceKey)</link>

the final render doesn't seem to render correctly, I see the string literal instead of the actual space key.

What am I missing? I didn't see anything obvious in the atlassian-plugin.xml, and I couldn't find a help page outlining the usage.

Thanks!

6 answers

1 accepted

0 votes
Answer accepted
Eric Koepfle August 5, 2013

So it turned out the $helper is not a accessible by default object.

I ened up with:

<link>/spaces/spacetools.action?key=$generalUtil.urlEncode($space.key)</link>

thanks all for the suggestions.

0 votes
Maris Seimanovs December 4, 2013

I discovered that in JIRA, JiraWebActionSupport has method urlEncode, thus I could just do the following in my Velocity template:

$action.urlEncode("my/unsafe/url")

0 votes
Eric Koepfle August 5, 2013

@David Pinn, Yep. But I found my way around it.

0 votes
TtheB
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.
July 31, 2013

try

$action.helper.spaceKey

Eric Koepfle August 5, 2013

This was close, but it was the $helper object that was null. I ended up using:

<link>/spaces/spacetools.action?key=$generalUtil.urlEncode($space.key)</link>

I guess I saw the helper so much I thought it was there by default.

0 votes
David Pinn
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.
July 31, 2013

When you say 'I see the string literal' do you mean that you see '$helper.spaceKey' in the output?

0 votes
Deleted user July 31, 2013

You've put the generalUtil in velocity context?

The best way to do that is bring the $helper.spaceKey already encoded to the velocity template.

Eric Koepfle August 5, 2013

with Confluence, GeneralUtil is always in the velocity context. it's one of the default objects.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events