@@ -12,9 +12,10 @@ Rendering works internally by creating a `org.w3c.dom.Document` instance from th
1212[source,groovy]
1313----
1414import grails.plugin.springcache.annotations.Cacheable
15+ import grails.plugins.rendering.document.XhtmlDocumentService
1516
1617class CouponDocumentService {
17- def xhmlDocumentService
18+ XhtmlDocumentService xhmlDocumentService
1819
1920 @Cacheable('couponDocumentCache')
2021 class getDocument(serial) {
@@ -29,13 +30,12 @@ All of the render methods can take a `document` parameter instead of the usual `
2930----
3031class CouponController {
3132
32- def couponDocumentService
33+ CouponDocumentService couponDocumentService
3334
34- def gif = {
35- def serial = params.id
36- def document = couponDocumentService.getDocument(serial)
35+ def gif(String id) {
36+ def document = couponDocumentService.getDocument(id)
3737
38- renderGif(filename: "${serial }.gif", document)
38+ renderGif(filename: "${id }.gif", document)
3939 }
4040}
4141----
@@ -50,8 +50,8 @@ import grails.plugin.springcache.annotations.Cacheable
5050
5151class CouponGifService {
5252
53- def couponDocumentService
54- def gifRenderingService
53+ CouponDocumentService couponDocumentService
54+ GifRenderingService gifRenderingService
5555
5656 def getGif(serial) {
5757 def document = couponDocumentService.getDocument(serial)
@@ -65,13 +65,12 @@ class CouponGifService {
6565----
6666class CouponController {
6767
68- def couponGifService
68+ CouponDocumentService couponDocumentService
6969
70- def gif = {
71- def serial = params.id
72- def bytes = couponGifService.getGif(serial)
70+ def gif(String id) {
71+ def document = couponDocumentService.getDocument(id)
7372
74- renderGif(bytes: bytes, filename: "${serial }.gif")
73+ renderGif(filename: "${id }.gif", document )
7574 }
7675}
7776----
0 commit comments