Announcement Announcement Module
No announcement yet.
Partial rendering of a form with Ajax and fragments Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Partial rendering of a form with Ajax and fragments


    I'm trying to refresh a part of my form with Sring Javascript and tiles fragments: on a select change, I want to populate and refresh another select input.

    It works well when I reload the whole page but when I reload only the second select via Ajax, I have an exception:
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'children' available as request attribute
    Here is my code:

    Flow definition
    <view-state id="form" view="keyword.edit">
        <evaluate expression="editKeywordAction.setupForm" />
      <transition on="changeTree">
        <evaluate expression="editKeywordAction.bind" />
        <evaluate expression="editKeywordAction.changeTree" />
        <render fragments="children" />
      <transition on="save" to="finish">
        <evaluate expression="editKeywordAction.bindAndValidate" />
        <evaluate expression="" />
      <transition on="cancel" to="cancel" />

    Tiles definition
    <definition name="keyword.edit" template="/jsp/edit.jsp">
      <put-attribute name="children" value="/jsp/children.jsp" />
    <script type="text/javascript">
      function changeTree() {
        $('_eventId').value = 'changeTree';
        Spring.remoting.submitForm('tree', 'keyword', {fragments: 'children'}); 
        return false;
    <form:form commandName="keyword" name="keyword" action="${flowExecutionUrl}">
      <input type="hidden" name="_eventId" id="_eventId" value="save" />
      <form:select path="tree" id="tree" onchange="changeTree()" multiple="false">
        <form:options items="${trees}" />
      <tiles:insertAttribute name="children" />
    <form:select path="children" id="children" multiple="false">
      <form:options items="${children}" />
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'childTest' available as request attribute
      at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(
      at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(
      at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(
      at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(
      at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(
      at org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(
      at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(
      at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(
    Does that means I can only reload the whole form (including the form:form tags) and not only some inputs of this form ?

  • #2
    I'm trying to do exactly the same thing. Did you ever figure out a way of partially rendering the form? I'm guessing it's not possible.


    • #3
      No, I did not find a solution for the moment :-(


      • #4
        did you find a solution for that problem?

        I have created a jira-issue. see


        • #5
          Yes... I've switched to Wicket ;-)


          • #6
            How is this wicket thing... can you work with spring from within wicket?


            • #7
              You should be able to use the spring:bind tag around the control you want to re-render partially to setup the same binding in the Ajax case. See the spring:bind tag in the Spring Framework reference manual.



              • #8
                Does this work in any recent versions?

                As a newbie I am frustrated. Is there a solution for the partial render w/tiles, webflow and bindings? If my spring tags (bind or form) reference a model attribute I get the previously mentioned bind failure. Other attempts such as rendering a simple HTML list not bound to an attribute work fine. I have tried upgrading tiles/spring beyond framework=2.6; webflow=2.08; tiles = 2.06 but only succeeded in breaking tiles on startup. Any guidance is appreciated



                • #9
                  Keith is correct, you can use spring:bind and reference the parent modelAttribute value in the path in order for this to work.

                  Using the Spring form input tags to bind individual properties requires a parent form:form tag in the same fragment (with modelAttribute name) in order for the binding to work when rendering the fragment.


                  • #10
                    I have the same problem. Actually, spring:bind is a solution but it's not convenient. it requires to enclose simple html tags with spring:bind whereas our form is build only with spring form tag. It's complexify the code a make almost useless the use of fragment with form pages.

                    Have you plan to find an easier solution ? Like the idea of to make a tag which do the job of form:form without render an html <form> tag ?


                    • #11
                      any idea if this is resolved?


                      • #12
                        I reload only the second select via Ajax, I have an exception


                        • #13
                          refreshing a partial form

                          I am new to this forum so forgive me if I am not posting to the proper thread.
                          I know this thread is old but I have not found a solution to this problem anywhere else yet.

                          I have the same problem of refreshing a JSP fragment that's part of a parent
                          JSP (tiles) which declares the form:form. When I receive the refreshed view from the controller,
                          all the paths (in form:input) have been trimmed down a little bit. The initial
                          paths were something like "ticket.selections[0].numbers[0]". The path after the
                          partial refresh were changed to "selections[0].numbers[0]".

                          Is there any standard technique for doing partial form refresh in Spring 3 ?