freemarker.ext.servlet.HttpSessionHashModel Java Examples
The following examples show how to use
freemarker.ext.servlet.HttpSessionHashModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FreeMarkerView.java From spring-analysis-note with MIT License | 5 votes |
/** * Build a FreeMarker {@link HttpSessionHashModel} for the given request, * detecting whether a session already exists and reacting accordingly. * @param request current HTTP request * @param response current servlet response * @return the FreeMarker HttpSessionHashModel */ private HttpSessionHashModel buildSessionModel(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); if (session != null) { return new HttpSessionHashModel(session, getObjectWrapper()); } else { return new HttpSessionHashModel(null, request, response, getObjectWrapper()); } }
Example #2
Source File: FreeMarkerView.java From java-technology-stack with MIT License | 5 votes |
/** * Build a FreeMarker {@link HttpSessionHashModel} for the given request, * detecting whether a session already exists and reacting accordingly. * @param request current HTTP request * @param response current servlet response * @return the FreeMarker HttpSessionHashModel */ private HttpSessionHashModel buildSessionModel(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); if (session != null) { return new HttpSessionHashModel(session, getObjectWrapper()); } else { return new HttpSessionHashModel(null, request, response, getObjectWrapper()); } }
Example #3
Source File: FreeMarkerView.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build a FreeMarker {@link HttpSessionHashModel} for the given request, * detecting whether a session already exists and reacting accordingly. * @param request current HTTP request * @param response current servlet response * @return the FreeMarker HttpSessionHashModel */ private HttpSessionHashModel buildSessionModel(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); if (session != null) { return new HttpSessionHashModel(session, getObjectWrapper()); } else { return new HttpSessionHashModel(null, request, response, getObjectWrapper()); } }
Example #4
Source File: FreeMarkerViewHandler.java From scipio-erp with Apache License 2.0 | 5 votes |
public static void prepOfbizRoot(Map<String, Object> root, HttpServletRequest request, HttpServletResponse response) { ServletContext servletContext = request.getServletContext(); // SCIPIO: get context using servlet API 3.0 HttpSession session = request.getSession(); // add in the OFBiz objects root.put("delegator", request.getAttribute("delegator")); root.put("dispatcher", request.getAttribute("dispatcher")); root.put("security", request.getAttribute("security")); root.put("userLogin", session.getAttribute("userLogin")); // add the response object (for transforms) to the context as a BeanModel root.put("response", response); // add the application object (for transforms) to the context as a BeanModel root.put("application", servletContext); // add the servlet context -- this has been deprecated, and now requires servlet, do we really need it? //root.put("applicationAttributes", new ServletContextHashModel(servletContext, FreeMarkerWorker.getDefaultOfbizWrapper())); // add the session object (for transforms) to the context as a BeanModel root.put("session", session); // add the session root.put("sessionAttributes", new HttpSessionHashModel(session, FreeMarkerWorker.getDefaultOfbizWrapper())); // add the request object (for transforms) to the context as a BeanModel root.put("request", request); // add the request root.put("requestAttributes", new HttpRequestHashModel(request, FreeMarkerWorker.getDefaultOfbizWrapper())); // add the request parameters -- this now uses a Map from UtilHttp Map<String, Object> requestParameters = UtilHttp.getParameterMap(request); root.put("requestParameters", requestParameters); // add the TabLibFactory TaglibFactory JspTaglibs = new TaglibFactory(servletContext); root.put("JspTaglibs", JspTaglibs); }
Example #5
Source File: FreeMarkerView.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Build a FreeMarker {@link HttpSessionHashModel} for the given request, * detecting whether a session already exists and reacting accordingly. * @param request current HTTP request * @param response current servlet response * @return the FreeMarker HttpSessionHashModel */ private HttpSessionHashModel buildSessionModel(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); if (session != null) { return new HttpSessionHashModel(session, getObjectWrapper()); } else { return new HttpSessionHashModel(null, request, response, getObjectWrapper()); } }
Example #6
Source File: CrafterFreeMarkerView.java From engine with GNU General Public License v3.0 | 5 votes |
protected HttpSessionHashModel createSessionModel(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); if(session != null) { return new HttpSessionHashModel(session, getObjectWrapper()); } else { return new HttpSessionHashModel(null, request, response, getObjectWrapper()); } }
Example #7
Source File: CrafterFreeMarkerView.java From engine with GNU General Public License v3.0 | 4 votes |
@Override @SuppressWarnings("deprecation") protected SimpleHash buildTemplateModel(final Map<String, Object> model, final HttpServletRequest request, final HttpServletResponse response) { AllHttpScopesAndAppContextHashModel templateModel = new AllHttpScopesAndAppContextHashModel( getObjectWrapper(), applicationContextAccessor, getServletContext(), request, disableVariableRestrictions); HttpSessionHashModel sessionModel = createSessionModel(request, response); HttpRequestHashModel requestModel = new HttpRequestHashModel(request, response, getObjectWrapper()); HttpRequestParametersHashModel requestParamsModel = new HttpRequestParametersHashModel(request); Map<String, String> cookies = createCookieMap(request); if (disableVariableRestrictions) { templateModel.put(KEY_APPLICATION_CAP, servletContextHashModel); templateModel.put(KEY_APPLICATION, servletContextHashModel); templateModel.put(KEY_APP_CONTEXT_CAP, applicationContextAccessor); templateModel.put(KEY_APP_CONTEXT, applicationContextAccessor); } templateModel.put(KEY_SESSION_CAP, sessionModel); templateModel.put(KEY_SESSION, sessionModel); templateModel.put(KEY_REQUEST_CAP, requestModel); templateModel.put(KEY_REQUEST, requestModel); templateModel.put(KEY_REQUEST_PARAMS_CAP, requestParamsModel); templateModel.put(KEY_REQUEST_PARAMS, requestParamsModel); templateModel.put(KEY_COOKIES_CAP, cookies); templateModel.put(KEY_COOKIES, cookies); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth != null) { templateModel.put(KEY_AUTH_TOKEN, auth); // for backwards compatibility with Profile ... if (auth.getPrincipal() instanceof ProfileUser) { ProfileUser details = (ProfileUser) auth.getPrincipal(); templateModel.put(KEY_AUTH_CAP, details.getAuthentication()); templateModel.put(KEY_AUTH, details.getAuthentication()); templateModel.put(KEY_PROFILE_CAP, details.getProfile()); templateModel.put(KEY_PROFILE, details.getProfile()); } } SiteContext siteContext = SiteContext.getCurrent(); Configuration siteConfig = siteContext.getConfig(); Locale locale = LocaleContextHolder.getLocale(); Object siteContextObject = disableVariableRestrictions? siteContext : new SiteContextHashModel(getObjectWrapper()); TemplateHashModel staticModels = BeansWrapper.getDefaultInstance().getStaticModels(); TemplateHashModel enumModels = BeansWrapper.getDefaultInstance().getEnumModels(); templateModel.put(KEY_STATICS_CAP, staticModels); templateModel.put(KEY_STATICS, staticModels); templateModel.put(KEY_ENUMS_CAP, enumModels); templateModel.put(KEY_ENUMS, enumModels); templateModel.put(KEY_SITE_CONTEXT_CAP, siteContextObject); templateModel.put(KEY_SITE_CONTEXT, siteContextObject); templateModel.put(KEY_LOCALE_CAP, locale); templateModel.put(KEY_LOCALE, locale); if (siteConfig != null) { templateModel.put(KEY_SITE_CONFIG, siteConfig); templateModel.put(KEY_SITE_CONFIG_CAP, siteConfig); } templateModel.putAll(model); ObjectFactory<SimpleHash> componentModelFactory = new ObjectFactory<SimpleHash>() { public SimpleHash getObject() { return buildTemplateModel(model, request, response); } }; RenderComponentDirective renderComponentDirective = new RenderComponentDirective(); renderComponentDirective.setSiteItemService(siteItemService); renderComponentDirective.setModelFactory(componentModelFactory); renderComponentDirective.setTemplateXPathQuery(componentTemplateXPathQuery); renderComponentDirective.setTemplateNamePrefix(componentTemplateNamePrefix); renderComponentDirective.setTemplateNameSuffix(componentTemplateNameSuffix); renderComponentDirective.setIncludeElementName(componentIncludeElementName); renderComponentDirective.setComponentElementName(componentEmbeddedElementName); renderComponentDirective.setScriptResolver(componentScriptResolver); renderComponentDirective.setServletContext(getServletContext()); ExecuteControllerDirective executeControllerDirective = new ExecuteControllerDirective(); executeControllerDirective.setServletContext(getServletContext()); templateModel.put(RENDER_COMPONENT_DIRECTIVE_NAME, renderComponentDirective); templateModel.put(EXECUTE_CONTROLLER_DIRECTIVE_NAME, executeControllerDirective); return templateModel; }