Results 1 to 4 of 4

Thread: InternalResourceViewResolver and mobile views

  1. #1
    Join Date
    May 2005
    Location
    BEEK, The Netherlands
    Posts
    230

    Default InternalResourceViewResolver and mobile views

    In Keith Donalds blog post about Spring Mobile (http://blog.springsource.com/2010/11...n-development/) I found this part interesting:


    Finally, a Tiles-based page layout that changes if the device is a mobile device:

    <definition name="page" templateExpression="/WEB-INF/layouts/${currentDevice.mobile ? 'mobile/' : 'standard/'}page.jsp" />

    I like to do something similar with a InternalResourceViewResolver in my mvc config xml.

    <bean class="org.springframework.web.servlet.view.Intern alResourceViewResolver" prefix="/WEB-INF/views/" p:suffix=".jsp" />

    This because I'm not using Tiles but plain JSP's (decorated using SiteMesh).

    Can I use the expression like ${currentDevice.mobile ? 'mobile/' : 'standard/'} also in combination with a InternalResourceViewResolver.

    Bases on the currentDevice.mobile I want to render
    index.jsp (for desktop) or index.iphone.jsp or perhaps index.android.jsp.

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Unfortunately InternalResourceViewResolver does not support view template expressions, it only allows a static prefix and suffix values to be injected. You could implement your own ViewResolver that would do this, perhaps even a special subclass or composite of InternalResourceViewResolver. ViewResolver is passed the HttpServletRequest and from the request you can obtain the currentDevice as a request attribute. You can also get at RequestAttributes via the RequestContextHolder thread local.

    Keith
    Last edited by Keith Donald; Nov 29th, 2010 at 04:35 PM.
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    May 2005
    Location
    BEEK, The Netherlands
    Posts
    230

    Default

    Probabably a DeviceAwareInternalResourceViewResolver in Spring Mobile core would have benefit for everybody. Would be a feature request I guess.

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Yeah, I suggested this in a comment here: http://blog.springsource.com/2010/12...comment-181442.
    Keith Donald
    Core Spring Development Team

Posting Permissions

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