grails - How can I set a variable from a regular helper method in GSP? -



grails - How can I set a variable from a regular helper method in GSP? -

i need output html values depend on kind of object have (i'm transitioning between db representations). right have logic in block of g:if expressions. it's relatively hard read , debug.

<g:if test="${o.iskinda}"> <g:set var="x" value="${...}" /> <g:set var="y" value="${...}" /> ... </g:if> <g:else> <g:set var="x" value="${...}" /> <g:set var="y" value="${...}" /> ... </g:else>

i particularly not interested in adding these values x , y methods of o. i'd set them using view helper, understand == "tag lib" in grails:

// tag helper // class amazingtaglib { def valuexfor = { attrs -> o.iskinda? 1 : 2 } ... } // previous gsp, rewritten // ... <g:set var="x" value="${ valuexfor(o) }" />

this failing, however. when effort utilize x, bound empty streamcharbuffer, presumably because didn't attach out in implementation of valuexfor. should have had integer returned value of helper.

how can utilize such functional helper methods in view?

the issue default tag libraries used render out. in case looking homecoming object/value method , need tell taglib method different standard behavior. adding next trick:

class amazingtaglib { static returnobjectfortags = ['valuexfor'] def valuexfor = { attrs -> o.iskinda? 1 : 2 } ... }

grails gsp

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -