Question

Using Spring Webflow and Dijit it looks like I can only add one Decoration per element (field)?

I am working on a Spring Webflow project and I was loading a list of schools once the user selects a Borough from a dropdown. The form was working great until I added a dijit.form.Select widgettype to it. Please look at the code below.

Can I use both?

The Issue I am having is on the Spring MVC side the bean now has the value "borough" in the borough field and NOT the value the user entered!

<form:select path="borough" id="borough" >
<form:option value="UNKNOWN" label="Unknown" />
<form:option value="X" label="Bronx" />
<form:option value="K" label="Brooklyn" />
<form:option value="M" label="Manhattan" />
<form:option value="Q" label="Queens" />
<form:option value="R" label="Staten Island" />
<form:option value="O" label="All Other Schools" />
</form:select>
<script type="text/javascript">
            Spring.addDecoration(new Spring.ElementDecoration({
            elementId : "borough",
            widgetType : "dijit.form.Select",
            widgetAttrs : {
                                promptMessage : "Enter Borough",
                                required : true }}));

            Spring.addDecoration(new Spring.AjaxEventDecoration({
            elementId: "borough",
            event: "onChange",
            formId:"member",
            params: {fragments:"body", _eventId: "loadSchools"}}));
</script> 
Was it helpful?

Solution

I fixed the issue. I removed the Spring.AjaxEventDecoration call and changed the Spring.ElementDecoration to the following:

 <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>

I am not 100% clear on why the Ajax call did not work but I have my project working with this code now!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top