Announcement Announcement Module
Collapse
No announcement yet.
Render fragments with Ajax in webflow renders full page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Render fragments with Ajax in webflow renders full page

    Hi all,

    I have a problem where I want to use AJAX to re-render a part of the screen in webflow. I am in a view-state and use a transition "refresh" that will stay in the same view-state but needs to re-render the "part" tile of the view.

    I have read many forum posts (and solutions) on this topic, but none of the solutions worked for me.

    As soon as the AJAX call is sent (with the correct fragments parameters), I can see in the server logging that the fragments are correctly interpreted

    Code:
    Flash scope = map['flowRenderFragments' -> array<String>['test']]
    But instead I get the complete page rendered as a 302 redirect response.

    It seems that I have 2 problems. How can I disable this redirect (only for this ajax call) and how can I get only the necessary fragment.

    I am using spring 3.0.5, webflow 2.3.0 and tiles 2.2.2

    Some excerpts of my configuration:

    Code:
    <bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.webflow.mvc.view.FlowAjaxTilesView"/>
    </bean>
    main.jsp
    Code:
    <tiles:insertAttribute name="part"/>
    
    <c:url value="/editor/editor.do?_eventId=refresh&_flowExecutionKey=${flowExecutionKey}&fragments=part" var="refreshAction"/>
    
    <input type="button" onclick="refresh();" value="refresh"/>
    
    <script type="text/javascript" language="JavaScript">
    
        function refresh()
        {
            jQuery.get('${refreshAction}', function(data) {
                jQuery('#test').html(data);
            });
        }
    </script>
    part.jsp
    Code:
    <div id="part">
        <%= new java.util.Date() %>
    </div>
    tiles:
    Code:
    <definition name=".main" template="/WEB-INF/jsp/main.jsp">
            <put-attribute name="part"  value=".part" />
    </definition>
    
    <definition name=".part" template="/WEB-INF/part.jsp"/>

  • #2
    ur code looks fine to me ..try
    appending &ajaxSource=true to the end of the url

    Comment


    • #3
      Maybe you could try this instead...

      <button type="submit" id="refreshBtn" name="_eventId_refresh">Refresh</button>
      <script type="text/javascript">
      Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'refreshBtn' ,event:'onclick',formId:'yourForm'}));
      </script>
      And in your flow use...

      <transition on="refresh">
      <render fragments="part"/>
      </transition>
      and does your main.jsp have a root div? Perhaps this is also a problem. I always find this feature quite picky!

      Comment

      Working...
      X