Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -74,12 +74,12 @@ this.modelScreen = modelScreen; if (Debug.verboseOn()) Debug.logVerbose("Reading Screen action with name: " + actionElement.getNodeName(), module); } - + public abstract void runAction(Map<String, Object> context) throws GeneralException; - + public static List<ModelScreenAction> readSubActions(ModelScreen modelScreen, Element parentElement) { List<ModelScreenAction> actions = FastList.newInstance(); - + List<? extends Element> actionElementList = UtilXml.childElementList(parentElement); for (Element actionElement: actionElementList) { if ("set".equals(actionElement.getNodeName())) { @@ -106,19 +106,19 @@ throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName()); } } - + return actions; } - + public static void runSubActions(List<ModelScreenAction> actions, Map<String, Object> context) throws GeneralException { if (actions == null) return; - + for (ModelScreenAction action: actions) { if (Debug.verboseOn()) Debug.logVerbose("Running screen action " + action.getClass().getName(), module); action.runAction(context); } } - + public static class SetField extends ModelScreenAction { protected FlexibleMapAccessor<Object> field; protected FlexibleMapAccessor<Object> fromField; @@ -128,7 +128,7 @@ protected String type; protected String toScope; protected String fromScope; - + public SetField(ModelScreen modelScreen, Element setElement) { super (modelScreen, setElement); this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field")); @@ -143,12 +143,12 @@ throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a screen widget"); } } - + public void runAction(Map<String, Object> context) { String globalStr = this.globalExdr.expandString(context); // default to false boolean global = "true".equals(globalStr); - + Object newValue = null; if (this.fromScope != null && this.fromScope.equals("user")) { if (!this.fromField.isEmpty()) { @@ -179,7 +179,7 @@ if (ObjectType.isEmpty(newValue) && !this.defaultExdr.isEmpty()) { newValue = this.defaultExdr.expandString(context); } - + if (UtilValidate.isNotEmpty(this.type)) { try { newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); @@ -189,7 +189,7 @@ throw new IllegalArgumentException(errMsg); } } - + if (this.toScope != null && this.toScope.equals("user")) { String originalName = this.field.getOriginalName(); List<String> currentWidgetTrail = UtilGenerics.toList(context.get("_WIDGETTRAIL_")); @@ -225,7 +225,7 @@ this.field.put(context, newValue); } } - + if (global) { Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); if (globalCtx != null) { @@ -234,14 +234,14 @@ this.field.put(context, newValue); } } - + // this is a hack for backward compatibility with the JPublish page object Map<String, Object> page = UtilGenerics.checkMap(context.get("page")); if (page != null) { this.field.put(page, newValue); } } - + public Object getInMemoryPersistedFromField(Object storeAgent, Map<String, Object> context) { Object newValue = null; String originalName = this.fromField.getOriginalName(); @@ -250,7 +250,7 @@ if (currentWidgetTrail != null) { trailList.addAll(currentWidgetTrail); } - + for (int i=trailList.size(); i >= 0; i--) { List<String> subTrail = trailList.subList(0,i); String newKey = null; @@ -258,7 +258,7 @@ newKey = StringUtil.join(subTrail, "|") + "|" + originalName; else newKey = originalName; - + if (storeAgent instanceof ServletContext) { newValue = ((ServletContext)storeAgent).getAttribute(newKey); } else if (storeAgent instanceof HttpSession) { @@ -271,19 +271,19 @@ return newValue; } } - + public static class PropertyMap extends ModelScreenAction { protected FlexibleStringExpander resourceExdr; protected FlexibleMapAccessor<ResourceBundleMapWrapper> mapNameAcsr; protected FlexibleStringExpander globalExdr; - + public PropertyMap(ModelScreen modelScreen, Element setElement) { super (modelScreen, setElement); this.resourceExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("resource")); this.mapNameAcsr = FlexibleMapAccessor.getInstance(setElement.getAttribute("map-name")); this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global")); } - + public void runAction(Map<String, Object> context) { String globalStr = this.globalExdr.expandString(context); // default to false @@ -291,7 +291,7 @@ Locale locale = (Locale) context.get("locale"); String resource = this.resourceExdr.expandString(context, locale); - + ResourceBundleMapWrapper existingPropMap = this.mapNameAcsr.get(context); if (existingPropMap == null) { this.mapNameAcsr.put(context, UtilProperties.getResourceBundleMap(resource, locale, context)); @@ -325,9 +325,9 @@ } } } - + public static class PropertyToField extends ModelScreenAction { - + protected FlexibleStringExpander resourceExdr; protected FlexibleStringExpander propertyExdr; protected FlexibleMapAccessor<Object> fieldAcsr; @@ -346,7 +346,7 @@ this.argListAcsr = FlexibleMapAccessor.getInstance(setElement.getAttribute("arg-list-name")); this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global")); } - + public void runAction(Map<String, Object> context) { //String globalStr = this.globalExdr.expandString(context); // default to false @@ -355,7 +355,7 @@ 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); @@ -365,8 +365,8 @@ 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 + + // 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); @@ -381,15 +381,15 @@ 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<String, Object> context) throws GeneralException { if (location.endsWith(".bsh")) { try { @@ -427,7 +427,7 @@ protected FlexibleMapAccessor<Map<String, Object>> resultMapNameAcsr; protected FlexibleStringExpander autoFieldMapExdr; protected Map<FlexibleMapAccessor<Object>, Object> fieldMap; - + public Service(ModelScreen modelScreen, Element serviceElement) { super (modelScreen, serviceElement); this.serviceNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("service-name")); @@ -436,15 +436,15 @@ this.autoFieldMapExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("auto-field-map")); this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement); } - + public void runAction(Map<String, Object> context) { String serviceNameExpanded = this.serviceNameExdr.expandString(context); if (UtilValidate.isEmpty(serviceNameExpanded)) { throw new IllegalArgumentException("Service name was empty, expanded from: " + this.serviceNameExdr.getOriginal()); } - + String autoFieldMapString = this.autoFieldMapExdr.expandString(context); - + try { Map<String, Object> serviceContext = null; if ("true".equals(autoFieldMapString)) { @@ -463,17 +463,17 @@ if (autoFieldMap != null) { serviceContext = this.modelScreen.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, autoFieldMap); } - } + } if (serviceContext == null) { serviceContext = FastMap.newInstance(); } - + if (this.fieldMap != null) { EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); } - + Map<String, Object> result = this.modelScreen.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); - + if (!this.resultMapNameAcsr.isEmpty()) { this.resultMapNameAcsr.put(context, result); String queryString = (String)result.get("queryString"); @@ -484,7 +484,7 @@ String queryStringEncoded = queryString.replaceAll("&", "%26"); context.put("queryStringEncoded", queryStringEncoded); } catch (PatternSyntaxException e) { - + } } } else { @@ -500,12 +500,12 @@ public static class EntityOne extends ModelScreenAction { protected PrimaryKeyFinder finder; - + public EntityOne(ModelScreen modelScreen, Element entityOneElement) { super (modelScreen, entityOneElement); finder = new PrimaryKeyFinder(entityOneElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); @@ -519,12 +519,12 @@ public static class EntityAnd extends ModelScreenAction { protected ByAndFinder finder; - + public EntityAnd(ModelScreen modelScreen, Element entityAndElement) { super (modelScreen, entityAndElement); finder = new ByAndFinder(entityAndElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); @@ -538,12 +538,12 @@ public static class EntityCondition extends ModelScreenAction { ByConditionFinder finder; - + public EntityCondition(ModelScreen modelScreen, Element entityConditionElement) { super (modelScreen, entityConditionElement); finder = new ByConditionFinder(entityConditionElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); @@ -560,7 +560,7 @@ protected FlexibleMapAccessor<Object> toValueNameAcsr; protected String relationName; protected boolean useCache; - + public GetRelatedOne(ModelScreen modelScreen, Element getRelatedOneElement) { super (modelScreen, getRelatedOneElement); this.valueNameAcsr = FlexibleMapAccessor.getInstance(getRelatedOneElement.getAttribute("value-field")); @@ -595,7 +595,7 @@ throw new IllegalArgumentException(errMsg); } } - + } public static class GetRelated extends ModelScreenAction { @@ -605,7 +605,7 @@ protected FlexibleMapAccessor<List<String>> orderByListAcsr; protected String relationName; protected boolean useCache; - + public GetRelated(ModelScreen modelScreen, Element getRelatedElement) { super (modelScreen, getRelatedElement); this.valueNameAcsr = FlexibleMapAccessor.getInstance(getRelatedElement.getAttribute("value-field")); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -74,17 +74,17 @@ } return rootCondition.eval(context); } - + public static abstract class ScreenCondition implements Serializable { protected ModelScreen modelScreen; public ScreenCondition(ModelScreen modelScreen, Element conditionElement) { this.modelScreen = modelScreen; } - + public abstract boolean eval(Map<String, Object> context); } - + public static List<ScreenCondition> readSubConditions(ModelScreen modelScreen, Element conditionElement) { List<ScreenCondition> condList = FastList.newInstance(); List<? extends Element> subElementList = UtilXml.childElementList(conditionElement); @@ -93,7 +93,7 @@ } return condList; } - + public static ScreenCondition readCondition(ModelScreen modelScreen, Element conditionElement) { if (conditionElement == null) { return null; @@ -126,15 +126,15 @@ throw new IllegalArgumentException("Condition element not supported with name: " + conditionElement.getNodeName()); } } - + public static class And extends ScreenCondition { protected List<ScreenCondition> subConditions; - + public And(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.subConditions = readSubConditions(modelScreen, condElement); } - + public boolean eval(Map<String, Object> context) { // return false for the first one in the list that is false, basic and algo for (ScreenCondition subCondition: this.subConditions) { @@ -145,15 +145,15 @@ return true; } } - + public static class Xor extends ScreenCondition { protected List<ScreenCondition> subConditions; - + public Xor(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.subConditions = readSubConditions(modelScreen, condElement); } - + public boolean eval(Map<String, Object> context) { // if more than one is true stop immediately and return false; if all are false return false; if only one is true return true boolean foundOneTrue = false; @@ -170,15 +170,15 @@ return foundOneTrue; } } - + public static class Or extends ScreenCondition { protected List<ScreenCondition> subConditions; - + public Or(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.subConditions = readSubConditions(modelScreen, condElement); } - + public boolean eval(Map<String, Object> context) { // return true for the first one in the list that is true, basic or algo for (ScreenCondition subCondition: this.subConditions) { @@ -189,16 +189,16 @@ return false; } } - + public static class Not extends ScreenCondition { protected ScreenCondition subCondition; - + public Not(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); Element firstChildElement = UtilXml.firstChildElement(condElement); this.subCondition = readCondition(modelScreen, firstChildElement); } - + public boolean eval(Map<String, Object> context) { return !this.subCondition.eval(context); } @@ -229,7 +229,7 @@ if (UtilValidate.isEmpty(resource)) { resource = serviceName; } - + if (UtilValidate.isEmpty(serviceName)) { Debug.logWarning("No permission service-name specified!", module); return false; @@ -290,20 +290,20 @@ public static class IfHasPermission extends ScreenCondition { protected FlexibleStringExpander permissionExdr; protected FlexibleStringExpander actionExdr; - + public IfHasPermission(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.permissionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("permission")); this.actionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("action")); } - + public boolean eval(Map<String, Object> context) { // if no user is logged in, treat as if the user does not have permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (userLogin != null) { String permission = permissionExdr.expandString(context); String action = actionExdr.expandString(context); - + Security security = (Security) context.get("security"); if (action != null && action.length() > 0) { // run hasEntityPermission @@ -325,7 +325,7 @@ protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander methodExdr; protected FlexibleStringExpander classExdr; - + public IfValidateMethod(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); @@ -333,11 +333,11 @@ this.methodExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("method")); this.classExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("class")); } - + public boolean eval(Map<String, Object> context) { String methodName = this.methodExdr.expandString(context); String className = this.classExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); String fieldString = null; if (fieldVal != null) { @@ -380,7 +380,7 @@ return resultBool.booleanValue(); } } - + public static class IfCompare extends ScreenCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander valueExdr; @@ -388,25 +388,25 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompare(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.valueExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("value")); - + this.operator = condElement.getAttribute("operator"); this.type = condElement.getAttribute("type"); this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format")); } - + public boolean eval(Map<String, Object> context) { String value = this.valueExdr.expandString(context); String format = this.formatExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); - + // always use an empty string by default if (fieldVal == null) { fieldVal = ""; @@ -425,11 +425,11 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfCompareField extends ScreenCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleMapAccessor<Object> toFieldAcsr; @@ -437,26 +437,26 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompareField(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field")); if (this.toFieldAcsr.isEmpty()) this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field-name")); - + this.operator = condElement.getAttribute("operator"); this.type = condElement.getAttribute("type"); this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format")); } - + public boolean eval(Map<String, Object> context) { String format = this.formatExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); Object toFieldVal = this.toFieldAcsr.get(context); - + // always use an empty string by default if (fieldVal == null) { fieldVal = ""; @@ -475,25 +475,25 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfRegexp extends ScreenCondition { static PatternMatcher matcher = new Perl5Matcher(); static PatternCompiler compiler = new Perl5Compiler(); protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander exprExdr; - + public IfRegexp(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.exprExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("expr")); } - + public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); String expr = this.exprExdr.expandString(context); @@ -514,20 +514,20 @@ } // always use an empty string by default if (fieldString == null) fieldString = ""; - + return matcher.matches(fieldString, pattern); } } - + public static class IfEmpty extends ScreenCondition { protected FlexibleMapAccessor<Object> fieldAcsr; - + public IfEmpty(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); } - + public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); return ObjectType.isEmpty(fieldVal); @@ -535,12 +535,12 @@ } public static class IfEntityPermission extends ScreenCondition { protected EntityPermissionChecker permissionChecker; - + public IfEntityPermission(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.permissionChecker = new EntityPermissionChecker(condElement); } - + public boolean eval(Map<String, Object> context) { return permissionChecker.runPermissionCheck(context); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -71,17 +71,17 @@ public static final String module = ModelScreenWidget.class.getName(); protected ModelScreen modelScreen; - + public ModelScreenWidget(ModelScreen modelScreen, Element widgetElement) { super(widgetElement); this.modelScreen = modelScreen; if (Debug.verboseOn()) Debug.logVerbose("Reading Screen sub-widget with name: " + widgetElement.getNodeName(), module); } - + public abstract void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException; public abstract String rawString(); - + public static List<ModelScreenWidget> readSubWidgets(ModelScreen modelScreen, List<? extends Element> subElementList) { List<ModelScreenWidget> subWidgets = FastList.newInstance(); for (Element subElement: subElementList) { @@ -123,10 +123,10 @@ throw new IllegalArgumentException("Found invalid screen widget element with name: " + subElement.getNodeName()); } } - + return subWidgets; } - + public static void renderSubWidgetsString(List<ModelScreenWidget> subWidgets, Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { if (subWidgets == null) { return; @@ -142,16 +142,16 @@ public boolean boundaryCommentsEnabled() { return modelScreen.boundaryCommentsEnabled(); } - + public ModelScreen getModelScreen() { return this.modelScreen; } - + public static class SectionsRenderer extends HashMap<String, Object> { protected ScreenStringRenderer screenStringRenderer; protected Map<String, Object> context; protected Appendable writer; - + public SectionsRenderer(Map<String, ? extends Object> sectionMap, Map<String, Object> context, Appendable writer, ScreenStringRenderer screenStringRenderer) { this.putAll(sectionMap); this.context = context; @@ -176,7 +176,7 @@ protected List<ModelScreenWidget> subWidgets; protected List<ModelScreenWidget> failWidgets; public boolean isMainSection = false; - + public Section(ModelScreen modelScreen, Element sectionElement) { super(modelScreen, sectionElement); @@ -191,7 +191,7 @@ if (actionsElement != null) { this.actions = ModelScreenAction.readSubActions(modelScreen, actionsElement); } - + // read sub-widgets Element widgetsElement = UtilXml.firstChildElement(sectionElement, "widgets"); List<? extends Element> subElementList = UtilXml.childElementList(widgetsElement); @@ -213,16 +213,16 @@ condTrue = false; } } - + // if condition does not exist or evals to true run actions and render widgets, otherwise render fail-widgets if (condTrue) { // run the actions only if true ModelScreenAction.runSubActions(this.actions, context); - + try { // section by definition do not themselves do anything, so this method will generally do nothing, but we'll call it anyway screenStringRenderer.renderSectionBegin(writer, context, this); - + // render sub-widgets renderSubWidgetsString(this.subWidgets, writer, context, screenStringRenderer); @@ -236,7 +236,7 @@ try { // section by definition do not themselves do anything, so this method will generally do nothing, but we'll call it anyway screenStringRenderer.renderSectionBegin(writer, context, this); - + // render sub-widgets renderSubWidgetsString(this.failWidgets, writer, context, screenStringRenderer); @@ -247,9 +247,9 @@ throw new RuntimeException(errMsg); } } - + } - + public String getBoundaryCommentName() { if (isMainSection) { return modelScreen.getSourceLocation() + "#" + modelScreen.getName(); @@ -257,7 +257,7 @@ return name; } } - + public String rawString() { return "<section" + (UtilValidate.isNotEmpty(this.name)?" name=\"" + this.name + "\"":"") + ">"; } @@ -269,7 +269,7 @@ protected FlexibleStringExpander autoUpdateTargetExdr; protected String autoUpdateInterval = "2"; protected List<ModelScreenWidget> subWidgets; - + public Container(ModelScreen modelScreen, Element containerElement) { super(modelScreen, containerElement); this.idExdr = FlexibleStringExpander.getInstance(containerElement.getAttribute("id")); @@ -278,7 +278,7 @@ if (containerElement.hasAttribute("auto-update-interval")) { this.autoUpdateInterval = containerElement.getAttribute("auto-update-interval"); } - + // read sub-widgets List<? extends Element> subElementList = UtilXml.childElementList(containerElement); this.subWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, subElementList); @@ -287,7 +287,7 @@ public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { try { screenStringRenderer.renderContainerBegin(writer, context, this); - + // render sub-widgets renderSubWidgetsString(this.subWidgets, writer, context, screenStringRenderer); @@ -298,11 +298,11 @@ throw new RuntimeException(errMsg); } } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } @@ -330,7 +330,7 @@ protected boolean initiallyCollapsed = false; protected boolean padded = true; protected List<ModelScreenWidget> subWidgets; - + public Screenlet(ModelScreen modelScreen, Element screenletElement) { super(modelScreen, screenletElement); this.idExdr = FlexibleStringExpander.getInstance(screenletElement.getAttribute("id")); @@ -404,7 +404,7 @@ throw new RuntimeException(errMsg + e); } } - + public boolean collapsible() { return this.collapsible; } @@ -428,7 +428,7 @@ public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getTitle(Map<String, Object> context) { return this.titleExdr.expandString(context); } @@ -453,7 +453,7 @@ public static class HorizontalSeparator extends ModelScreenWidget { protected FlexibleStringExpander idExdr; protected FlexibleStringExpander styleExdr; - + public HorizontalSeparator(ModelScreen modelScreen, Element separatorElement) { super(modelScreen, separatorElement); this.idExdr = FlexibleStringExpander.getInstance(separatorElement.getAttribute("id")); @@ -463,11 +463,11 @@ public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { screenStringRenderer.renderHorizontalSeparator(writer, context, this); } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } @@ -481,7 +481,7 @@ protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; protected FlexibleStringExpander shareScopeExdr; - + public IncludeScreen(ModelScreen modelScreen, Element includeScreenElement) { super(modelScreen, includeScreenElement); this.nameExdr = FlexibleStringExpander.getInstance(includeScreenElement.getAttribute("name")); @@ -496,36 +496,36 @@ if (!(context instanceof MapStack)) { context = MapStack.create(context); } - + ((MapStack) context).push(); - + // build the widgetpath List<String> widgetTrail = UtilGenerics.toList(context.get("_WIDGETTRAIL_")); if (widgetTrail == null) { widgetTrail = FastList.newInstance(); } - + String thisName = nameExdr.expandString(context); widgetTrail.add(thisName); context.put("_WIDGETTRAIL_", widgetTrail); } - + // dont need the renderer here, will just pass this on down to another screen call; screenStringRenderer.renderContainerBegin(writer, context, this); String name = this.getName(context); String location = this.getLocation(context); - + if (UtilValidate.isEmpty(name)) { if (Debug.verboseOn()) Debug.logVerbose("In the include-screen tag the screen name was empty, ignoring include; in screen [" + this.modelScreen.getName() + "]", module); return; } - + // check to see if the name is a composite name separated by a #, if so split it up and get it by the full loc#name if (ScreenFactory.isCombinedName(name)) { String combinedName = name; location = ScreenFactory.getResourceNameFromCombined(combinedName); name = ScreenFactory.getScreenNameFromCombined(combinedName); } - + ModelScreen modelScreen = null; if (UtilValidate.isNotEmpty(location)) { try { @@ -555,15 +555,15 @@ ((MapStack) context).pop(); } } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } - + public boolean shareScope(Map<String, Object> context) { String shareScopeString = this.shareScopeExdr.expandString(context); // defaults to false, so anything but true is false @@ -579,12 +579,12 @@ protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; protected Map<String, DecoratorSection> sectionMap = new HashMap<String, DecoratorSection>(); - + public DecoratorScreen(ModelScreen modelScreen, Element decoratorScreenElement) { super(modelScreen, decoratorScreenElement); this.nameExdr = FlexibleStringExpander.getInstance(decoratorScreenElement.getAttribute("name")); this.locationExdr = FlexibleStringExpander.getInstance(decoratorScreenElement.getAttribute("location")); - + List<? extends Element> decoratorSectionElementList = UtilXml.childElementList(decoratorScreenElement, "decorator-section"); for (Element decoratorSectionElement: decoratorSectionElementList) { String name = decoratorSectionElement.getAttribute("name"); @@ -598,28 +598,28 @@ if (!(context instanceof MapStack)) { context = MapStack.create(context); } - + MapStack contextMs = (MapStack) context; // create a standAloneStack, basically a "save point" for this SectionsRenderer, and make a new "screens" object just for it so it is isolated and doesn't follow the stack down MapStack standAloneStack = contextMs.standAloneChildStack(); standAloneStack.put("screens", new ScreenRenderer(writer, standAloneStack, screenStringRenderer)); SectionsRenderer sections = new SectionsRenderer(this.sectionMap, standAloneStack, writer, screenStringRenderer); - + // put the sectionMap in the context, make sure it is in the sub-scope, ie after calling push on the MapStack contextMs.push(); context.put("sections", sections); - + String name = this.getName(context); String location = this.getLocation(context); - + // check to see if the name is a composite name separated by a #, if so split it up and get it by the full loc#name if (ScreenFactory.isCombinedName(name)) { String combinedName = name; location = ScreenFactory.getResourceNameFromCombined(combinedName); name = ScreenFactory.getScreenNameFromCombined(combinedName); } - + ModelScreen modelScreen = null; if (UtilValidate.isNotEmpty(location)) { try { @@ -651,7 +651,7 @@ public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } @@ -663,7 +663,7 @@ public static class DecoratorSection extends ModelScreenWidget { protected List<ModelScreenWidget> subWidgets; - + public DecoratorSection(ModelScreen modelScreen, Element decoratorSectionElement) { super(modelScreen, decoratorSectionElement); // read sub-widgets @@ -680,9 +680,9 @@ return "<decorator-section name=\"" + this.name + "\">"; } } - + public static class DecoratorSectionInclude extends ModelScreenWidget { - + public DecoratorSectionInclude(ModelScreen modelScreen, Element decoratorSectionElement) { super(modelScreen, decoratorSectionElement); } @@ -712,13 +712,13 @@ return "<decorator-section-include name=\"" + this.name + "\">"; } } - + public static class Label extends ModelScreenWidget { protected FlexibleStringExpander textExdr; - + protected FlexibleStringExpander idExdr; protected FlexibleStringExpander styleExdr; - + public Label(ModelScreen modelScreen, Element labelElement) { super(modelScreen, labelElement); @@ -740,7 +740,7 @@ throw new RuntimeException(errMsg); } } - + public String getText(Map<String, Object> context) { String text = this.textExdr.expandString(context); StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -749,15 +749,15 @@ } return text; } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } - + public String rawString() { return "<label id=\"" + this.idExdr.getOriginal() + "\" style=\"" + this.styleExdr.getOriginal() + "\" text=\"" + this.textExdr.getOriginal() + "\"/>"; } @@ -768,7 +768,7 @@ protected FlexibleStringExpander locationExdr; protected FlexibleStringExpander shareScopeExdr; protected ModelForm modelForm = null; - + public Form(ModelScreen modelScreen, Element formElement) { super(modelScreen, formElement); @@ -785,7 +785,7 @@ } ((MapStack) context).push(); } - + // try finding the formStringRenderer by name in the context in case one was prepared and put there FormStringRenderer formStringRenderer = (FormStringRenderer) context.get("formStringRenderer"); // if there was no formStringRenderer put in place, now try finding the request/response in the context and creating a new one @@ -800,7 +800,7 @@ if (formStringRenderer == null) { throw new IllegalArgumentException("Could not find a formStringRenderer in the context, and could not find HTTP request/response objects need to create one."); } - + ModelForm modelForm = getModelForm(context); //Debug.logInfo("before renderFormString, context:" + context, module); try { @@ -815,7 +815,7 @@ ((MapStack) context).pop(); } } - + public ModelForm getModelForm(Map<String, Object> context) { ModelForm modelForm = null; String name = this.getName(context); @@ -829,15 +829,15 @@ } return modelForm; } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } - + public boolean shareScope(Map<String, Object> context) { String shareScopeString = this.shareScopeExdr.expandString(context); // defaults to false, so anything but true is false @@ -853,7 +853,7 @@ protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; protected FlexibleStringExpander shareScopeExdr; - + public Tree(ModelScreen modelScreen, Element treeElement) { super(modelScreen, treeElement); @@ -870,7 +870,7 @@ } ((MapStack) context).push(); } - + String name = this.getName(context); String location = this.getLocation(context); ModelTree modelTree = null; @@ -889,7 +889,7 @@ Debug.logError(e, errMsg, module); throw new RuntimeException(errMsg); } - + // try finding the treeStringRenderer by name in the context in case one was prepared and put there TreeStringRenderer treeStringRenderer = (TreeStringRenderer) context.get("treeStringRenderer"); // if there was no treeStringRenderer put in place, now try finding the request/response in the context and creating a new one @@ -897,17 +897,17 @@ treeStringRenderer = new HtmlTreeRenderer(); /* String renderClassStyle = modelTree.getRenderStyle(); - if (UtilValidate.isNotEmpty(renderClassStyle) && renderClassStyle.equals("simple")) + if (UtilValidate.isNotEmpty(renderClassStyle) && renderClassStyle.equals("simple")) treeStringRenderer = new HtmlTreeRenderer(); else treeStringRenderer = new HtmlTreeExpandCollapseRenderer(); - */ + */ } // still null, throw an error if (treeStringRenderer == null) { throw new IllegalArgumentException("Could not find a treeStringRenderer in the context, and could not find HTTP request/response objects need to create one."); } - + StringBuffer renderBuffer = new StringBuffer(); modelTree.renderTreeString(renderBuffer, context, treeStringRenderer); try { @@ -922,15 +922,15 @@ ((MapStack) context).pop(); } } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } - + public boolean shareScope(Map<String, Object> context) { String shareScopeString = this.shareScopeExdr.expandString(context); // defaults to false, so anything but true is false @@ -944,7 +944,7 @@ public static class PlatformSpecific extends ModelScreenWidget { protected Map<String, ModelScreenWidget> subWidgets; - + public PlatformSpecific(ModelScreen modelScreen, Element platformSpecificElement) { super(modelScreen, platformSpecificElement); subWidgets = new HashMap<String, ModelScreenWidget>(); @@ -997,7 +997,7 @@ } public static class Content extends ModelScreenWidget { - + protected FlexibleStringExpander contentId; protected FlexibleStringExpander editRequest; protected FlexibleStringExpander editContainerStyle; @@ -1007,7 +1007,7 @@ protected String width; protected String height; protected String border; - + public Content(ModelScreen modelScreen, Element subContentElement) { super(modelScreen, subContentElement); @@ -1067,13 +1067,13 @@ dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", expandedDataResourceId)); this.dataResourceId = FlexibleStringExpander.getInstance(expandedDataResourceId); } - + String mimeTypeId = null; if (dataResource != null) { mimeTypeId = dataResource.getString("mimeTypeId"); } - - if (UtilValidate.isNotEmpty(mimeTypeId) + + if (UtilValidate.isNotEmpty(mimeTypeId) && ((mimeTypeId.indexOf("application") >= 0) || (mimeTypeId.indexOf("image")) >= 0) ) { screenStringRenderer.renderContentFrame(writer, context, this); } else { @@ -1093,44 +1093,44 @@ } } - + public String getContentId(Map<String, Object> context) { return this.contentId.expandString(context); } - + public String getDataResourceId(Map<String, Object> context) { return this.dataResourceId.expandString(context); } - + public String getEditRequest(Map<String, Object> context) { return this.editRequest.expandString(context); } - + public String getEditContainerStyle(Map<String, Object> context) { return this.editContainerStyle.expandString(context); } - + public String getEnableEditName(Map<String, Object> context) { return this.enableEditName.expandString(context); } - + public boolean xmlEscape() { return this.xmlEscape; } - + public String rawString() { // may want to expand this a bit more return "<content content-id=\"" + this.contentId.getOriginal() + "\" xml-escape=\"" + this.xmlEscape + "\"/>"; } - + public String getWidth() { return this.width; } - + public String getHeight() { return this.height; } - + public String getBorder() { return this.border; } @@ -1143,7 +1143,7 @@ protected FlexibleStringExpander editContainerStyle; protected FlexibleStringExpander enableEditName; protected boolean xmlEscape = false; - + public SubContent(ModelScreen modelScreen, Element subContentElement) { super(modelScreen, subContentElement); @@ -1170,27 +1170,27 @@ throw new RuntimeException(errMsg); } } - + public String getContentId(Map<String, Object> context) { return this.contentId.expandString(context); } - + public String getMapKey(Map<String, Object> context) { return this.mapKey.expandString(context); } - + public String getEditRequest(Map<String, Object> context) { return this.editRequest.expandString(context); } - + public String getEditContainerStyle(Map<String, Object> context) { return this.editContainerStyle.expandString(context); } - + public String getEnableEditName(Map<String, Object> context) { return this.enableEditName.expandString(context); } - + public boolean xmlEscape() { return this.xmlEscape; } @@ -1204,7 +1204,7 @@ public static class Menu extends ModelScreenWidget { protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; - + public Menu(ModelScreen modelScreen, Element menuElement) { super(modelScreen, menuElement); @@ -1235,11 +1235,11 @@ throw new IllegalArgumentException("Could not find a menuStringRenderer in the context, and could not find HTTP request/response objects need to create one."); } } - + ModelMenu modelMenu = getModelMenu(context); modelMenu.renderMenuString(writer, context, menuStringRenderer); } - + public ModelMenu getModelMenu(Map<String, Object> context) { String name = this.getName(context); String location = this.getLocation(context); @@ -1257,7 +1257,7 @@ public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } @@ -1266,7 +1266,7 @@ return "<include-menu name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\"/>"; } } - + public static class Link extends ModelScreenWidget { protected FlexibleStringExpander textExdr; protected FlexibleStringExpander idExdr; @@ -1282,7 +1282,7 @@ protected boolean encode = false; protected String linkType; protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance(); - + public Link(ModelScreen modelScreen, Element linkElement) { super(modelScreen, linkElement); @@ -1302,7 +1302,7 @@ if (imageElement != null) { this.image = new Image(modelScreen, imageElement); } - + this.linkType = linkElement.getAttribute("link-type"); List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter"); for (Element parameterElement: parameterElementList) { @@ -1319,7 +1319,7 @@ throw new RuntimeException(errMsg); } } - + public String getText(Map<String, Object> context) { String text = this.textExdr.expandString(context); StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -1328,15 +1328,15 @@ } return text; } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } - + public String getTarget(Map<String, Object> context) { Map<String, Object> expanderContext = context; StringUtil.SimpleEncoder simpleEncoder = context == null ? null : (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -1345,35 +1345,35 @@ } return this.targetExdr.expandString(expanderContext); } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getTargetWindow(Map<String, Object> context) { return this.targetWindowExdr.expandString(context); } - + public String getUrlMode() { return this.urlMode; } - + public String getPrefix(Map<String, Object> context) { return this.prefixExdr.expandString(context); } - + public boolean getFullPath() { return this.fullPath; } - + public boolean getSecure() { return this.secure; } - + public boolean getEncode() { return this.encode; } - + public Image getImage() { return this.image; } @@ -1381,7 +1381,7 @@ public String getLinkType() { return this.linkType; } - + public List<WidgetWorker.Parameter> getParameterList() { return this.parameterList; } @@ -1462,7 +1462,7 @@ setId(imageElement.getAttribute("id")); setStyle(imageElement.getAttribute("style")); setWidth(imageElement.getAttribute("width")); - setHeight(imageElement.getAttribute("height")); + setHeight(imageElement.getAttribute("height")); setBorder(imageElement.getAttribute("border")); setAlt(imageElement.getAttribute("alt")); setUrlMode(UtilFormatOut.checkEmpty(imageElement.getAttribute("url-mode"), "content")); @@ -1477,15 +1477,15 @@ throw new RuntimeException(errMsg); } } - + public String getSrc(Map<String, Object> context) { return this.srcExdr.expandString(context); } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } @@ -1501,15 +1501,15 @@ public String getBorder(Map<String, Object> context) { return this.borderExdr.expandString(context); } - + public String getAlt(Map<String, Object> context) { return this.alt.expandString(context); } - + public String getUrlMode() { return this.urlMode; } - + public void setSrc(String val) { String textAttr = UtilFormatOut.checkNull(val); this.srcExdr = FlexibleStringExpander.getInstance(textAttr); @@ -1533,7 +1533,7 @@ String altAttr = UtilFormatOut.checkNull(val); this.alt = FlexibleStringExpander.getInstance(altAttr); } - + public void setUrlMode(String val) { if (UtilValidate.isEmpty(val)) { this.urlMode = "content"; Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -44,7 +44,7 @@ * Widget Library - Screen factory class */ public class ScreenFactory { - + public static final String module = ScreenFactory.class.getName(); public static final UtilCache<String, Map<String, ModelScreen>> screenLocationCache = new UtilCache<String, Map<String, ModelScreen>>("widget.screen.locationResource", 0, 0, false); @@ -60,7 +60,7 @@ } return true; } - + public static String getResourceNameFromCombined(String combinedName) { // split out the name on the last "#" int numSignIndex = combinedName.lastIndexOf("#"); @@ -73,7 +73,7 @@ String resourceName = combinedName.substring(0, numSignIndex); return resourceName; } - + public static String getScreenNameFromCombined(String combinedName) { // split out the name on the last "#" int numSignIndex = combinedName.lastIndexOf("#"); @@ -86,15 +86,15 @@ String screenName = combinedName.substring(numSignIndex + 1); return screenName; } - - public static ModelScreen getScreenFromLocation(String combinedName) + + public static ModelScreen getScreenFromLocation(String combinedName) throws IOException, SAXException, ParserConfigurationException { String resourceName = getResourceNameFromCombined(combinedName); String screenName = getScreenNameFromCombined(combinedName); return getScreenFromLocation(resourceName, screenName); } - - public static ModelScreen getScreenFromLocation(String resourceName, String screenName) + + public static ModelScreen getScreenFromLocation(String resourceName, String screenName) throws IOException, SAXException, ParserConfigurationException { Map<String, ModelScreen> modelScreenMap = getScreensFromLocation(resourceName); ModelScreen modelScreen = modelScreenMap.get(screenName); @@ -104,7 +104,7 @@ return modelScreen; } - public static Map<String, ModelScreen> getScreensFromLocation(String resourceName) + public static Map<String, ModelScreen> getScreensFromLocation(String resourceName) throws IOException, SAXException, ParserConfigurationException { Map<String, ModelScreen> modelScreenMap = screenLocationCache.get(resourceName); if (modelScreenMap == null) { @@ -116,7 +116,7 @@ if (loader == null) { loader = ScreenFactory.class.getClassLoader(); } - + URL screenFileUrl = null; screenFileUrl = FlexibleLocation.resolveLocation(resourceName, loader); if (screenFileUrl == null) { @@ -130,26 +130,26 @@ } } } - + if (modelScreenMap == null) { throw new IllegalArgumentException("Could not find screen file with name [" + resourceName + "]"); } return modelScreenMap; } - public static ModelScreen getScreenFromWebappContext(String resourceName, String screenName, HttpServletRequest request) + public static ModelScreen getScreenFromWebappContext(String resourceName, String screenName, HttpServletRequest request) throws IOException, SAXException, ParserConfigurationException { String webappName = UtilHttp.getApplicationName(request); String cacheKey = webappName + "::" + resourceName; - - + + Map<String, ModelScreen> modelScreenMap = screenWebappCache.get(cacheKey); if (modelScreenMap == null) { synchronized (ScreenFactory.class) { modelScreenMap = screenWebappCache.get(cacheKey); if (modelScreenMap == null) { ServletContext servletContext = (ServletContext) request.getAttribute("servletContext"); - + URL screenFileUrl = servletContext.getResource(resourceName); Document screenFileDoc = UtilXml.readXmlDocument(screenFileUrl, true); modelScreenMap = readScreenDocument(screenFileDoc, resourceName); @@ -157,14 +157,14 @@ } } } - + ModelScreen modelScreen = (ModelScreen) modelScreenMap.get(screenName); if (modelScreen == null) { throw new IllegalArgumentException("Could not find screen with name [" + screenName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]"); } return modelScreen; } - + public static Map<String, ModelScreen> readScreenDocument(Document screenFileDoc, String sourceLocation) { Map<String, ModelScreen> modelScreenMap = FastMap.newInstance(); if (screenFileDoc != null) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderException.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderException.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderException.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -35,7 +35,7 @@ } public ScreenRenderException(Throwable nested) { - super(nested); + super(nested); } public ScreenRenderException(String str) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -66,21 +66,21 @@ public class ScreenRenderer { public static final String module = ScreenRenderer.class.getName(); - + protected Appendable writer; protected MapStack<String> context; protected ScreenStringRenderer screenStringRenderer; - + public ScreenRenderer(Appendable writer, MapStack<String> 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 pound sign ("#"). This is the same format that is used in the view-map elements on the controller.xml file. * @throws IOException * @throws SAXException @@ -95,7 +95,7 @@ /** * 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 @@ -109,7 +109,7 @@ // then try to get an already built screen output from the cache: // 1) if we find it then we get it and attach it to the passed in writer // 2) if we can't find one, we create a new StringWriter, - // and pass it to the renderScreenString; + // and pass it to the renderScreenString; // then we wrap its content and put it in the cache; // and we attach it to the passed in writer WidgetContextCacheKey wcck = new WidgetContextCacheKey(context); @@ -158,11 +158,11 @@ context.put("userLogin", userLogin); context.put("nowTimestamp", UtilDateTime.nowTimestamp()); } - + /** * This method populates the context for this ScreenRenderer based on the HTTP Request and Response 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 @@ -176,12 +176,12 @@ // attribute names to skip for session and application attributes; these are all handled as special cases, duplicating results and causing undesired messages Set<String> attrNamesToSkip = UtilMisc.toSet("delegator", "dispatcher", "security", "webSiteId"); - Map<String, Object> parameterMap = UtilHttp.getCombinedMap(request, attrNamesToSkip); + Map<String, Object> parameterMap = UtilHttp.getCombinedMap(request, attrNamesToSkip); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); - + populateBasicContext(context, screens, parameterMap, (GenericDelegator) request.getAttribute("delegator"), - (LocalDispatcher) request.getAttribute("dispatcher"), (Security) request.getAttribute("security"), + (LocalDispatcher) request.getAttribute("dispatcher"), (Security) request.getAttribute("security"), UtilHttp.getLocale(request), userLogin); context.put("autoUserLogin", session.getAttribute("autoUserLogin")); @@ -193,7 +193,7 @@ // set up the user's time zone context.put("timeZone", UtilHttp.getTimeZone(request)); - + // ========== setup values that are specific to OFBiz webapps context.put("request", request); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenTextViewHandler.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -38,7 +38,7 @@ import org.ofbiz.widget.text.TextScreenRenderer; public class ScreenTextViewHandler extends AbstractViewHandler { - + public static final String module = ScreenTextViewHandler.class.getName(); protected ServletContext servletContext = null; Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenWidgetViewHandler.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -49,17 +49,17 @@ public class ScreenWidgetViewHandler extends AbstractViewHandler { public static final String module = ScreenWidgetViewHandler.class.getName(); - + protected ServletContext servletContext = null; protected HtmlScreenRenderer htmlScreenRenderer = new HtmlScreenRenderer(); - + /** * @see org.ofbiz.webapp.view.ViewHandler#init(javax.servlet.ServletContext) */ public void init(ServletContext context) throws ViewHandlerException { this.servletContext = context; } - + /** * @see org.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @@ -88,7 +88,7 @@ // to speed up output. writer = new StandardCompress().getWriter(writer, null); } - + ScreenRenderer screens = new ScreenRenderer(writer, null, htmlScreenRenderer); screens.populateContextForRequest(request, response, servletContext); // this is the object used to render forms from their definitions Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenXmlViewHandler.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -37,9 +37,9 @@ import org.ofbiz.widget.xml.XmlFormRenderer; public class ScreenXmlViewHandler extends ScreenWidgetViewHandler { - + public static final String module = ScreenXmlViewHandler.class.getName(); - + public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException { Writer writer = null; try { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -58,7 +58,7 @@ public class TextFormRenderer implements FormStringRenderer { public static final String module = TextFormRenderer.class.getName(); - + HttpServletRequest request; HttpServletResponse response; @@ -290,11 +290,11 @@ public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) { // TODO } - + public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) { // TODO } - + public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) { } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java?rev=757077&r1=757076&r2=757077&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java Sat Mar 21 23:24:58 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
Free forum by Nabble | Edit this page |