I think I've found a bug in the WebWork 2.2.2 template 'radiomap.ftl' in the
simple theme. I have only just joined this list, so forgive me if this is
not going to be used in Struts Action 2.0, or there's a better place to post
this. A proposed patch is included at the end of this message.

The 'radiomap' template doesn't work if the provided list uses Boolean keys.
The 'select' template handles it, but radiomap doesn't. Just FYI, we chose a
radio control for this instead of a checkbox just because of the annoying
parameter-is-null-if-not-checked behavior. I know there are other ways to
address it with a checkbox, but... I'm not using them. Probably why this bug
never came up before, so maybe only I care.

JSP page:

<%@ taglib prefix="ww" uri="/webwork"%>
<ww:set name="enable_options"
        value="#{true: getText('option.enabled'), false:
getText('option.disabled')}"/>
<ww:form name="myForm" id="myForm" action="saveLdapConfig" method="post">
        <ww:radio name="enabled"
                label="%{getText('prompt.enabled')}"
                list="#enable_options"
                />
        ...
</ww:form>

=====================
Results in the following error message:

FreeMarker template error!

Error on line 12, column 79 in template/simple/radiomap.ftl
Expecting a string, date or number here, Expression itemKey is instead a
freemarker.ext.beans.BooleanModel
The problematic instruction:
----------
==&gt; ${itemKey?html} [on line 12, column 77 in
template/simple/radiomap.ftl]
 in user-directive ww.iterator [on line 1, column 1 in
template/simple/radiomap.ftl]
 in include "/${parameters.templateDir}/simple/radiomap.ftl" [on line 3,
column 1 in template/xhtml/radiomap.ftl]
----------

======================
I can provide the full Java stack trace, if anybody cares, but in looking at
'select.ftl', I think I found the solution. 

The select template creates a variable 'itemKeyStr' and uses that anywhere
the string value is used, instead of the 'itemKey' directly. Apparently the
expression ${itemKey?html} doesn't work when itemKey is a Boolean.

I've gotten the above JSP to work by overriding
/template/simple/radiomap.ftl with the text following my signature. Changed
lines are commented.

I'd appreciate any feedback. Please be kind; it's my first post to this
list. :-)

Jay H. Hartley, Ph.D.
Senior Software Engineer/Architect
Modius, Inc.

======================
<@ww.iterator value="parameters.list">
    <#if parameters.listKey?exists>
        <#assign itemKey = stack.findValue(parameters.listKey)/>
    <#else>
        <#assign itemKey = stack.findValue('top')/>
    </#if>
<#-- 
        Create new variable itemKeyStr, like in select.ftl 
-->
    <#assign itemKeyStr = itemKey.toString() />
    <#if parameters.listValue?exists>
        <#assign itemValue = stack.findString(parameters.listValue)/>
    <#else>
        <#assign itemValue = stack.findString('top')/>
    </#if>
<#--
        Use itemKeyStr?html for output instead of itemKey?html
-->
<input type="radio" name="${parameters.name?html}"
id="${parameters.id?html}${itemKeyStr?html}"<#rt/>
<#if tag.contains(parameters.nameValue, itemKey)>
 checked="checked"<#rt/>
</#if>
<#--
        Use itemKeyStr?html for output instead of itemKey?html
-->
<#if itemKey?exists>
 value="${itemKeyStr?html}"<#rt/>
</#if>
<#if parameters.disabled?default(false)>
 disabled="disabled"<#rt/>
</#if>
<#if parameters.tabindex?exists>
 tabindex="${parameters.tabindex?html}"<#rt/>
</#if>
<#if parameters.cssClass?exists>
 class="${parameters.cssClass?html}"<#rt/>
</#if>
<#if parameters.cssStyle?exists>
 style="${parameters.cssStyle?html}"<#rt/>
</#if>
<#if parameters.title?exists>
 title="${parameters.title?html}"<#rt/>
</#if>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
/><#rt/>
<#--
        Use itemKeyStr?html for output instead of itemKey?html
-->
<label for="${parameters.id?html}${itemKeyStr?html}"><#rt/>
    ${itemValue}<#t/>
</label>
</@ww.iterator>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to