⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 screenrenderer.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $Id: ScreenRenderer.java 6519 2006-01-17 08:17:22Z jonesde $ * * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */package org.ofbiz.widget.screen;import java.io.IOException;import java.io.Writer;import java.util.Enumeration;import java.util.LinkedList;import java.util.List;import java.util.Locale;import java.util.Map;import java.util.Set;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import javax.xml.parsers.ParserConfigurationException;import javolution.util.FastMap;import javolution.util.FastSet;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.GeneralException;import org.ofbiz.base.util.UtilDateTime;import org.ofbiz.base.util.UtilFormatOut;import org.ofbiz.base.util.UtilHttp;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.base.util.collections.MapStack;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntity;import org.ofbiz.entity.GenericValue;import org.ofbiz.security.Security;import org.ofbiz.service.DispatchContext;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.webapp.control.LoginWorker;import org.ofbiz.widget.html.HtmlFormRenderer;import org.xml.sax.SAXException;import freemarker.ext.beans.BeansWrapper;import freemarker.ext.jsp.TaglibFactory;import freemarker.ext.servlet.HttpRequestHashModel;import freemarker.ext.servlet.HttpSessionHashModel;/** * Widget Library - Screen model class * * @author     <a href="mailto:jonesde@ofbiz.org">David E. Jones</a> * @version    $Rev: 6519 $ * @since      3.1 */public class ScreenRenderer {    public static final String module = ScreenRenderer.class.getName();        protected Writer writer;    protected MapStack context;    protected ScreenStringRenderer screenStringRenderer;        public ScreenRenderer(Writer writer, MapStack context, ScreenStringRenderer screenStringRenderer) {        this.writer = writer;        this.context = context;        if (this.context == null) this.context = MapStack.create();        this.screenStringRenderer = screenStringRenderer;    }        /**     * Renders the named screen using the render environment configured when this ScreenRenderer was created.     *      * @param combinedName A combination of the resource name/location for the screen XML file and the name of the screen within that file, separated by a puund sign ("#"). This is the same format that is used in the view-map elements on the controller.xml file.     * @throws IOException     * @throws SAXException     * @throws ParserConfigurationException     */    public String render(String combinedName) throws GeneralException, IOException, SAXException, ParserConfigurationException {        String resourceName = ScreenFactory.getResourceNameFromCombined(combinedName);        String screenName = ScreenFactory.getScreenNameFromCombined(combinedName);        this.render(resourceName, screenName);        return "";    }    /**     * Renders the named screen using the render environment configured when this ScreenRenderer was created.     *      * @param resourceName The name/location of the resource to use, can use "component://[component-name]/" and "ofbiz://" and other special OFBiz style URLs     * @param screenName The name of the screen within the XML file specified by the resourceName.     * @throws IOException     * @throws SAXException     * @throws ParserConfigurationException     */    public String render(String resourceName, String screenName) throws GeneralException, IOException, SAXException, ParserConfigurationException {        ModelScreen modelScreen = ScreenFactory.getScreenFromLocation(resourceName, screenName);        modelScreen.renderScreenString(writer, context, screenStringRenderer);        return "";    }    public ScreenStringRenderer getScreenStringRenderer() {        return this.screenStringRenderer;    }    public void populateBasicContext(Map parameters, GenericDelegator delegator, LocalDispatcher dispatcher, Security security, Locale locale, GenericValue userLogin) {        // ========== setup values that should always be in a screen context        // include an object to more easily render screens        context.put("screens", this);        // make a reference for high level variables, a global context        context.put("globalContext", context.standAloneStack());        // make sure the "nullField" object is in there for entity ops; note this is nullField and not null because as null causes problems in FreeMarker and such...        context.put("nullField", GenericEntity.NULL_FIELD);        // get all locale information        context.put("availableLocales", UtilMisc.availableLocales());        context.put("parameters", parameters);        context.put("delegator", delegator);        context.put("dispatcher", dispatcher);        context.put("security", security);        context.put("locale", locale);        context.put("userLogin", userLogin);    }        /**     * This method populates the context for this ScreenRenderer based on the HTTP Request and Respone objects and the ServletContext.     * It leverages various conventions used in other places, namely the ControlServlet and so on, of OFBiz to get the different resources needed.     *      * @param request     * @param response     * @param servletContext     */    public void populateContextForRequest(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) {        HttpSession session = request.getSession();        // attribute names to skip for session and application attributes; these are all handled as special cases, duplicating results and causing undesired messages        Set attrNamesToSkip = FastSet.newInstance();        attrNamesToSkip.add("delegator");        attrNamesToSkip.add("dispatcher");        attrNamesToSkip.add("security");        attrNamesToSkip.add("webSiteId");        Map parameterMap = UtilHttp.getParameterMap(request);        // go through all request attributes and for each name that is not already in the parameters Map add the attribute value        Enumeration requestAttrNames = request.getAttributeNames();        while (requestAttrNames.hasMoreElements()) {            String attrName = (String) requestAttrNames.nextElement();            Object attrValue = request.getAttribute(attrName);            // NOTE: this is being set to false by default now             //this change came after the realization that it is common to want a request attribute to override a request parameter, but I can't think of even ONE reason why a request parameter should override a request attribute...            final boolean preserveRequestParameters = false;            if (preserveRequestParameters) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -