Spring MVC中Spring.AjaxEventDecoration和dijit.form.Select的问题

时间:2012-10-11 18:16:43

标签: spring spring-mvc dojo spring-webflow

我在使用Spring.AjaxEventDecoration和dijit.form.Select时遇到问题,如果用户从选择框中选择性别类型,我得到的bean中的elementID是Spring MVC吗?以下是我的表格:

<form:select path="sex">
<form:option value="MALE" label="MALE" />
<form:option value="FEMALE" label="FEMALE" />
</form:select> 
<script type="text/javascript">
  Spring.addDecoration(new Spring.ElementDecoration({
  elementId : "sex",
  widgetType : "dijit.form.Select",
  widgetAttrs : {
  promptMessage : "Enter Sex",
  required : true }}));

  Spring.addDecoration(new Spring.AjaxEventDecoration({
  elementId: "sex",
  event: "onChange",
  formId:"customer",
  params: {fragments:"body", _eventId: "loadSchools"}}));
</script> 

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。我删除了 Spring.AjaxEventDecoration 调用,并将 Spring.ElementDecoration 更改为以下内容:

 <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "sex",
                                widgetType : "dijit.form.Select",
                                widgetAttrs : {
                                promptMessage : "Enter Sex",
                                required : true, 
                                onChange : function() {
                                    Spring.remoting.submitForm(
                                        'submit', 
                                        'customer', 
                                        {_eventId: 'sexchange', fragments:'contents'}
                                     ); 
                                     return false;
                                } }}));


                        </script>

我不是100%清楚为什么Ajax调用不起作用,但我现在让我的项目使用这段代码!