Exemplo n.º 1
0
  /* (non-Javadoc)
   * @see org.springframework.extensions.surf.mvc.AbstractWebFrameworkView#validateRequestContext(org.springframework.extensions.surf.RequestContext, javax.servlet.http.HttpServletRequest)
   */
  @Override
  protected void validateRequestContext(RequestContext rc, HttpServletRequest req)
      throws Exception {
    super.validateRequestContext(rc, req);

    String themeId = null;

    // test to see if this is a site page
    String siteId = rc.getUriTokens().get("site");
    if (siteId != null) {
      // find the site dashboard page - and look for a theme override
      Page dashboard = getObjectService().getPage("site/" + siteId + "/dashboard");
      if (dashboard != null) {
        themeId = dashboard.getProperty("theme");
      }
    } else {
      // examine current page directly for custom properties with a theme override
      // this allows a different theme per page
      themeId = rc.getPage().getProperty("theme");
    }

    // if themeId different to current theme then look it up
    if (themeId != null && themeId.length() != 0 && !rc.getThemeId().equals(themeId)) {
      Theme theme = getObjectService().getTheme(themeId);
      if (theme != null) {
        // found a valid theme - set it current ready for page rendering
        rc.setTheme(theme);
      }
    }
  }