rickilama54 / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

ListGridRecord's __ref attribute causes "Too much recursion" in ValuesManager.editRecord() #336

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

What steps will reproduce the problem?
1. Create a DynamicForm, add it to a ValuesManager.
2. Create a ListGridRecord in java, using "new ListGridRecord()"
3. Call valuesManager.editRecord() on the record

What is the expected output? What do you see instead?
I expect the record to be edited in the form.
This works in hosted mode, but in firefox, the browser hangs, and I get a
"Too much recursion" javascript exception.

Here is a screenshot of the exception (using firebug):
http://imgur.com/wiW7J.png

Here is the sample test case project:
http://rapidshare.com/files/287760417/tooMuchRecursionTestCase.zip.html

(I could not attach these files directly due to "Issue attachment storage
quota exceeded"... If someone can attach them it would be cool, because I
think rapidshare allows only 10 downloads... I'll keep a backup locally,
tell me if there is a problem with the hosts I have chosen)

The stacktrace I get is as follows:

findNextIndex()
findIndex()
find()
getArrayItem()
getItem()
getField()
_findMemberByField()
getItem()
_cloneValues()
_cloneValues()
_cloneValues()
...
[repeated 2975 times]
...
rememberValues()
setValues()
setData()
_editRecord()
editRecord()
kD
iE
rB
km
um
zz
lA
eB()
handleActivate()
handleClick()
bubbleEvent()
handleClick()
_handleMouseUp()
handleMouseUp()
dispatch()
(?)()

What version of the product are you using? On what operating system?
SmartGWT 1.3
Ubuntu 8.10
Firefox 3.0.14

Please provide any additional information below.
My guess is that ValuesManager.js' _cloneValues() method tries to deeply
clone the javaScriptObject, but the circular dependency between the
ListGridRecord and its associated jsObj creates an infinite loop.

Workarounds:
Remove the __ref attribute from the ListGridRecord once created, or create
it using new ListGridRecord(JSOHelper.createObject()) (which does not
initilize the __ref attribute).
The problem is that you would lose the ability to re-associate your
javascript record to the ListGridRecord when you bridge back from the
javascript world to the GWT world.

Regards,

Etienne

Original issue reported on code.google.com by nev...@gmail.com on 2 Oct 2009 at 1:52

GoogleCodeExporter commented 8 years ago
Thanks for the test case. Fixed in SVN. Let me know if you still have issues.

Original comment by sanjiv.j...@gmail.com on 8 Oct 2009 at 1:45

GoogleCodeExporter commented 8 years ago
Well, I tested my sample test case against the trunk, and I still seem to have 
the bug.
Maybe I built it wrong, though?

What I did:

svn update on both trunk/ and tools/

~/dev/checkouts/libs/smartgwt/smartgwt-read-only$ ant clean main
Tested using trunk/build/lib/smartgwt.jar
This did not correct the problem.

~/dev/checkouts/libs/smartgwt/smartgwt-read-only$ ant clean main
-Dsmartclient.version=7.0-trunk
(I never really used ant, but this seemed to take the latest version of
smartclient.jar with your recent changes)
Tested again using the jar generated in trunk/build/lib/smartgwt.jar, but I 
still got
the problem.

Note that the problem does not show in Hosted Mode, only in firefox. I also just
tested in Chromium and it also has the problem (it hangs).

I saw that you removed the __ref attribute inside DataSource.js' 
serializeFields()
method, but this method does not seem to get called, according to the "Too much
recursion" stacktrace. Shouldn't we try to remove it inside ValuesManager's
_cloneValues() method instead?

Regards

Original comment by nev...@gmail.com on 8 Oct 2009 at 1:13

GoogleCodeExporter commented 8 years ago
I ran your testcase in hosted mode and it ran fine. I'll run in web mode and 
see what
I find.

Original comment by sanjiv.j...@gmail.com on 8 Oct 2009 at 1:48

GoogleCodeExporter commented 8 years ago

Original comment by sanjiv.j...@gmail.com on 20 Oct 2009 at 2:33

GoogleCodeExporter commented 8 years ago
I'm attaching the test case and screenshot here, since we may attach files 
again:

Original comment by nev...@gmail.com on 20 Oct 2009 at 8:39

Attachments:

GoogleCodeExporter commented 8 years ago
is this issue fixed? any updates? We have hit similar issue and struggling to 
find a 
work around. I have attached sample test case code in this thread: 
http://forums.smartclient.com/showthread.php?p=32632#post32632

Original comment by rake...@gmail.com on 28 Oct 2009 at 4:43

GoogleCodeExporter commented 8 years ago
rakeshw, the issue you've reported is not related to this issue.

Original comment by sanjiv.j...@gmail.com on 28 Oct 2009 at 4:47

GoogleCodeExporter commented 8 years ago
do you want to suggest a workaround in the mean time? 

Thanks
Rakesh 

Original comment by rake...@gmail.com on 28 Oct 2009 at 5:25

GoogleCodeExporter commented 8 years ago
I have narrowed down this issue but haven't had a chance to look into the issue 
you
posted.

Original comment by sanjiv.j...@gmail.com on 28 Oct 2009 at 5:28

GoogleCodeExporter commented 8 years ago
Hi,

getting the same "Too much recursion" error when calling 
valuesManager.editRecord(),
but in my case there is no ListGrid involved cuz of two different datasources. 
Hosted
mode is OK, any Browser comes up with this error. Code snippet:

mValuesManager.getDataSource().filterData(crit, new DSCallback() {
    public void execute(DSResponse response, Object rawData, DSRequest request) {
        Record[] lRecord =  response.getData();
    mRecordForDynamicForm = lRecord[0];
        mValuesManager.editRecord(mRecordForDynamicForm);
    }
});

Now in fact that the filter being set on the DynamicForm´s DataSource 
definetely just
returns one record I tried following workaround:

mValuesManager.getDataSource().filterData(crit);
mValuesManager.fetchData();

fetchData should force any DynamicForm added to the ValuesManager to display the
first record of the datasource. Unfortunately the above mentioned "Too much
recursion" error appears in this workaround, too.

Is there any single workaround for multiple DynamicForms bound to same 
DataSource? Or
is a QuickFix available over SVN?

TIA!
Markus 

Original comment by mechlar2...@googlemail.com on 29 Oct 2009 at 7:50

GoogleCodeExporter commented 8 years ago
mechlar2009, which version of Smart GWT are you using? Have you tried the 
latest SVN build?

Original comment by sanjiv.j...@gmail.com on 29 Oct 2009 at 12:49

GoogleCodeExporter commented 8 years ago
Sorry for leaving that out: Error appears in SmartGWT 1.2 and 1.3

Haven´t had time to try the latest build today, will do so asap and add another
comment. Thx so far!

Original comment by mechlar2...@googlemail.com on 29 Oct 2009 at 2:25

GoogleCodeExporter commented 8 years ago
Well, unfortunately the error still exists on ValuesManager.editRecord() and
ValuesManager.fetchData() even with the new build :(

Original comment by mechlar2...@googlemail.com on 29 Oct 2009 at 3:55

GoogleCodeExporter commented 8 years ago
Removing the __ref attribute from the record works for me. I mean _so far_ it 
haven't
cauesed any issues to me.

Original comment by jaroslav...@gmail.com on 29 Oct 2009 at 5:12

GoogleCodeExporter commented 8 years ago
Hey Jaroslav,

Would you please be so kind to post your code snippet removing the __ref 
Attribute
from a Record()? Thx!

Markus

Original comment by mechlar2...@googlemail.com on 30 Oct 2009 at 9:52

GoogleCodeExporter commented 8 years ago
well, technically i'm not removing it...
record.setAttribute("__ref", "")
but rather setting to an empty string

Original comment by jaroslav...@gmail.com on 30 Oct 2009 at 9:56

GoogleCodeExporter commented 8 years ago
Damn, that works fine! Thank you very much :)

Original comment by mechlar2...@googlemail.com on 30 Oct 2009 at 10:16

GoogleCodeExporter commented 8 years ago
i'm glad i could help but credits go to Etienne (the very first message)

Original comment by jaroslav...@gmail.com on 30 Oct 2009 at 10:21

GoogleCodeExporter commented 8 years ago
ValuesManager._cloneValues() does not check whether such object has already been
cloned on previous recursive pass:
...
} else if (isc.isAn.Object(propValue) && !isc.isAn.Array(propValue)) {
    storedValues[prop] = {};
    this._cloneValues(storedValues[prop], propValue, (fullDataPath +
isc.Canvas._$slash));

So if we have for example the mutual(or cyclic) referenced objects - that 
causes this
function fall down in the infinite clone recursion. (e.g. I stored some Java
Hibernate/Gilead mutual/bidirectional one-to-one entities in some my/custom
ListGridRecord object's attributes and that breaks this function work even in 
GWT
hosted mode).  

                }

Original comment by psy051...@gmail.com on 11 Nov 2009 at 2:22

GoogleCodeExporter commented 8 years ago
Fixed in SVN. 

Original comment by sanjiv.j...@gmail.com on 27 Nov 2009 at 7:31

GoogleCodeExporter commented 8 years ago

Original comment by sanjiv.j...@gmail.com on 29 Nov 2009 at 10:31

GoogleCodeExporter commented 8 years ago
having a similar problem to this; basically updating a listgrid record;  Works 
in
hosted mode only, updates get to the db.  FF / IE /Chrome: it does not get to 
the db.  

Original comment by vitie...@gmail.com on 2 Dec 2009 at 9:32

GoogleCodeExporter commented 8 years ago
vitiello, as noted, this was recently fixed in SVN. Try the latest nightly or 
build 
from SVN.

Original comment by sanjiv.j...@gmail.com on 2 Dec 2009 at 9:35

GoogleCodeExporter commented 8 years ago
i have, it must be something else.

Original comment by vitie...@gmail.com on 7 Dec 2009 at 7:32

GoogleCodeExporter commented 8 years ago
ValuesManager.valuesHaveChanged() always return true even after 
rememberValues() call.
This is because _cloneValues() method just skips the "__ref" attribute, but
valuesHaveChanged() method uses isc.objectsAreEqual(...) method to compare 
current
values(which may contain __ref attribute) and _oldValues (which never contain 
__ref
attribute). So isc.objectsAreEqual(...) method should also skip __ref attribute 
upon
comparing say Record(s), or maybe other approach should be used - say just copy 
__ref
attribute instead of skip it in _cloneValues.

Original comment by psy051...@gmail.com on 8 Dec 2009 at 2:35

GoogleCodeExporter commented 8 years ago
I am facing problem of Too much recursion error.I am using smartgwt-2.1 this 
version
Below senario only run with 27 elements.but if set have 27 and  above elemets 
then it
triggers the error "Too much recursion" 

Set<Disposition> dispositionSet = envelope.getPayload() 
.getMessage().getZoeorder().getDisposition();

                if (dispositionSet != null && dispositionSet.size() > 0) {

                    for (Iterator<Disposition> iterator = dispositionSet
                            .iterator(); iterator.hasNext();) {
                        Disposition disposition = (Disposition) iterator.next();

                        HLayout dispositionLayout = new HLayout();
                        try {
                            orderPreview.getDispostionLayout(dispositionLayout,
                                    ZoeConstants.DISPOS_SECTION_ID, this,
                                    disposition, envelope);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        mainLayout.addMember(dispositionLayout);

                        // Display Layout

                        HLayout displayLayout = new HLayout();
                        orderPreview.getDisplayLayout(displayLayout,
                                ZoeConstants.DISPOS_SECTION_ID, this,
                                disposition);

                        mainLayout.addMember(orderPreview.getBlankLine());
                        mainLayout.addMember(displayLayout);

                        // get Zus�itzliche Hinweise Layout

                        HLayout zhLayout = new HLayout();
                        orderPreview.getZHLayout(zhLayout,
                                ZoeConstants.DISPOS_SECTION_ID, this,
                                disposition);

                        mainLayout.addMember(orderPreview.getBlankLine());
                        mainLayout.addMember(zhLayout);

                    }
                }

            }

            mainLayout.addMember(orderPreview.getBlankLine());
            mainLayout.addMember(addressesLayout);
            mainLayout.addMember(orderPreview.getBlankLine());
            mainLayout.addMember(addresses1Layout);
            mainLayout.addMember(orderPreview.getBlankLine());
            mainLayout.addMember(orderPreview.getBlankLine());
            mainLayout.addMember(obsLayout);

            quickViewWindow.addItem(mainLayout);

        } else {
            SC.say(Zoe.messages.noDataInOrderMSG());
        }

Original comment by parasjot...@gmail.com on 29 Mar 2010 at 5:30