dijit form filteringselect不支持EL变量中的选项?

时间:2015-08-27 22:59:37

标签: spring variables dojo el options

春天有一个非常漂亮的解决方案来填充EL变量中的选择列表,例如:

<form:select id="customerentity_customerTitle" path="customerTitle" cssStyle="width:300px;">
    <form:option value="None" label="*** Select Your Title ***"></form:option>
    <form:options items="${fn:split(title_t, ',')}" />
</form:select>

这种JSTL和弹簧解决方案可以轻松应用。

当我试图在Dojo中找到类似的解决方案时。我发现最接近的解决方案是dijit / form / FilteringSelect,但是当我尝试使用类似的方式来填充动态生成的下拉选择时,它不起作用。

<select id="customerentity_customerTitle" name="customerTitle" style="width: 300px;" data-dojo-type="dijit/form/FilteringSelect" 
    data-dojo-props="value: '${customerentity.customerTitle}',placeHolder: 'Select Your Title',options:'${fn:split(title_t, ',')}'">
</select> 

我的问题是:是否有可能使用类似的方式在数字/表格/ FilteringSelect中执行此操作?或者我必须使用javascript来填充它?

欢迎任何建议!!

修改

标题保存在属性文件中,并使用:

进行访问
<fmt:setBundle basename="bundles.customer-resources" />

资源包。

来源如下:

storageway.customer.person.title.options=Mr.,Ms.,Mrs.,Dr.,Other

访问:

<fmt:message key="storageway.customer.person.title.options" var="title_t" scope="session" />

这是一个简单的字符串数组而不是键:值映射。 Spring表单可以正确处理它,但dijit / form / FilteringSelect不能。

1 个答案:

答案 0 :(得分:0)

您可以在option内创建正常的dijit/form/FilteringSelect代码。 它们将被渲染。所以我打赌你可以做到

<select id="customerentity_customerTitle" name="customerTitle" style="width: 300px;" data-dojo-type="dijit/form/FilteringSelect" 
data-dojo-props="value: '${customerentity.customerTitle}',placeHolder: 'Select Your Title'">

    <form:options items="${fn:split(title_t, ',')}" />
</select>

请参阅代码段:

&#13;
&#13;
require(["dojo/parser", "dojo/domReady!"], function(parser){
    parser.parse();
});
&#13;
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css"> 
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/tundra/tundra.css">

<div class="tundra">
  
  <select id="customerentity_customerTitle" name="customerTitle" style="width: 300px;" data-dojo-type="dijit/form/FilteringSelect" 
    data-dojo-props="value: 'b',placeHolder: 'Select Your Title'">
    
    <option value="a">value A</option>
    <option value="b">value B</option>
    <option value="c">value C</option>
  </select> 
  
</div>
&#13;
&#13;
&#13;

相关问题