How to put Velocity parameters in WebWork action

grundic
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.
September 19, 2011

I've implemented custom WebWork action. For it I've supplied some velocity templates.

How can I add custom parameters to velocity? I didn'f find any such method :(

1 answer

1 accepted

2 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
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.
September 19, 2011

If you add private variables in the action and getter methods for them in the action class, they are accessible from the velocity template. Is this what you want?

grundic
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.
September 19, 2011

Yep, I think that's just it! Thanks a lot!

grundic
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.
September 19, 2011

One more question: if I have to add to velocity context standard jira components - for example, webResourceManager - should I write something like:

public WebResourceManager getWebResourceManager(){
return ComponentManager.getInstance().getWebResourceManager();
}


It looks like overhead :-/

Bahar Çağlar October 11, 2012

If you add private variables in the action and getter methods for them in the action class, they are accessible from the velocity template. Is this what you want?

Hi Jobin,

Can you give an example for this?

Thanks

Jobin Kuruvilla [Adaptavist]
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.
October 11, 2012

Example for getter/setters? If you have variable xyz and getter/setters for it, you can access it in velocity template as $xyz

Jobin Kuruvilla [Adaptavist]
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.
October 11, 2012

Are you missing 's'? Try

<p>size : $crman.relationSchemes.size() </p>

You can also use

<p>size : $crman.getRelationSchemes().size() </p>

Bahar Çağlar October 11, 2012

I can access with action like

#set ($crman = $action.relationManager)

then, I want to access its variables as folows:

<p>size : $crman.relationScheme.size() </p>

I have a getRelationSchemes() methods in it, but I am always getting zero. What is wrong with this?

Suggest an answer

Log in or Sign up to answer