Author: jleroux
Date: Sat Jul 12 05:19:41 2008 New Revision: 676162 URL: http://svn.apache.org/viewvc?rev=676162&view=rev Log: Fix "Problems in virtual product's detail page if productFeatureTypeId contain non alfa characters." (https://issues.apache.org/jira/browse/OFBIZ-230) - OFBIZ-230 Modified: ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml ofbiz/trunk/applications/product/script/org/ofbiz/product/feature/ProductFeatureServices.xml ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java Modified: ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml?rev=676162&r1=676161&r2=676162&view=diff ============================================================================== --- ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml (original) +++ ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml Sat Jul 12 05:19:41 2008 @@ -36,4 +36,12 @@ <value xml:lang="en">USPS address validation requires either zip5 or city and state</value> <value xml:lang="th">USPS à¸à¹à¸à¸à¸à¸²à¸£à¸à¸µà¹à¸à¸¢à¸¹à¹ à¸à¹à¸²à¹à¸¡à¹ รหัสà¹à¸à¸£à¸©à¸à¸µà¸¢à¹ หรืภà¹à¸¡à¸·à¸à¸ à¹à¸¥à¸° รัà¸</value> </property> + <property key="ProductFeatureTypeIdMustContainsLettersAndDigits"> + <value xml:lang="en">The Product Feature TypeId must contains only letters and digits and must begin by a letter. Please re-enter</value> + <value xml:lang="fr">La réf. de type de caractéristique d'article ne doit contenit que des lettres et des chiffres et doit commencer par une lettre. Recommencez SVP</value> + </property> + <property key="ProductFeatureTypeIdMustNotBeResevedWord"> + <value xml:lang="en">The Product Feature TypeId must not be one of the reserved words, this is one of them. Please re-enter</value> + <value xml:lang="fr">La réf. de type de caractéristique d'article ne peut être un mot réservé, ce mot là en est un. Recommencez SVP</value> + </property> </resource> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/feature/ProductFeatureServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/feature/ProductFeatureServices.xml?rev=676162&r1=676161&r2=676162&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/feature/ProductFeatureServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/feature/ProductFeatureServices.xml Sat Jul 12 05:19:41 2008 @@ -276,6 +276,32 @@ <check-permission permission="CATALOG" action="_CREATE"><fail-message message="Security Error: to run createProductFeatureType you must have the CATALOG_CREATE or CATALOG_ADMIN permission"/></check-permission> <check-errors/> + <if> + <condition> + <not> + <if-regexp field-name="parameters.productFeatureTypeId" expr="^[a-zA-Z]+[0-9_]*$"></if-regexp> + </not> + </condition> + <then> + <add-error> + <fail-property resource="ProductErrorUiLabels" property="ProductFeatureTypeIdMustContainsLettersAndDigits"/> + </add-error> + </then> + </if> + <check-errors/> + + <if> + <condition> + <if-validate-method field-name="parameters.productFeatureTypeId" method="isJavaScriptReservedWord"></if-validate-method> + </condition> + <then> + <add-error> + <fail-property resource="ProductErrorUiLabels" property="ProductFeatureTypeIdMustNotBeResevedWord"/> + </add-error> + </then> + </if> + <check-errors/> + <make-value value-name="newEntity" entity-name="ProductFeatureType"/> <set-nonpk-fields map-name="parameters" value-name="newEntity"/> <set-pk-fields map-name="parameters" value-name="newEntity"/> Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java?rev=676162&r1=676161&r2=676162&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java Sat Jul 12 05:19:41 2008 @@ -604,7 +604,30 @@ // All characters are numbers or letters. return true; } - + + public static boolean isJavaScriptReservedWord(String s) { + String[] javaScriptReservedWord = {"abstract", "alert", "arguments", "Array", "blur", "boolean", "Boolean", "break", "byte", + "callee", "caller", "captureEventscase", "catch", "char", "class", "clearInterval", "clearTimeout", "close", "closed", + "confirm", "const", "constructor", "continue", "Date", "debugger", "default", "defaultStatusdelete", "do", "document", + "double", "else", "enum", "escape", "eval", "export", "extends", "false", "final", "finally", "find", "float", "for", + "focus", "frames", "function", "Function", "goto", "history", "home", "if", "implements", "import", "in", "Infinity", + "innerHeight", "innerWidth", "instanceof", "int", "interface", "isFinite", "isNaN", "java", "length", "location", + "locationbar", "long", "Math", "menubar", "moveBy", "moveTo", "name", "NaN", "native", "netscape", "new", "null", + "Number", "Object", "open", "opener", "outerHeight", "outerWidth", "package", "Packages", "pageXOffset", "pageYOffset", + "parent", "parseFloat", "parseInt", "personalbar", "print", "private", "prompt", "protected", "prototype", "public", + "RegExp", "releaseEventsresizeBy", "resizeTo", "return", "routeEvent", "scroll", "scrollbars", "scrollBy", "scrollTo", + "self", "setInterval", "setTimeout", "short", "static", "status", "statusbar", "stop", "String", "super", "switch", + "synchronized", "this", "throw", "throws", "toolbar", "top", "toString", "transient", "true", "try", "typeof", "unescape", + "unwatch", "valueOf", "var", "void", "watch", "while", "with", "window"}; + for (String reservedWord : javaScriptReservedWord) { + if (reservedWord.equals(s)) { + return true; + } + } + return false; + } + + /* ================== METHODS TO CHECK VARIOUS FIELDS. ==================== */ /** isSSN returns true if string s is a valid U.S. Social Security Number. Must be 9 digits. */ |
Free forum by Nabble | Edit this page |