Announcement Announcement Module
Collapse
No announcement yet.
Ajax without addDecoration statements Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ajax without addDecoration statements

    Hello,

    we've been using spring webflows for some time now and encountered some problems when combining it with Ajax requests.

    This is probably because the dojo components that we use in our web page are declared in the standard dojo syntax like:

    Code:
    <input id="key" name="key" dojoType="dijit.form.TextBox" autoComplete="false" hasDownArrow="false" class="smallInput" type="text" />
    With Spring webflows, in general dojo components are defined with the syntax like this:

    Code:
    <form:input id="searchString" path="searchString"/>
    <script type="text/javascript">
        Spring.addDecoration(new Spring.ElementDecoration({
            elementId: "searchString",
            widgetType: "dijit.form.ValidationTextBox",
            widgetAttrs: { promptMessage : "Search hotels by name, address, city, or zip." }}));
    </script>
    While the first syntax is much easier to understand and works perfectly fine with spring webflows, if you are using Ajax requests, then you're out of luck. In the returned Ajax response the partial html fragments are no longer converted to Dojo components and you end up with standard ugly html widgets.

    Is there any way that working with a standard Dojo syntax will be supported in future spring webflows versions?

    I did some research and managed to get this to work for the most basic Dojo widgets. In the handleResponse method of the spring-js Spring.RemotingHandler object (defined in the Spring-Dojo.js file) I did some modifications to fetch all the tags with a dojoType attribute, and then after the loop of the insert of the new nodes

    Code:
    newNodes.forEach(...
    and before the evaluation of the extracted script blocks in the returned Ajax response

    Code:
    dojo.forEach(extractedScriptNodes, function(script){
    i generated some script blocks with addDecoration statements to the collection of extractedScriptNodes, so it would seem as if they were in the original response.

    This seemed to work fine, so my question is, why not add this to future versions of the spring-js library? The code i modified was just a test case to see if this could work, but i'm sure that something more generic could be done.

    In that case the syntax definitions of the dojo widgets would stay in line with the standard dojo syntax, and which to me seems much cleaner.
Working...
X