How to write conditional expression using Gpath in GSP page

291 Views Asked by At

I want to display the attachments whose type may be 1 or 4 or 5

${attachments} has got attachments with the attributes name, type

EDIT:

<g:findAll in="${attachments}" expr="it.type==1 || it.type==4 ||  it.type==5">
       <p>File: ${it.name}, ${it.type}</p>
    </g:findAll>

I was trying the above method, it didn't work, How to do this.

1

There are 1 best solutions below

0
On
<g:each in="${attachments.findAll{[1,4,5].contains(it.type)}}">
    <p>File: ${it.name}, ${it.type}</p>
</g:each>