📄 screenrenderer.java
字号:
Object param = parameterMap.get(attrName); if (param == null) { parameterMap.put(attrName, attrValue); } else if (param instanceof String && ((String) param).length() == 0) { // also put the attribute value in if the parameter is empty parameterMap.put(attrName, attrValue); } else { // do nothing, just log something Debug.logInfo("Found request attribute that conflicts with parameter name, leaving request parameter in place for name: " + attrName, module); } } else { parameterMap.put(attrName, attrValue); } } // do the same for session attributes, for convenience Enumeration sessionAttrNames = session.getAttributeNames(); while (sessionAttrNames.hasMoreElements()) { String attrName = (String) sessionAttrNames.nextElement(); if (attrNamesToSkip.contains(attrName)) continue; Object attrValue = session.getAttribute(attrName); Object param = parameterMap.get(attrName); if (param == null) { parameterMap.put(attrName, attrValue); } else if (param instanceof String && ((String) param).length() == 0) { // also put the attribute value in if the parameter is empty parameterMap.put(attrName, attrValue); } else { // do nothing, just log something Debug.logInfo("Found session attribute that conflicts with parameter name, leaving request parameter in place for name: " + attrName, module); } } // do the same for servlet context (application) attribute, for convenience Enumeration applicationAttrNames = servletContext.getAttributeNames(); while (applicationAttrNames.hasMoreElements()) { String attrName = (String) applicationAttrNames.nextElement(); if (attrNamesToSkip.contains(attrName)) continue; Object param = parameterMap.get(attrName); Object attrValue = servletContext.getAttribute(attrName); if (Debug.verboseOn()) Debug.logVerbose("Getting parameter from application attrbute with name [" + attrName + "] and value [" + attrValue + "]", module); if (param == null) { parameterMap.put(attrName, attrValue); } else if (param instanceof String && ((String) param).length() == 0) { // also put the attribute value in if the parameter is empty parameterMap.put(attrName, attrValue); } else { // do nothing, just log something Debug.logInfo("Found servlet context (application) attribute that conflicts with parameter name, leaving request parameter in place for name: " + attrName, module); } } GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); this.populateBasicContext(parameterMap, (GenericDelegator) request.getAttribute("delegator"), (LocalDispatcher) request.getAttribute("dispatcher"), (Security) request.getAttribute("security"), UtilHttp.getLocale(request), userLogin); context.put("autoUserLogin", session.getAttribute("autoUserLogin")); context.put("person", session.getAttribute("person")); context.put("partyGroup", session.getAttribute("partyGroup")); // some things also seem to require this, so here it is: request.setAttribute("userLogin", userLogin); // ========== setup values that are specific to OFBiz webapps // this is the object used to render forms from their definitions context.put("formStringRenderer", new HtmlFormRenderer(request, response)); context.put("request", request); context.put("response", response); context.put("session", session); context.put("application", servletContext); if (servletContext != null) { String rootDir = (String) context.get("rootDir"); String webSiteId = (String) context.get("webSiteId"); String https = (String) context.get("https"); if (UtilValidate.isEmpty(rootDir)) { rootDir = servletContext.getRealPath("/"); context.put("rootDir", rootDir); } if (UtilValidate.isEmpty(webSiteId)) { webSiteId = (String) servletContext.getAttribute("webSiteId"); context.put("webSiteId", webSiteId); } if (UtilValidate.isEmpty(https)) { https = (String) servletContext.getAttribute("https"); context.put("https", https); } } // these ones are FreeMarker specific and will only work in FTL templates, mainly here for backward compatibility BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); context.put("sessionAttributes", new HttpSessionHashModel(session, wrapper)); context.put("requestAttributes", new HttpRequestHashModel(request, wrapper)); TaglibFactory JspTaglibs = new TaglibFactory(servletContext); context.put("JspTaglibs", JspTaglibs); context.put("requestParameters", UtilHttp.getParameterMap(request)); // this is a dummy object to stand-in for the JPublish page object for backward compatibility context.put("page", FastMap.newInstance()); // some information from/about the ControlServlet environment context.put("controlPath", request.getAttribute("_CONTROL_PATH_")); context.put("contextRoot", request.getAttribute("_CONTEXT_ROOT_")); context.put("serverRoot", request.getAttribute("_SERVER_ROOT_URL_")); context.put("checkLoginUrl", LoginWorker.makeLoginUrl(request, "checkLogin")); String externalLoginKey = LoginWorker.getExternalLoginKey(request); String externalKeyParam = externalLoginKey == null ? "" : "&externalLoginKey=" + externalLoginKey; context.put("externalLoginKey", externalLoginKey); context.put("externalKeyParam", externalKeyParam); // setup message lists List eventMessageList = (List) request.getAttribute("eventMessageList"); if (eventMessageList == null) eventMessageList = new LinkedList(); List errorMessageList = (List) request.getAttribute("errorMessageList"); if (errorMessageList == null) errorMessageList = new LinkedList(); if (request.getAttribute("_EVENT_MESSAGE_") != null) { eventMessageList.add(UtilFormatOut.replaceString((String) request.getAttribute("_EVENT_MESSAGE_"), "\n", "<br/>")); request.removeAttribute("_EVENT_MESSAGE_"); } if (request.getAttribute("_EVENT_MESSAGE_LIST_") != null) { eventMessageList.addAll((List) request.getAttribute("_EVENT_MESSAGE_LIST_")); request.removeAttribute("_EVENT_MESSAGE_LIST_"); } if (request.getAttribute("_ERROR_MESSAGE_") != null) { errorMessageList.add(UtilFormatOut.replaceString((String) request.getAttribute("_ERROR_MESSAGE_"), "\n", "<br/>")); request.removeAttribute("_ERROR_MESSAGE_"); } if (session.getAttribute("_ERROR_MESSAGE_") != null) { errorMessageList.add(UtilFormatOut.replaceString((String) session.getAttribute("_ERROR_MESSAGE_"), "\n", "<br/>")); session.removeAttribute("_ERROR_MESSAGE_"); } if (request.getAttribute("_ERROR_MESSAGE_LIST_") != null) { errorMessageList.addAll((List) request.getAttribute("_ERROR_MESSAGE_LIST_")); request.removeAttribute("_ERROR_MESSAGE_LIST_"); } context.put("eventMessageList", eventMessageList); context.put("errorMessageList", errorMessageList); if (request.getAttribute("serviceValidationException") != null) { context.put("serviceValidationException", request.getAttribute("serviceValidationException")); request.removeAttribute("serviceValidationException"); } // if there was an error message, this is an error if (errorMessageList.size() > 0) { context.put("isError", Boolean.TRUE); } else { context.put("isError", Boolean.FALSE); } // if a parameter was passed saying this is an error, it is an error if ("true".equals((String) parameterMap.get("isError"))) { context.put("isError", Boolean.TRUE); } context.put("nowTimestamp", UtilDateTime.nowTimestamp()); // to preserve these values, push the MapStack context.push(); } public Map getContext() { return context; } public void populateContextForService(DispatchContext dctx, Map serviceContext) { this.populateBasicContext(serviceContext, dctx.getDelegator(), dctx.getDispatcher(), dctx.getSecurity(), (Locale) serviceContext.get("locale"), (GenericValue) serviceContext.get("userLogin")); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -