- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2017 09:35 AM
Hi All,
We're on Helsinki ...
I've got a UI PAGE attempting to populate a SELECT; choosing one entry to be SELECTED...
<select name="selectList" id="selectList" onchange="getSelectListOptionValue(this)">
<j:while test="${jvar_list.next()}">
<j:set var="jvar_value" value="${jvar_list.getValue('u_vendor_name')}"/>
<j:choose>
<j:when test="$[jvar_value== searchBy]">
<option value="${jvar_value}" selected="selected">${jvar_value}</option>
</j:when>
<j:otherwise>
<option value="${jvar_value}">${jvar_value}</option>
</j:otherwise>
</j:choose>
</j:while>
</select>
The value of 'searchBy' is known to be a valid case of one of the jvar_value
The line ==>
<j:when test="$[jvar_value== searchBy]">
Is never found to come true though ALERTs have show that jvar_value and searchBy have the same value for one record... I've got a test suite of 2 records.
Any ideas?
The line== searchBy]">
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2017 11:25 AM
Interestingly, it looks like Jelly will not support a combination of a jelly variable (jvar_value) and a javascript variable (searchBy) in the test condition. It seems to work if both are jelly variables or both are javascript variables.
You also need to fix the syntax in the test condition to use curly braces {} instead of box brackets [] since this is to be evaluated in phase 1 as mentioned by Chuck above.
One way of fixing this would be to use a g:evaluate or a j:set to set the value of searchBy in a jelly var (jvar_searchBy) and change the test condition in line 1 above to be:
<j:when test="${jvar_value == jvar_searchBy}">
Hope that helps.
PS: Please hit "Correct", "Helpful" or "Like" depending on the impact of the response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2017 09:40 AM
The square brackets are phase 2, you'll want to change that first. Try this:
<j:when test="${jvar_value} eq 'searchBy'">
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2017 09:45 AM
Thanks, Chuck, but no joy...
And, since the 'searchBy' is also a javascript variable, I also tried
<j:when test="${jvar_value} eq ${searchBy}">
Still never matches.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2017 09:51 AM
Did you validate that ${jvar_value} has a value? You should be able to see this with a <g:breakpoint /> with debugging turned on to inspect your variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2017 10:17 AM
Actually I am using it both the normal and "selected" cases of adding the option just for that purpose ... I've even used the JVAR_VALUE and SEARCHBY interchangeably in lines 2 and 5 just to ensure they BOTH have values and that's how I know that they have EQUAL values for the one row I expect to set that option to SELECTED.
- <j:when test="$[jvar_value== searchBy]">
- <option value="${jvar_value}" selected="selected">${jvar_value}</option>
- </j:when>
- <j:otherwise>
- <option value="${jvar_value}">${jvar_value}</option>
- </j:otherwise>