
|
If you were logged in you would be able to see more operations.
|
|
|
|
File Attachments:
|
1.
select.vm (3 kB)
|
|
Environment:
|
Nothing special
|
|
|
I found that select template does not populate list key & value in case is is BigDecimal (it should fail for other objects too). For instance if TR_APPL_NUM is a instance of BigDecimal, the following tag:
<ww:select ... listKey="TR_APPL_NUM" listValue="PERSON_DESC" />, will render as a sequence of <option value="">PERSON_DESC[I]</option>.
<BR /><BR />
Workaround 1: <BR />
It works if the value is transformed to a String manually, like this:
<ww:select ... listKey="TR_APPL_NUM.toString()" listValue="PERSON_DESC" />
Workaround 2: <BR />
It works if you modify the select.vm stack value evaluation to target String value, i.e. something like this: #set( $itemValue = $stack.findValue($parameters.listValue, $clazz) ), where $clazz is evaluated like this: #set( $clazz = $Class.forName("java.lang.String") ) <BR />
A working copy of select.vm should look like this: <BR />
<PRE>
#*
-- selectmap.vm
--
-- Required Parameters:
-- * label - The description that will be used to identfy the control.
-- * name - The name of the attribute to put and pull the result from.
-- Equates to the NAME parameter of the HTML SELECT tag.
-- * list - Iterator that will provide the options for the control.
-- Equates to the HTML OPTION tags in the SELECT and supplies
-- both the NAME and VALUE parameters of the OPTION tag.
--
-- Optional Parameters:
-- * labelposition - determines were the label will be place in relation
-- to the control. Default is to the left of the control.
-- * size - SIZE parameter of the HTML SELECT tag.
-- * disabled - DISABLED parameter of the HTML SELECT tag.
-- * tabindex - tabindex parameter of the HTML SELECT tag.
-- * onchange - onkeyup parameter of the HTML SELECT tag.
-- * size - SIZE parameter of the HTML SELECT tag.
-- * multiple - MULTIPLE parameter of the HTML SELECT tag.
-- * headerKey - Combined with headerValue parameter specifies the top of select list
-- * headerValue - see above
--
*#
#parse("/template/xhtml/controlheader.vm")
<select name="$!parameters.name" id="$!parameters.name"
#if ($parameters.size) size="$parameters.size" #end
#if ($parameters.disabled) disabled="disabled" #end
#if ($parameters.tabindex) tabindex="$parameters.tabindex" #end
#if ($parameters.onchange) onchange="$parameters.onchange" #end
#if ($parameters.id) id="$parameters.id" #end
#if ($parameters.multiple) multiple="multiple" #end
>
#if ($parameters.headerKey && $parameters.headerValue)
<option value="$!webwork.htmlEncode($parameters.headerKey)">$!webwork.htmlEncode($parameters.headerValue)</option>
#end
#if ($parameters.emptyOption)
<option value=""></option>
#end
#set( $items = $parameters.list )
#set( $clazz = $Class.forName("java.lang.String") )
#if( $items )
#foreach( $item in $items )
$stack.push($item)
#if( $parameters.listKey )
#set( $itemKey = $stack.findValue($parameters.listKey, $clazz) )
#else
#set( $itemKey = $item )
#end
#if( $parameters.listValue )
#set( $itemValue = $stack.findValue($parameters.listValue, $clazz) )
#else
#set( $itemValue = $item )
#end
<option value="$!webwork.htmlEncode($itemKey)"
#if( $tag.contains($parameters.nameValue, $itemKey) )selected#end
>$!webwork.htmlEncode($itemValue)</option>
#set ($trash = $stack.pop())
#end
#end
</select>
#parse("/template/xhtml/controlfooter.vm")
</PRE>
|
|
Description
|
I found that select template does not populate list key & value in case is is BigDecimal (it should fail for other objects too). For instance if TR_APPL_NUM is a instance of BigDecimal, the following tag:
<ww:select ... listKey="TR_APPL_NUM" listValue="PERSON_DESC" />, will render as a sequence of <option value="">PERSON_DESC[I]</option>.
<BR /><BR />
Workaround 1: <BR />
It works if the value is transformed to a String manually, like this:
<ww:select ... listKey="TR_APPL_NUM.toString()" listValue="PERSON_DESC" />
Workaround 2: <BR />
It works if you modify the select.vm stack value evaluation to target String value, i.e. something like this: #set( $itemValue = $stack.findValue($parameters.listValue, $clazz) ), where $clazz is evaluated like this: #set( $clazz = $Class.forName("java.lang.String") ) <BR />
A working copy of select.vm should look like this: <BR />
<PRE>
#*
-- selectmap.vm
--
-- Required Parameters:
-- * label - The description that will be used to identfy the control.
-- * name - The name of the attribute to put and pull the result from.
-- Equates to the NAME parameter of the HTML SELECT tag.
-- * list - Iterator that will provide the options for the control.
-- Equates to the HTML OPTION tags in the SELECT and supplies
-- both the NAME and VALUE parameters of the OPTION tag.
--
-- Optional Parameters:
-- * labelposition - determines were the label will be place in relation
-- to the control. Default is to the left of the control.
-- * size - SIZE parameter of the HTML SELECT tag.
-- * disabled - DISABLED parameter of the HTML SELECT tag.
-- * tabindex - tabindex parameter of the HTML SELECT tag.
-- * onchange - onkeyup parameter of the HTML SELECT tag.
-- * size - SIZE parameter of the HTML SELECT tag.
-- * multiple - MULTIPLE parameter of the HTML SELECT tag.
-- * headerKey - Combined with headerValue parameter specifies the top of select list
-- * headerValue - see above
--
*#
#parse("/template/xhtml/controlheader.vm")
<select name="$!parameters.name" id="$!parameters.name"
#if ($parameters.size) size="$parameters.size" #end
#if ($parameters.disabled) disabled="disabled" #end
#if ($parameters.tabindex) tabindex="$parameters.tabindex" #end
#if ($parameters.onchange) onchange="$parameters.onchange" #end
#if ($parameters.id) id="$parameters.id" #end
#if ($parameters.multiple) multiple="multiple" #end
>
#if ($parameters.headerKey && $parameters.headerValue)
<option value="$!webwork.htmlEncode($parameters.headerKey)">$!webwork.htmlEncode($parameters.headerValue)</option>
#end
#if ($parameters.emptyOption)
<option value=""></option>
#end
#set( $items = $parameters.list )
#set( $clazz = $Class.forName("java.lang.String") )
#if( $items )
#foreach( $item in $items )
$stack.push($item)
#if( $parameters.listKey )
#set( $itemKey = $stack.findValue($parameters.listKey, $clazz) )
#else
#set( $itemKey = $item )
#end
#if( $parameters.listValue )
#set( $itemValue = $stack.findValue($parameters.listValue, $clazz) )
#else
#set( $itemValue = $item )
#end
<option value="$!webwork.htmlEncode($itemKey)"
#if( $tag.contains($parameters.nameValue, $itemKey) )selected#end
>$!webwork.htmlEncode($itemValue)</option>
#set ($trash = $stack.pop())
#end
#end
</select>
#parse("/template/xhtml/controlfooter.vm")
</PRE> |
Show » |
|