I have a select box of TYPES that each type has their own PARAMETERS. The TYPES select box will fire off some AJAX that calls a template and renders PARAMETER select boxes on my view. The Parameters are made up of name:value pairs, thus every name can have many values.
Some parameters need multiple='true' for the user to select multiple values for each name, while other parameters need to be restricted to only one choice.
In my gsp page I have a bunch of these:
<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 issue is that I have 6 parameters for one particular TYPE that need to select multiple values, the rest do not. Rather than explicitly type out as above, is there a way that I can test for more than one thing in a g:if statement like you can in java? such as:
if(something.equals(PARAMETER_A) || something.equals(PARAMETER_B))
etc.
Is there a way to do something similar to java's approach in groovy?
Grails g:if
just uses groovy in its test attribute. So to answer your question, yes:
<g:if test="${something.equals(PARAMETER_A) || something.equals(PARAMETER_B)}">
</g:if>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With