How to send data from WebWork action to velocity template?

Hi,

I have a webwork action that does a bunch of work and return “success” to render a success.vm or “error” to render a error.vm velocity template. In case of errors, I have to collect all the errors and display them on the velocity template. How do I transfer the data from servlet to my velocity template?

I have used VelocityContext (org.apache.velocity.VelocityContext) to add my errors to the context.

VelocityContext velocityContext = new VelocityContext();
velocityContext.internalPut("projectNotFound","APD");

Now in the error.vm, I have used $projectNofFound to display the project key “APD”. But instead, it just prints “$projectNotFound”.

Error.vm:

Project : $projectNotFound not found!! Please update your child projects list.

Output:

How do I get the $projectNotFound value?

1 Like

@daniel @david.pinn @jechlin @jobinkk
Guys can anyone help me with this?

1 Like

Found answer to my problem here: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-set-value-for-variables-in-velocity-file/qaq-p/515944