Announcement Announcement Module
No announcement yet.
Content-type in AjaxTilesView not set Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Content-type in AjaxTilesView not set

    I use Spring Webflow 2.0.6 with Spring Framework 2.5.6 - After a 2 weeks I have working fragments rendering, but the response from server has no Content-type. I believe when the whole page is rendered tiles takes care about setting response content-type according JSP page, but in AjaxTilesView#renderMergedOutputModel call "container.render(attributeToRender, response.getWriter(), new Object[] { request, response });" doesn't set content-type to response.
    So my Czech letters are just ? in FF.
    I did quick dirty fix:
    public class FixFlowAjaxTilesView extends org.springframework.webflow.mvc.view.FlowAjaxTilesView
        public FixFlowAjaxTilesView()
        /* (non-Javadoc)
         * @see org.springframework.js.ajax.tiles2.AjaxTilesView#renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
        protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
                throws Exception
            if (getAjaxHandler().isAjaxRequest(request, response)) 
            super.renderMergedOutputModel(model, request, response);
    Not sure if that's the right thing to do. Is this a bug or Did I something wrong?

  • #2
    I agree, we should probably go ahead and set the content type in the TilesAjaxView on an Ajax request.

    In the meantime, have you tried using Spring's CharacterEncodingFilter?


    • #3
      Well the encoding is right (everything is UTF-8). Thanks for the filter - next piece of my own class is replaced by spring one.

      As far as I understand HTTP if there is no content-type specified in response the "HTTP default" is used ("text/html; charset=ISO-8859-1"). I think FF takes Ajax-Fragment as ISO-8859-1 and when it renders the chars are broken.
      Anyway setting content-type solves it. In my enviroment it's "text/html;charset=UTF-8".

      As I found the difference btw.
      org.springframework.web.servlet.view.tiles2.TilesV iew#renderMergedOutputModel
      is in invoking method:

      TilesView#container.render(getUrl(), new Object[] {request, response});
      where render fills response._contentType

      AjaxTilesView#container.render(attributeToRender, response.getWriter(), new Object[] { request, response });
      where render doesn't fill anything. I know there is no method available for ajax response.

      But regarding Tiles 2.1 doc container.render(attributeToRender, response.getWriter(), new Object[] { request, response });
      is deprecated and will be not evaluated.
      Thus solved by Tiles. Well it should be cause f.e. jsp can render different content-type (thinking directly JSON

      So maybe worth a note when integrating Tiles 2.1?


      • #4
        We resorted to the same work-around as the OP.

        Originally posted by jeremyg484 View Post
        I agree, we should probably go ahead and set the content type in the TilesAjaxView on an Ajax request.
        Yes, I also believe you should. However, seeing at that there hasn't been any activity on spring-js for a year I don't have much hope.
        Is spring-js dead? I believe that more than two years ago I read somewhere that it should become it's own top level project?