[jira] Created: (OFBIZ-218) Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (OFBIZ-218) Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).

Nicolas Malin (Jira)
Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).
---------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: OFBIZ-218
                 URL: http://issues.apache.org/jira/browse/OFBIZ-218
             Project: OFBiz (The Open for Business Project)
          Issue Type: Bug
          Components: framework
            Reporter: Jacopo Cappellato
            Priority: Minor


If you open a lookup window and then in the lookup window's form there is a new lookup link, that link will load a new lookup screen inside the same popup windows: the system will try to assign the value you'll select there to one of the fields of the main window (instead of one of the fields of the first lookup form).

To reproduce this:

1) Accounting app
2) Find Payments
3) Choose a payment that still has an amount left to apply
4) Application tab
5) lookup from the invoices Id field
6) on that popup lookup from the "From Party Id" field on that screen to a lookup


--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (OFBIZ-218) Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).

Nicolas Malin (Jira)
     [ http://issues.apache.org/jira/browse/OFBIZ-218?page=all ]

Jacopo Cappellato updated OFBIZ-218:
------------------------------------

    Attachment: lookup.ftl

Romà Ferré Añaños reported this bug in the old Jira issue and included the attached patch with the following comment:

*************************************************************************************
We found that in a screen form with more than one popup field, the current mechanism fails to properly identify the field (in the main window) which was to receive the selected value.

In a typical scenario, only one of the fields would receive the result of any of the popups.

We inspected the javascript code in "framework/common/webcommon/includes/lookup.ftl" and found that the mechanism for locating the opener field depended on the URL parameter "id". This parameter is not properly passed on successive submits (or pages) in the popup, and it only takes the first submit on the "Lookup" button to lose the "id" parameter.

We have designed a solution for this bug which relies on cookies, so that we can remember the id between pages.

We rely upon typical javascript setCookie/getCookie functions.

Here is the main part of our solution:

        //let us prepare a regular expression which will alow us to extract the id parameter from the URL
        // => this is guaranteed to work the first time we open up the popup
        var re_id = new RegExp('id=(\\d+)');
        //We set num_id to -1 in case of "no match" to remember this condition later
        var num_id = (re_id.exec(String(window.location))
                ? new Number(RegExp.$1) : -1);
        //Now we want to obtain the obj_caller...
        var obj_caller;
        if(num_id!=-1){
//an id was passed in, let us remember it...
setCookie("__popupNumId__",num_id);
obj_caller = (window.opener ? window.opener.lookups[num_id] : null);
}
else{
//No id was passed in, let us check if we have a remembered cookie
//let us see if we have a previous num_id saved as a cookie
var oldNumId=getCookie("__popupNumId__");
if(oldNumId){
//we found a remembered id
obj_caller = (window.opener ? window.opener.lookups[oldNumId] : null);
}
else{
//oops!! abnormal situation
}
}
        if (obj_caller == null)
            obj_caller = window.opener;


This is our modified version of the file, with getCookie/setCookie functions. It works for us. Enjoy!

*************************************************************************************


> Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).
> ---------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-218
>                 URL: http://issues.apache.org/jira/browse/OFBIZ-218
>             Project: OFBiz (The Open for Business Project)
>          Issue Type: Bug
>          Components: framework
>            Reporter: Jacopo Cappellato
>            Priority: Minor
>         Attachments: lookup.ftl
>
>
> If you open a lookup window and then in the lookup window's form there is a new lookup link, that link will load a new lookup screen inside the same popup windows: the system will try to assign the value you'll select there to one of the fields of the main window (instead of one of the fields of the first lookup form).
> To reproduce this:
> 1) Accounting app
> 2) Find Payments
> 3) Choose a payment that still has an amount left to apply
> 4) Application tab
> 5) lookup from the invoices Id field
> 6) on that popup lookup from the "From Party Id" field on that screen to a lookup

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-218) Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)
    [ http://issues.apache.org/jira/browse/OFBIZ-218?page=comments#action_12433771 ]
           
Jacopo Cappellato commented on OFBIZ-218:
-----------------------------------------

Instead of using cookies as proposed, maybe a better solution is to use the 'window' JavaScript element:
the name of a lookup window could be equal to the name of the screen, than we could pass the name of the caller window to the called lookup.

Something like:
windowname.document.formname.fieldname

instead of:
document.formname.fieldname
(as we have today)

Does it make sense?

> Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).
> ---------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-218
>                 URL: http://issues.apache.org/jira/browse/OFBIZ-218
>             Project: OFBiz (The Open for Business Project)
>          Issue Type: Bug
>          Components: framework
>            Reporter: Jacopo Cappellato
>            Priority: Minor
>         Attachments: lookup.ftl
>
>
> If you open a lookup window and then in the lookup window's form there is a new lookup link, that link will load a new lookup screen inside the same popup windows: the system will try to assign the value you'll select there to one of the fields of the main window (instead of one of the fields of the first lookup form).
> To reproduce this:
> 1) Accounting app
> 2) Find Payments
> 3) Choose a payment that still has an amount left to apply
> 4) Application tab
> 5) lookup from the invoices Id field
> 6) on that popup lookup from the "From Party Id" field on that screen to a lookup

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-218) Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)
    [ http://issues.apache.org/jira/browse/OFBIZ-218?page=comments#action_12461562 ]
           
Jacopo Cappellato commented on OFBIZ-218:
-----------------------------------------

Another way to test this bug is explained by Jacques Le Roux in OFBIZ-579, that I have closed as 'duplicate' since it is very similar to this issue (but I think that his comment is interesting):

"There is a problem calling a lookup from a lookup window. Most of the time it fails else with an error message or doing nothing (see lookups in contentId lookup from Product/Content) and when you get to the second lookup (see Fixed Asset Id in WorkEffortId llokup from Product/WorkEffort) and it works, you never get back to the first lookup where the Id is needed. "


> Lookup buttons invoked from a lookup screen don't work because they return the selected value to the main window (instead of to the first lookup window).
> ---------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-218
>                 URL: http://issues.apache.org/jira/browse/OFBIZ-218
>             Project: Apache OFBiz (The Open for Business Project)
>          Issue Type: Bug
>          Components: framework
>            Reporter: Jacopo Cappellato
>            Priority: Minor
>         Attachments: lookup.ftl
>
>
> If you open a lookup window and then in the lookup window's form there is a new lookup link, that link will load a new lookup screen inside the same popup windows: the system will try to assign the value you'll select there to one of the fields of the main window (instead of one of the fields of the first lookup form).
> To reproduce this:
> 1) Accounting app
> 2) Find Payments
> 3) Choose a payment that still has an amount left to apply
> 4) Application tab
> 5) lookup from the invoices Id field
> 6) on that popup lookup from the "From Party Id" field on that screen to a lookup

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira