Results 1 to 4 of 4

Thread: Content-type in AjaxTilesView not set

  1. #1

    Unhappy Content-type in AjaxTilesView not set

    Hi,
    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:
    Code:
    public class FixFlowAjaxTilesView extends org.springframework.webflow.mvc.view.FlowAjaxTilesView
    {
    
        public FixFlowAjaxTilesView()
        {
            super();
        }
    
        /* (non-Javadoc)
         * @see org.springframework.js.ajax.tiles2.AjaxTilesView#renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
         */
        @SuppressWarnings("unchecked")
        @Override
        protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
                throws Exception
        {
            if (getAjaxHandler().isAjaxRequest(request, response)) 
            {
                response.setContentType(getContentType());
                //response.setCharacterEncoding(arg0)
            }
            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. #2
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Default

    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?
    http://static.springframework.org/sp...ingFilter.html
    Jeremy Grelle

    Staff Engineer, Web Products Team
    SpringSource

  3. #3

    Lightbulb

    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
    and
    AjaxTilesView
    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. #4

    Default

    We resorted to the same work-around as the OP.

    Quote 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 https://fisheye.springsource.org/changelog/spring-js 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?

    Cheers,
    Marcel Stör, http://www.frightanic.com
    Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •