History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: WW-455
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Mathias Bogaert
Reporter: Emilian Abadjiev
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
WebWork

Select tag template does not work properly for Object like BigDecima

Created: 27/Jan/04 04:30 AM   Updated: 23/Nov/04 08:51 AM
Component/s: Views
Affects Version/s: 2.0
Fix Version/s: 2.1.7

File Attachments: 1. File select.vm (3 kb)

Environment: Nothing special


 Description  « Hide
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>

 All   Comments   Change History      Sort Order:
Emilian Abadjiev - [27/Jan/04 06:46 AM ]
The last select.vm example doesn't match correctly selected option. This should work better.