Forum Discussion

jmcwhinney's avatar
jmcwhinney
Contributor
11 years ago

.FindChild( will not refresh cached copy of object.

I cant seem to get .FindChild to find my object directly below it.



I have tried the following:

MyObject.FindChild("JavaFullClassName","javax.swing.JViewport");

MyObject.FindChild("JavaFullClassName","javax.swing.JViewport",1,true);





and neither of them work.



However, if I first try to iterate the children objects and look at their classname, then it does work afterwards... (see below)







DisplayComponents(MyObject);

MyObject.FindChild("JavaFullClassName","javax.swing.JViewport");



function DisplayComponents(TheObject){

  var TheComponents = TheObject.getComponents();

  for (var i = 0; i < TheComponents.length; i++) {

    if(TheComponents.Items(i) != null){

      if(TheComponents.Items(i).getClass() != null){

        var ClassName = TheComponents.Items(i).getClass().toString();

      }

    }

  }

}

4 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi James,

     


    Have you tried calling the Refresh method?




    MyObject.Refresh();


    MyObject.FindChild("JavaFullClassName","javax.swing.JViewport");



  • Hi Tanya,



    Yes I did try using MyObject.Refresh() instead of using my DisplayComponents function, however it did not work.



    Thanks,

    - James



  • I started noticing that even my workaround method wasn't working all the time.

    After adding a time delay between checking the subcomponents and calling .FindChild, that seemed to fix it.



    So then I tried the same thing with .Refresh() and that worked too.

    eg:





    MyObject.Refresh();

    aqUtils.Delay(1000);

    MyObject.FindChild("JavaFullClassName","javax.swing.JViewport");



    Is there any better way to wait for the completion of .Refresh() rather than the above workaround??

    I would have expected the application to automatically wait until the refresh had completed before moving to the next line of code.



    Thanks!

    - James