开发者

s.select tag renders empty dropdown

开发者 https://www.devze.com 2023-02-12 21:44 出处:网络
I am using struts2 and freemarker and I want to creta a simple drop down which should display vales found in a value object.

I am using struts2 and freemarker and I want to creta a simple drop down which should display vales found in a value object.

<td><@s.select name="operationalKey" list="key.operationalColumns" theme="simple" id="input.taskForm.operationalKey" /> </td>

The problem is that although I开发者_JAVA百科 have values in my list (I can see them if I do a iteration through the key.operationalColumns) the drop down is rendered as empty.

The getOperationalColumns method returns a List

the same thing calling a method of the action (e.g. if the action would return the List then it is working).

I do not get it?!? This OGNL stuff is working only with the action? it is not supposed to look at the objects also? am I doing something wrong?

Any help would be much appreciated thanks


I use spring.ftl:

* This file consists of a collection of FreeMarker macros aimed at easing
* some of the common requirements of web applications - in particular
* handling of forms.
*
* Spring's FreeMarker support will automatically make this file and therefore
* all macros within it available to any application using Spring's
* FreeMarkerConfigurer.) but I image struts would have something similar.

Here is use case:

<#assign someOptions = ["oneday","twoday", "week", "month"]>
<@spring.formSingleSelect "item.delivery", someOptions, " "/>

Or you can make your own macro here is the source from spring.ftl:

<#--
* formSingleSelect
*
* Show a selectbox (Dropdown) input element allowing a single value to be chosen
* from a list of options.
*
* @param path the name of the field to bind to
* @param options a map (value=label) of all the available options
* @param attributes any additional attributes for the element (such as class
*    or CSS styles or size
-->
<#macro formSingleSelect path options attributes="">
<@bind path/>
<select id="${status.expression}" name="${status.expression}" ${attributes}>
    <#list options?keys as value>
    <option value="${value?html}"<@checkSelected value/>>${options[value]?html}</option>
    </#list>
</select>
</#macro>
0

精彩评论

暂无评论...
验证码 换一张
取 消