Announcement Announcement Module
No announcement yet.
InternalResourceViewResolver and mobile views Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • InternalResourceViewResolver and mobile views

    In Keith Donalds blog post about Spring Mobile ( 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/${ ? '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 ${ ? 'mobile/' : 'standard/'} also in combination with a InternalResourceViewResolver.

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

  • #2
    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.

    Last edited by Keith Donald; Nov 29th, 2010, 04:35 PM.


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


      • #4
        Yeah, I suggested this in a comment here: