I use GSP to send emails based on the MailService plugin. Closing sendMail passes (in particular)body(view:..., model:myModel)
I know that I can access each element of myModel Map using ${itemName}in GSP. However, since I sometimes want to create an element name dynamically, like 'item'+i, I need to have some surrounding method to access the variable.
I already tried ${model.get('item'+i)and ${params.get('item'+i), but the model is null and params is an empty Map. I also tried pageScope, but although I can access the element through ${pageScope.itemName, I cannot use ${pageScope.get('item'+i)}it because pageScope is not a Map.
There may be many solutions to this problem; I would be happy for the easy ;-). One solution that I see is to pass myModel as the only parameter and then always use it myModel.get(...), however that would mean that I had to modify all my existing GSPs to always refer to myModel instead of directly accessing elements (with fixed names ); therefore, if there is a way that I do not need to change the model passed to the GSP, this would be my favorite.
If someone could say a few words about the difference between the model and the parameters in this context, that would be useful!
source
share