I am trying to understand why this is not working :
<g:set var="testvar" value="${'label.' + controller.computeLabel()}"/>
<g:message code="${testvar}"/>
The output for this is (assuming that controller.computeLabel() returns "computed.label"):
label.computed.label
How can I force g:message to resolve the code attribute ?
Thank you !!
You are assuming a lot with the statement of:
Assuming that contoller.computeLabel() returns "computed.label"
Calling a controller inline like that in your GSP isn't going to behave the way you expect. In fact, it's wrong on many levels. You should not be doing it.
Instead, whatever controller is rendering the GSP should be providing the information in the model instead. So, you would end up with something like this:
<g:set var="testvar" value="${'label.' + valueFromModel}"/>
Approaching the problem this way, and using MVC correctly will solve your issue.
Without more information about the specifics of your situation it's impossible to give you a more detailed answer.