Grails multiple g: if test for more than one condition

I have a TYPES selection box, each type has its own PARAMETERS. Some AJAX will be disabled in the TYPES select box, which calls the template and displays the PARAMETER select boxes on my view. Parameters consist of name: value pairs, so each name can have many values.

Some parameters require multiple = 'true' for the user to select multiple values ​​for each name, while other parameters should be limited to only one choice.

On my gsp page, I have a bunch of:

    <g:if test="${it?.getKey().toString().equals('PARAMETER_A')}">
      <td><g:select multiple="true" optionKey="id" optionValue="value" name="sampleParameters" id="parameter" value="${params?.sampleParameters}" from='${it?.getValue().sort()}'></g:select></td>
    </g:if>
    <g:if test="${it?.getKey().toString().equals('PARAMETER_B')}">
      <td><g:select multiple="true" optionKey="id" optionValue="value" name="sampleParameters" id="parameter" value="${params?.sampleParameters}" from='${it?.getValue().sort()}'></g:select></td>
    </g:if>

My problem is that I have 6 parameters for one specific TYPE, which need to select several values, and the rest do not. Instead of explicitly specifying as stated above, is there a way that I can test more than one thing in a g: if statement, as you can in java? eg:

if(something.equals(PARAMETER_A) || something.equals(PARAMETER_B))

etc..

Is there a way to do something similar to the java approach in groovy?

+5
source share
1 answer

Grails g:ifjust uses groovy in its test attribute. Therefore, to answer your question, yes:

<g:if test="${something.equals(PARAMETER_A) || something.equals(PARAMETER_B)}">
</g:if>
+12
source

All Articles