I would like to render my pages in the browser using a JavaScript framework like React. So far, all our Tridion content is rendered as HTML on the serverside using JSP.
I can imagine it is possible to let Java render JSON objects instead of full HTML. But what I'm hoping is that the data is already available in the JSON format, so I can just access that. Ideally it should be structured so that I can request a normal page, and get the whole hierarchy of modules and their copy and media manager urls for images.
I'm trying to find out if DD4T does something like this, but I might be on the wrong track if it's not possible in the first place.
1 Answer
At the moment I imagine that your current implementation is "baking" your HTML during publishing and including some JSP code which is executed on the server.
There's nothing to stop you from having your templates render pages as JSON data and serving those up to React. DD4T could certainly help you here, as the publishing side already serialises to JSON, though you may want to shrink the data to only that which you need in your React app and to omit any sensitive information.
-
Thanks David, yes that is indeed what we are doing, publishing static html. Ideally, I'd like not having to create JSP code for all pages, but just get a certain 'node' from the Tridion content tree, based on a GUID for example. But good point that filtering the data might be needed in some cases. Have you tried something like this yourself?– MicrosCommented Apr 13, 2017 at 15:58
-
1I know of a customer who's serving up DD4T JSON to their React based front-end. Their web application basically retrieves the JSON data as pages from the content delivery API by the requested URL. Commented Apr 13, 2017 at 16:01
-
1bcg.com - also worth looking into DXA 2.0 Technology Preview, the model service might be exactly what you're looking for: github.com/sdl/dxa-web-application-java/releases– Nuno Linhares ♦Commented Apr 13, 2017 at 16:18
-
2I will have to add that the DXA Model Service is not intended as public API (yet), but a DXA Web Application (1.x or 2.0) can also serve JSON. Commented Apr 14, 2017 at 12:08