render json response on webflow

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

render json response on webflow

freak182
Hi

Sorry, if my post is not suitable to this forum. Just want to resolve my problem. We currently using thymeleaf with spring webflow. I can already do ajax with webflow and render thymeleaf template but this time i want json to be rendered.

I have this setup Spring Web Flow + Thymeleaf + Apache Tiles 2.
How to have a json response from webflow?

thanks.
Cheers.
Reply | Threaded
Open this post in threaded view
|

Re: render json response on webflow

danielfernandez
Administrator
AFAIK, WebFlow will render fragments of your page via AJAX only as HTML fragments, not JSON.

But in order to use JSON, you can directly use Spring MVC's support, by placing @ResponseBody annotations in your controllers returning JSON for AJAX calls.

Then you could parse such JSON using jQuery. I don't think the "spring-js" companion library for Spring WebFlow has JSON parsing facilities, though I'm not sure...

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: render json response on webflow

freak182
Hi daniel,

Thanks for the reply..If it is not too much to ask, can you help us to render json on webflow fragments? Because our app is built entirely on webflow + thymeleaf stack. Thanks in advance.

Cheers,
Eman
Reply | Threaded
Open this post in threaded view
|

Re: render json response on webflow

freak182
btw, i do this only to render json data, it's a hack but it works,

tiles:
<definition name="jsonData" template="/json/data" templateType="thymeleaf">
                <put-attribute name="body" value="/json/data"/>
</definition>

html template:


in jquery response:
var resp = response.replace("","").replace("","");
$.parseJSON(resp)

hehehehe it's bit ugly but it is only to work json in webflow and thymeleaf.

Eman
Reply | Threaded
Open this post in threaded view
|

Re: render json response on webflow

freak182
replace the < span > with "" string