Jacques,

Why do you say that the description-field-name attribute is "useless in the 
autocomplete context"?

It looks like in his initial implementation you chose to determine the related 
field (the "description" field) based on how the fields are named. In other 
word if the autocomplete ended with "Id", like partyId, if would remove the 
"Id" and add "Name" and look for a field with that name to put the description 
in.

What it sounds like you are proposing is to do is to determine the related 
field to populate by looking for the next field in the form, instead of using 
the description-field-name attribute like the lookup does.

In order to be consistent with the lookup window, and allow the fields to be 
named anything, the autocomplete stuff should use the existing lookup -> 
description-field-name attribute to determine the related field to populate 
instead of doing so based on the name by swapping out suffixes. Doing anything 
else seems like a hack to me.

So, back to the original question, why not use the value of the 
description-field-name attribute as the related field to populate with the 
description?

-David


On Sep 7, 2010, at 2:59 PM, Jacques Le Roux wrote:

> Of course when I began to work on this I tried to use description-field-name 
> but was unable to access it and discovered it was
> useless in the autocomplete context. BTW using jQuery for this should be far 
> easier as the
> http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ is now part 
> of jQuery.ui...
> 
> Jacques
> 
> From: <[email protected]>
>> Author: jleroux
>> Date: Tue Sep  7 19:55:49 2010
>> New Revision: 993508
>> 
>> URL: http://svn.apache.org/viewvc?rev=993508&view=rev
>> Log:
>> Introduces a very simple mean to set a dependent Id field when using a Name 
>> field as a lookup (the fields must have the same
>> prefix, eg: partyName, partyId).
>> It uses the description (Id) shown with the Name. Hence the Lookup screen 
>> must be set in order to show a description in the
>> autocomplete part.
>> It seems this is not always easy notably when you need to show at least 2 
>> parts for the Name (eg Person).
>> At least it easy to set and it works well for simples case for now (eg 
>> PartyGroup)
>> 
>> I did not find another way since Ajax.Autocompleter can't update another 
>> field.
>> The alternative would be navigation to the next hidden field, at least it 
>> would avoid the mandatory Id/Name pair.
>> But it's more difficult to demonstrate in Example component
>> 
>> Modified:
>>   ofbiz/trunk/framework/images/webapp/images/selectall.js
>> 
>> Modified: ofbiz/trunk/framework/images/webapp/images/selectall.js
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/selectall.js?rev=993508&r1=993507&r2=993508&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/images/webapp/images/selectall.js (original)
>> +++ ofbiz/trunk/framework/images/webapp/images/selectall.js Tue Sep  7 
>> 19:55:49 2010
>> @@ -232,6 +232,7 @@ function confirmActionFormLink(msg, form
>>  * @param target The URL to call to update the HTML container
>>  * @param targetParams The URL parameters
>> */
>> +
>> function ajaxUpdateArea(areaId, target, targetParams) {
>>    waitSpinnerShow();
>>    new Ajax.Updater(areaId, target, {parameters: targetParams, evalScripts: 
>> true,
>> @@ -377,7 +378,23 @@ function setLookDescription(textFieldId,
>>    if (description) {
>>        var start = description.lastIndexOf(' [');
>>        if (start != -1) {
>> +            // To allow to set a dependent Id field when using a Name field 
>> as a lookup (the fields must have the same prefix,
>> eg: partyName, partyId)
>> +            // It uses the description (Id) shown with the Name. Hence the 
>> Lookup screen must be set in order to show a
>> description in the autocomplete part.
>> +            // It seems this is not always easy notably when you need to 
>> show at least 2 parts for the Name (eg Person).
>> +            // At least it easy to set and it works well for simples case 
>> for now (eg PartyGroup)
>> +            var dependentId = textFieldId.replace(/Name/, "Id"); // Raw but 
>> ok for now, needs safe navigation...
>> +            // I did not find another way since Ajax.Autocompleter can't 
>> update another field
>> +            // The alternative would be navigation to the next hidden 
>> field, at least it would avoid the mandatory Id/Name pair
>> +            // But it's more difficult to demonstrate in Example component
>> +            // dependentId = 
>> (textFieldId.next('div').down('input[type=hidden]');
>> +            $(dependentId).clear();
>> +            var dependentIdValue = (description.substring(start + 1, 
>> description.length).replace(/\[/g, "")).replace(/\]/g, "");
>> +            if ($(dependentId)) {
>> +                $(dependentId).value = dependentIdValue;
>> +            }
>> +
>>            description = description.substring(0, start);
>> +            $(dependentId).value = description;
>>        }
>>    }
>>    var lookupWrapperEl = $(textFieldId).up('.field-lookup');
>> 
>> 
> 
> 

Reply via email to