Hello,

 If you are breaking your head like me to see why the appropriate radio
button is not selected, this might help you. FYI, I am using the simple
theme.

My s:radio tag  :
                        <s:radio id="answers[%{#question.id}]"
name="answers[%{#question.id}]"
                                 list="options"  listKey="questionOptionId"
 listValue="optionText" *value*="answers[%{#question.id}]"   />

Note: answers is a HashMap<Integer, String>

1. Create a new theme. Read more
here<http://siriwardana.blogspot.com/2008/11/vertically-formatted-checkboxlist.html>
if
you don't know how.
2. Make the following changes to the radiomap.ftl (I am only showing the
part that you need to fix and not the entire file).
-------------------------------------------------------
<#if parameters.name??>
*<#--/*ADD THIS LINE*/-->*
*        <#assign nameValue = stack.findString(parameters.name)/> *
 name="${parameters.name?html}" nmv="${nameValue?html} <#rt/>
</#if>
 id="${parameters.id?html}${itemKeyStr?html}" <#rt/>
*<#--/*REMOVE THIS LINE*/-->*
*<#if tag.contains(parameters.nameValue?default(''), itemKeyStr)> *
*<#--/*ADD THIS LINE*/-->*
*<#if tag.contains(nameValue, itemKeyStr) == true> *
 checked="checked" <#rt/>
</#if>
-------------------------------------------------------

*The problem *

I am not an expert on freemarker but I guess the *nameValue *parameter is
missing here (which is not in the documentation) and since it cannot find
that parameter it defaults to empty string and hence it will never match the
itemKeyStr unless the listKey is null or empty for that list item.

*The Solution*
 Just assign a *nameValue *variable to take the value from the value stack
using the el expression you passed as it's parameter value. And use the
tag.contains() method to compare it against the current list item's key
which is stored in the itemKeyStr. That should work.

If I am doing this right, how do we get this fix in the next patch? Please
advise. Thanks!

-- 
Cheers,
John

Reply via email to