encoder in velocity templates in 2.7

Hi all -

Could someone very briefly explain how the encoder object gets included in the Velocity context in 2.7?  We've just upgraded one of our projects to 2.7, and all of the strings that use the encoder are not interpolated on our site now... lots of "$encoder.htmlEncode( $dataElement.displayName )", and so forth - obviously not usable in that state.

We've got a set of deltas (custom changes) that we've applied to the base 2.7 for this project, but none of them have anything to do with velocity initialization or setup...

Thanks,
-David

Hello David,

for velocity template encoding we have a custom velocity context class:

  • Class name is EncoderVelocityContext.java and is located in dhis-web-commons project.

  • The context gets included in top of dhis-web-commons.xml in same project.

  • The actual encoder class which gets injected in the context is called Encoder.java and is located in dhis-support-system module.

  • Encoder.java mainly uses apache commons lang StringEscapeUtils internally.

Is your code availabe somewhere? It is funny you are seeing this. The displayName object is used for the database internationalization feature. If you look in BaseIdentifiableObject (dhis-web-api) you will also see that getDisplayName() will fall back to getName() if the former is not set, so you should def see something in your templates.

My best guess is that you have removed the velocity context from your dhis-web-commons.xml config and hence cannot access the encoder object.

Lars

···

On Fri, May 11, 2012 at 6:06 PM, Dave Trombley dave.trombley@gmail.com wrote:

Hi all -

Could someone very briefly explain how the encoder object gets included in the Velocity context in 2.7?  We've just upgraded one of our projects to 2.7, and all of the strings that use the encoder are not interpolated on our site now... lots of "$encoder.htmlEncode( $dataElement.displayName )", and so forth - obviously not usable in that state.



We've got a set of deltas (custom changes) that we've applied to the base 2.7 for this project, but none of them have anything to do with velocity initialization or setup...

Thanks,
-David


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp