You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sa...@apache.org on 2012/08/28 08:40:16 UTC

svn commit: r1377987 - /ofbiz/branches/release11.04/framework/images/webapp/images/fieldlookup.js

Author: sascharodekamp
Date: Tue Aug 28 06:40:16 2012
New Revision: 1377987

URL: http://svn.apache.org/viewvc?rev=1377987&view=rev
Log:
Lookup Form not working with Arabic characters (https://issues.apache.org/jira/browse/OFBIZ-4915): A patch from Taher Alkhateeb: Any field in a form that uses the <lookup target-form-name="WhateverForm"/> would not return results when searching in Arabic. I suspect the main offender is javascript/jQuery when parsing user input.

Modified:
    ofbiz/branches/release11.04/framework/images/webapp/images/fieldlookup.js

Modified: ofbiz/branches/release11.04/framework/images/webapp/images/fieldlookup.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/images/webapp/images/fieldlookup.js?rev=1377987&r1=1377986&r2=1377987&view=diff
==============================================================================
--- ofbiz/branches/release11.04/framework/images/webapp/images/fieldlookup.js (original)
+++ ofbiz/branches/release11.04/framework/images/webapp/images/fieldlookup.js Tue Aug 28 06:40:16 2012
@@ -87,7 +87,7 @@ function fieldLookup1(obj_target, args, 
     // passing methods
     this.popup = lookup_popup1;
     this.popup2 = lookup_popup2;
-    
+
     // validate input parameters
     if (! obj_target) return lookup_error("Error calling the field lookup: no target control specified");
     if (obj_target.value == null) return lookup_error("Error calling the field lookup: parameter specified is not valid target control");
@@ -108,7 +108,7 @@ function fieldLookup2(obj_target, obj_ta
     if (! obj_target2) return lookup_error("Error calling the field lookup: no target2 control specified");
     if (obj_target2.value == null) return lookup_error("Error calling the field lookup: parameter specified is not valid target2 control");
     target2 = obj_target2;
-    
+
 }
 
 function lookup_popup1(view_name, form_name, viewWidth, viewheight) {
@@ -157,7 +157,7 @@ function initiallyCollapse() {
             if (childElements[j].className == 'expanded' || childElements[j].className == 'collapsed') {
                 break;
             }
-        }        
+        }
         var childEle = childElements[j].firstChild;
         CollapsePanel(childEle, 'lec' + COLLAPSE);
         break;
@@ -181,7 +181,7 @@ function initiallyCollapseDelayed() {
 * Fieldlookup Class & Methods
 *************************************/
 function ConstructLookup(requestUrl, inputFieldId, dialogTarget, dialogOptionalTarget, formName, width, height, position, modal, ajaxUrl, showDescription, presentation, defaultMinLength, args) {
-    
+
     // add the presentation attribute to the request url to let the request know which decorator should be loaded
     if(!presentation) {
       var presentation = "layer"
@@ -214,7 +214,7 @@ function ConstructLookup(requestUrl, inp
         ajaxUrl = ajaxUrl.replace(ajaxUrl.substring(0, ajaxUrl.indexOf(",")), newInputBoxId);
         new ajaxAutoCompleter(ajaxUrl, showDescription, defaultMinLength, formName);
     }
-    
+
     var positioning = null;
     if (position == "topleft") {
         positioning = ['left', 'top'];
@@ -231,7 +231,7 @@ function ConstructLookup(requestUrl, inp
     } else {
         positioning = ['left', 'top'];
     }
-    
+
     var lookupFormAction = null;
     function lookup_onKeyEnter(event) {
         if (event.which == 13) {
@@ -239,7 +239,7 @@ function ConstructLookup(requestUrl, inp
             return false;
         }
     }
-    
+
     // Lookup Configuration
     var dialogOpts = {
         modal: (modal == "true") ? true : false,
@@ -272,7 +272,7 @@ function ConstructLookup(requestUrl, inp
                 },
                 success: function(data) {
                     jQuery("#" + lookupId).html(data);
-                    
+
                     lookupFormAction = jQuery("#" + lookupId + " form:first").attr("action");
                     modifySubmitButton(lookupId);
                     jQuery("#" + lookupId).bind("keypress", lookup_onKeyEnter);
@@ -286,7 +286,7 @@ function ConstructLookup(requestUrl, inp
                         prevLookup = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).lookupId;
                     }
                     identifyLookup(lookupId);
-                    
+
                     if (prevLookup) {
                         GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).prevLookup = prevLookup;
                     }
@@ -316,11 +316,11 @@ function ConstructLookup(requestUrl, inp
         }
 
     };
-    
+
     // init Dialog and register
     // create an object with all Lookup Informationes that are needed
     var dialogRef = jQuery("#" + lookupId).dialog(dialogOpts);
-    
+
     //setting up global variabels, for external access
     this.inputBoxId = inputBox.id;
     this.lookupId = lookupId;
@@ -334,7 +334,7 @@ function ConstructLookup(requestUrl, inp
     this.dialogRef = dialogRef;
     //write external settings in global window manager
     GLOBAL_LOOKUP_REF.setReference(lookupId, this);
-    
+
     // bind click Event to Dialog button
     jQuery("#" + lookupId + "_button").click(
         function (){
@@ -350,7 +350,7 @@ function ConstructLookup(requestUrl, inp
     );
 
     // close the dialog when clicking outside the dialog area
-    jQuery(".ui-widget-overlay").live("click", function() {  
+    jQuery(".ui-widget-overlay").live("click", function() {
         if(!ACTIVATED_LOOKUP || lookupId==ACTIVATED_LOOKUP){
             jQuery("#" + lookupId).dialog("close");
         }
@@ -374,31 +374,31 @@ function FieldLookupCounter() {
         this.refArr[""+ key + ""] = ref;
         return this.refArr[key];
     };
-    
+
     this.getReference = function (key) {
         // when key does not exist return null?
         return this.refArr[key] != null ? this.refArr[key] : null;
     };
-    
+
     this.getLastReference = function () {
         return (this.countFields() -1) + "_lookupId";
     }
-    
+
     this.createNextKey = function () {
-        return this.countFields() + "_lookupId";       
+        return this.countFields() + "_lookupId";
     };
-    
+
     this.countFields = function () {
         var count = 0;
         jQuery.each(this.refArr, function (itm) {count++;});
         return count;
     };
-    
+
     this.removeReference = function (key) {
         // deletes the Array entry (doesn't effect the array length)
         delete this.refArr[key];
     };
-    
+
 };
 var GLOBAL_LOOKUP_REF = new FieldLookupCounter;
 
@@ -416,7 +416,7 @@ function isEmpty(value) {
 }
 
 function identifyLookup (newAl) {
-    if (ACTIVATED_LOOKUP != newAl) { 
+    if (ACTIVATED_LOOKUP != newAl) {
         ACTIVATED_LOOKUP = newAl;
     }
 }
@@ -646,6 +646,7 @@ function lookupFormAjaxRequest(formActio
     var screenletTitleBar= jQuery("#"+lookupId+" .screenlet-title-bar :visible:first");
     jQuery.ajax({
       url: formAction,
+      type: "POST",
       data: data,
       beforeSend: function(jqXHR, settings) {
         //Here we append the spinner to the lookup screenlet and it will shown till the ajax request is processed.
@@ -734,7 +735,7 @@ function set_duration_value (value) {
     }
     else {
         obj_caller.target = jQuery(obj_caller.targetW);
-    }    
+    }
     var target = obj_caller.target;
 
     write_value(value, target);
@@ -748,7 +749,7 @@ function set_value (value) {
     else {
         obj_caller.target = jQuery(obj_caller.targetW);
     }
-    
+
     var target = obj_caller.target;
     write_value(value, target);
 
@@ -761,14 +762,14 @@ function set_values (value, value2) {
         obj_caller.target2 = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).target2;
     }
     else {
-        obj_caller.target = jQuery(obj_caller.targetW);        
+        obj_caller.target = jQuery(obj_caller.targetW);
     }
     var target = obj_caller.target;
     var target2 = obj_caller.target2;
     write_value(value, target);
     write_value(value2, target2)
     if (SHOW_DESCRIPTION) setLookDescription(target.attr("id"), value + " " + value2, "", "");
-    
+
     closeLookup();
 }
 
@@ -777,7 +778,7 @@ function write_value (value, target) {
         setSourceColor(target);
         target.val(value);
         target.trigger("lookup:changed");
-    }    
+    }
 }
 
 function set_multivalues(value) {
@@ -790,7 +791,7 @@ function set_multivalues(value) {
 
     var thisForm = obj_caller.target.form;
     var evalString = "";
-    
+
     if (arguments.length > 2) {
         for (var i = 1; i < arguments.length; i = i + 2) {
             evalString = "setSourceColor(thisForm." + arguments[i] + ")";
@@ -812,7 +813,7 @@ function closeLookup() {
     }
 }
 
-//load description for lookup fields 
+//load description for lookup fields
 var lookupDescriptionLoaded = function(fieldId, url, params, formName) {
   this.init(fieldId, url, params, formName);
 }
@@ -834,7 +835,7 @@ lookupDescriptionLoaded.prototype.update
   var fieldSerialized = jQuery("input[name=" + fieldName + "]", jQuery("form[name=" + this.formName + "]")).serialize();
   this.allParams = this.params + '&' + fieldSerialized + '&' + 'searchType=EQUALS';
   _fieldId = this.fieldId;
-  
+
   jQuery.ajax({
     url: this.url,
     type: "POST",
@@ -849,9 +850,9 @@ lookupDescriptionLoaded.prototype.update
   });
   }
 }
-    
+
 if(typeof String.prototype.trim !== 'function') { // Needed because IE8 does not implement trim yet
   String.prototype.trim = function() {
-    return this.replace(/^\s+|\s+$/g, ''); 
+    return this.replace(/^\s+|\s+$/g, '');
   }
 }
\ No newline at end of file