Laliwala IT Services

Laliwala IT Services
Website Development

Wednesday, February 23, 2011

How to use Velocity in AJAX response, jsr 286, ajax liferay, liferay template, method directly, jsp rather, dynamically, using java, jsp




Paul Franky : Hi,








we've built a portlet that uses the serveResource() method (see JSR 286) for creating a response to an AJAX request. This works fine so far.








What we wanna do is to render a velocity template within this method directly to an object. This object we would like to return as a string (or bytes) in response to the AJAX request.








How could we do this? Will ThemeUtil.includeVM() be our friend?






Mazhar Anwar : If you use jsp rather than velocity, it will be more simple.





you can have some html tag (<div>, <span>, etc with some ids and if require you can make it hidden initially) and after executaion of your serveResource method you can set those html tags dynamically using java script(AJAX) based on your response.








This is something intresting and innovative, please reply if success emoticon








Hope This Help.








Regards,

Mazhar






Paul Franky : Very sorry, not to use Velocity is not an option. We use the spring MVC Framework and Velocity to clearly separate code and design. That's also the reason for not creating a document "by-hand" inside serveResource().








Prepared hidden content is also not an option because we need to update large data tables (and we wanna update only those).








Nevertheless thanks for thinking about it.

No comments:

Post a Comment