Grails GSP How to change the Text of a Button template on the fly?

23 Views Asked by At

Im a newbie in the Grails Framework so keep that in mind. I have a Button Template which i render on a different place. I want to keep all the functionality of the template and the text on all usages but one.

How do i do this?

I tried Something like this:

<g:render template="relativePath/myTemplate"/>
<g:message code="myLabel.newText" default="newText"/> //should replace the text in the template

Obviously this didn't work.

1

There are 1 best solutions below

0
xpusostomos On

This question is incomprehensible. You really should write better questions. Generally, if you want to pass something to the template, it would be something like this:

<g:render template="relativePath/myTemplate" model="[myText: 'This is my new text']"

Then in the myTemplate you could do...

<g:message ... default="${myText}"/>

However the whole point of g:message is to not hard code messages, but to user messages.properties. Maybe you're trying to pass in a different message code:...

<g:render template="relativePath/myTemplate" model="[myCode: 'myLabel.newText']"
<g:message code="${myCode}"/>