Author: adrianc
Date: Wed Apr 15 17:44:47 2009 New Revision: 765284 URL: http://svn.apache.org/viewvc?rev=765284&view=rev Log: Added "NewList" and "NewMap" options to the <set> element type attribute. Now screen widgets and mini-language support the creation of empty Lists and Maps. Usage: <set field="theList" type="NewList"/> <set field="theMap" type="NewMap"/> Modified: ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java ofbiz/trunk/framework/widget/dtd/widget-form.xsd ofbiz/trunk/framework/widget/dtd/widget-menu.xsd ofbiz/trunk/framework/widget/dtd/widget-screen.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java Modified: ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd (original) +++ ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd Wed Apr 15 17:44:47 2009 @@ -1358,7 +1358,7 @@ <xs:attribute name="type"> <xs:annotation> <xs:documentation> - Type to convert to. + Type to convert to. NewList will create a new List, NewMap will create a new Map. </xs:documentation> </xs:annotation> <xs:simpleType> @@ -1376,6 +1376,8 @@ <xs:enumeration value="Timestamp"/> <xs:enumeration value="Boolean"/> <xs:enumeration value="Object"/> + <xs:enumeration value="NewList"/> + <xs:enumeration value="NewMap"/> </xs:restriction> </xs:simpleType> </xs:attribute> Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java Wed Apr 15 17:44:47 2009 @@ -21,6 +21,9 @@ import java.util.Locale; import java.util.TimeZone; +import javolution.util.FastList; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; @@ -96,15 +99,21 @@ } if (UtilValidate.isNotEmpty(this.type)) { - try { - newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, methodContext.getTimeZone(), methodContext.getLocale(), true); - } catch (GeneralException e) { - String errMsg = "Could not convert field value for the field: [" + this.field.toString() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - methodContext.setErrorReturn(errMsg, simpleMethod); - return false; + if ("NewMap".equals(this.type)) { + newValue = FastMap.newInstance(); + } else if ("NewList".equals(this.type)) { + newValue = FastList.newInstance(); + } else { + try { + newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, methodContext.getTimeZone(), methodContext.getLocale(), true); + } catch (GeneralException e) { + String errMsg = "Could not convert field value for the field: [" + this.field.toString() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); + Debug.logError(e, errMsg, module); + methodContext.setErrorReturn(errMsg, simpleMethod); + return false; + } + } } - } if (Debug.verboseOn()) Debug.logVerbose("In screen setting field [" + this.field.toString() + "] to value: " + newValue, module); this.field.put(methodContext, newValue); Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Wed Apr 15 17:44:47 2009 @@ -1528,6 +1528,8 @@ <xs:enumeration value="Timestamp"/> <xs:enumeration value="Boolean"/> <xs:enumeration value="Object"/> + <xs:enumeration value="NewList"/> + <xs:enumeration value="NewMap"/> </xs:restriction> </xs:simpleType> </xs:attribute> Modified: ofbiz/trunk/framework/widget/dtd/widget-menu.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-menu.xsd?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-menu.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-menu.xsd Wed Apr 15 17:44:47 2009 @@ -310,6 +310,8 @@ <xs:enumeration value="Timestamp"/> <xs:enumeration value="Boolean"/> <xs:enumeration value="Object"/> + <xs:enumeration value="NewList"/> + <xs:enumeration value="NewMap"/> </xs:restriction> </xs:simpleType> </xs:attribute> Modified: ofbiz/trunk/framework/widget/dtd/widget-screen.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-screen.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-screen.xsd Wed Apr 15 17:44:47 2009 @@ -343,6 +343,8 @@ <xs:enumeration value="Timestamp"/> <xs:enumeration value="Boolean"/> <xs:enumeration value="Object"/> + <xs:enumeration value="NewList"/> + <xs:enumeration value="NewMap"/> </xs:restriction> </xs:simpleType> </xs:attribute> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Wed Apr 15 17:44:47 2009 @@ -28,6 +28,9 @@ import java.util.TimeZone; import java.util.regex.PatternSyntaxException; +import javolution.util.FastList; +import javolution.util.FastMap; + import org.ofbiz.base.util.BshUtil; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; @@ -141,14 +144,19 @@ } if (UtilValidate.isNotEmpty(this.type)) { - try { - newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); - } catch (GeneralException e) { - String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - throw new IllegalArgumentException(errMsg); + if ("NewMap".equals(this.type)) { + newValue = FastMap.newInstance(); + } else if ("NewList".equals(this.type)) { + newValue = FastList.newInstance(); + } else { + try { + newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); + } catch (GeneralException e) { + String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } } - } if (Debug.verboseOn()) Debug.logVerbose("In screen setting field [" + this.field.getOriginalName() + "] to value: " + newValue, module); this.field.put(context, newValue); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java Wed Apr 15 17:44:47 2009 @@ -25,6 +25,7 @@ import java.util.Map; import java.util.TimeZone; +import javolution.util.FastList; import javolution.util.FastMap; import org.ofbiz.base.util.BshUtil; @@ -184,14 +185,19 @@ } if (UtilValidate.isNotEmpty(this.type)) { - try { - newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); - } catch (GeneralException e) { - String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - throw new IllegalArgumentException(errMsg); + if ("NewMap".equals(this.type)) { + newValue = FastMap.newInstance(); + } else if ("NewList".equals(this.type)) { + newValue = FastList.newInstance(); + } else { + try { + newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); + } catch (GeneralException e) { + String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } } - } if (this.toScope != null && this.toScope.equals("user")) { String originalName = this.field.getOriginalName(); 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=765284&r1=765283&r2=765284&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 Wed Apr 15 17:44:47 2009 @@ -181,12 +181,18 @@ } if (UtilValidate.isNotEmpty(this.type)) { - try { - newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); - } catch (GeneralException e) { - String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - throw new IllegalArgumentException(errMsg); + if ("NewMap".equals(this.type)) { + newValue = FastMap.newInstance(); + } else if ("NewList".equals(this.type)) { + newValue = FastList.newInstance(); + } else { + try { + newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); + } catch (GeneralException e) { + String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java?rev=765284&r1=765283&r2=765284&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java Wed Apr 15 17:44:47 2009 @@ -25,6 +25,7 @@ import java.util.TimeZone; import java.util.regex.PatternSyntaxException; +import javolution.util.FastList; import javolution.util.FastMap; import org.ofbiz.base.util.BshUtil; @@ -139,14 +140,19 @@ newValue = this.valueExdr.expandString(context); } if (UtilValidate.isNotEmpty(this.type)) { - try { - newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); - } catch (GeneralException e) { - String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); - Debug.logError(e, errMsg, module); - throw new IllegalArgumentException(errMsg); + if ("NewMap".equals(this.type)) { + newValue = FastMap.newInstance(); + } else if ("NewList".equals(this.type)) { + newValue = FastList.newInstance(); + } else { + try { + newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); + } catch (GeneralException e) { + String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); + Debug.logError(e, errMsg, module); + throw new IllegalArgumentException(errMsg); + } } - } this.field.put(context, newValue); |
Free forum by Nabble | Edit this page |