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

📄 modelscreenaction.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    newKey += originalName;                    HttpSession session = (HttpSession)context.get("session");                    session.setAttribute(newKey, newValue);                    if (Debug.verboseOn()) Debug.logVerbose("In user setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, module);            } else if (this.toScope != null && this.toScope.equals("application")) {                    String originalName = this.field.getOriginalName();                    List currentWidgetTrail = (List)context.get("_WIDGETTRAIL_");                    String newKey = "";                    if (currentWidgetTrail != null) {                        newKey = StringUtil.join(currentWidgetTrail, "|");                    }                    if (UtilValidate.isNotEmpty(newKey)) {                        newKey += "|";                    }                    newKey += originalName;                    ServletContext servletContext = (ServletContext)context.get("application");                    servletContext.setAttribute(newKey, newValue);                    if (Debug.verboseOn()) Debug.logVerbose("In application setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, module);            } else {                // only do this if it is not global, if global ONLY put it in the global context                if (!global) {                    if (Debug.verboseOn()) Debug.logVerbose("In screen setting field [" + this.field.getOriginalName() + "] to value: " + newValue, module);                    this.field.put(context, newValue);                }            }                        if (global) {                Map globalCtx = (Map) context.get("globalContext");                if (globalCtx != null) {                    this.field.put(globalCtx, newValue);                } else {                    this.field.put(context, newValue);                }            }                        // this is a hack for backward compatibility with the JPublish page object            Map page = (Map) context.get("page");            if (page != null) {                this.field.put(page, newValue);            }        }                public Object getInMemoryPersistedFromField(Object storeAgent, Map context) {            Object newValue = null;            String originalName = this.fromField.getOriginalName();            List currentWidgetTrail = (List)context.get("_WIDGETTRAIL_");            List trailList = new ArrayList();            if (currentWidgetTrail != null) {                trailList.addAll(currentWidgetTrail);            }                        for (int i=trailList.size(); i >= 0; i--) {                List subTrail = trailList.subList(0,i);                String newKey = null;                if (subTrail.size() > 0)                    newKey = StringUtil.join(subTrail, "|") + "|" + originalName;                else                    newKey = originalName;                                if (storeAgent instanceof ServletContext) {                    newValue = ((ServletContext)storeAgent).getAttribute(newKey);                } else if (storeAgent instanceof HttpSession) {                    newValue = ((HttpSession)storeAgent).getAttribute(newKey);                }                if (newValue != null) {                    break;                }            }            return newValue;        }    }        public static class PropertyMap extends ModelScreenAction {        protected FlexibleStringExpander resourceExdr;        protected FlexibleMapAccessor mapNameAcsr;        protected FlexibleStringExpander globalExdr;                public PropertyMap(ModelScreen modelScreen, Element setElement) {            super (modelScreen, setElement);            this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));            this.mapNameAcsr = new FlexibleMapAccessor(setElement.getAttribute("map-name"));            this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));        }                public void runAction(Map context) {            String globalStr = this.globalExdr.expandString(context);            // default to false            boolean global = "true".equals(globalStr);            Locale locale = (Locale) context.get("locale");            String resource = this.resourceExdr.expandString(context, locale);                        ResourceBundleMapWrapper existingPropMap = (ResourceBundleMapWrapper) this.mapNameAcsr.get(context);            if (existingPropMap == null) {                this.mapNameAcsr.put(context, UtilProperties.getResourceBundleMap(resource, locale));            } else {                existingPropMap.addBottomResourceBundle(resource);            }            if (global) {                Map globalCtx = (Map) context.get("globalContext");                if (globalCtx != null) {                    ResourceBundleMapWrapper globalExistingPropMap = (ResourceBundleMapWrapper) this.mapNameAcsr.get(globalCtx);                    if (globalExistingPropMap == null) {                        this.mapNameAcsr.put(globalCtx, UtilProperties.getResourceBundleMap(resource, locale));                    } else {                        // is it the same object? if not add it in here too...                        if (existingPropMap != globalExistingPropMap) {                            globalExistingPropMap.addBottomResourceBundle(resource);                        }                    }                }            }        }    }        public static class PropertyToField extends ModelScreenAction {                protected FlexibleStringExpander resourceExdr;        protected FlexibleStringExpander propertyExdr;        protected FlexibleMapAccessor fieldAcsr;        protected FlexibleStringExpander defaultExdr;        protected boolean noLocale;        protected FlexibleMapAccessor argListAcsr;        protected FlexibleStringExpander globalExdr;        public PropertyToField(ModelScreen modelScreen, Element setElement) {            super (modelScreen, setElement);            this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));            this.propertyExdr = new FlexibleStringExpander(setElement.getAttribute("property"));            this.fieldAcsr = new FlexibleMapAccessor(setElement.getAttribute("field"));            this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default"));            noLocale = "true".equals(setElement.getAttribute("no-locale"));            this.argListAcsr = new FlexibleMapAccessor(setElement.getAttribute("arg-list-name"));            this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));        }                public void runAction(Map context) {            //String globalStr = this.globalExdr.expandString(context);            // default to false            //boolean global = "true".equals(globalStr);            Locale locale = (Locale) context.get("locale");            String resource = this.resourceExdr.expandString(context, locale);            String property = this.propertyExdr.expandString(context, locale);                        String value = null;            if (noLocale) {                value = UtilProperties.getPropertyValue(resource, property);            } else {                value = UtilProperties.getMessage(resource, property, locale);            }            if (value == null || value.length() == 0) {                value = this.defaultExdr.expandString(context);            }                        // note that expanding the value string here will handle defaultValue and the string from             //  the properties file; if we decide later that we don't want the string from the properties             //  file to be expanded we should just expand the defaultValue at the beginning of this method.            value = FlexibleStringExpander.expandString(value, context);            if (!argListAcsr.isEmpty()) {                List argList = (List) argListAcsr.get(context);                if (argList != null && argList.size() > 0) {                    value = MessageFormat.format(value, argList.toArray());                }            }            fieldAcsr.put(context, value);        }    }        public static class Script extends ModelScreenAction {        protected String location;                public Script(ModelScreen modelScreen, Element scriptElement) {            super (modelScreen, scriptElement);            this.location = scriptElement.getAttribute("location");        }                public void runAction(Map context) throws GeneralException {            if (location.endsWith(".bsh")) {                try {                    BshUtil.runBshAtLocation(location, context);                } catch (GeneralException e) {                    String errMsg = "Error running BSH script at location [" + location + "]: " + e.toString();                    // throwing nested exception instead of logging full detail: Debug.logError(e, errMsg, module);                    throw new GeneralException(errMsg, e);                }            } else {                throw new GeneralException("For screen script actions the script type is not yet support for location:" + location);            }        }    }    public static class Service extends ModelScreenAction {        protected FlexibleStringExpander serviceNameExdr;        protected FlexibleMapAccessor resultMapNameAcsr;        protected FlexibleStringExpander autoFieldMapExdr;        protected Map fieldMap;                public Service(ModelScreen modelScreen, Element serviceElement) {            super (modelScreen, serviceElement);            this.serviceNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("service-name"));            this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor(serviceElement.getAttribute("result-map-name")) : null;            this.autoFieldMapExdr = new FlexibleStringExpander(serviceElement.getAttribute("auto-field-map"));            this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement);        }

⌨️ 快捷键说明

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