• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2241
  • Last Modified:

How to detect is applet started or not?

Hi all,

i have some problems with detection is applet started or not.
i have definition of applet in topFrame, and in mainFrame i have to wait until it is started.
so, in mainFrame i first waiting for loading of topFrame, and after it i wait for starting of applet.
here is code that i used in mainFrame:
 
<script>
  function waitUntilAppletOK(){
      if (parent.topFrame.document){
            if (parent.topFrame.document.myApplet){
                  if (parent.topFrame.document.myApplet.isActive()){ //this is line 24
                        convert();
                  }      
                    else
                        setTimeout("waitUntilAppletOK();", 1000);
            }
            else
                 setTimeout("waitUntilAppletOK();", 1000);            
      }
      else
                  setTimeout("waitUntilAppletOK();", 1000);            
      }

      function loadPage() {
            if (parent.top_isLoaded == true)
                  waitUntilAppletOK();
            else
                  setTimeout("LoadPage();",2000);
      }
      loadPage();
</script>

variable parent.top_isLoaded becomes true at the end of loading of topFrame.

and when i start application i got message:

Line 24:
Error: Object dosn't support this method or property

but if i refresh page after it, everything is ok.

how to disolve this problem?

thanks,
in advance
0
mali_djuro
Asked:
mali_djuro
  • 13
  • 8
  • 2
1 Solution
 
ZvonkoSystems architectCommented:
Put some var in topFrame to be set that var to true when the topFrame body has fired its onLoad event.
Check for that var in your mainFrame to ensure at least that the applet is loaded before checkin for activation.

0
 
ZvonkoSystems architectCommented:
Sorry, now I see you already have that top_isLoaded  var. I missed the check for that state in your upper waitUntilAppletOK() function.
Is it true that waitUntilAppletOK() is executed after topFrame has completted loading?
0
 
ZvonkoSystems architectCommented:
I was again too slow reading your source :)

Ok, reduce it top this:

<script>
 function waitUntilAppletOK(){
    if (parent.topFrame.document.myApplet.isActive &&
        parent.topFrame.document.myApplet.isActive()){
           convert();
      } else {
           setTimeout("waitUntilAppletOK();", 1000);
      }
   }

    function loadPage() {
         if (parent.top_isLoaded == true)
               waitUntilAppletOK();
         else
               setTimeout("LoadPage();",2000);
     }
    loadPage();
</script>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mali_djuroAuthor Commented:
yes, it passes loadPage function and goes to waitUntilAppletOK().

it gives error on checking

parent.topFrame.document.myApplet.isActive()

i don't know how else check it. i find out that if it is started it gives good results, but if it isn't it gives me error. is there other way for check?
0
 
ZvonkoSystems architectCommented:
Test please my last reduced proposal.
And no, I do not know of other applet state checking methods.
0
 
mali_djuroAuthor Commented:
i did, but still is a same error.

btw. what is difference between isActive and isActive()?

0
 
ZvonkoSystems architectCommented:
The difference is for isActive you get a reference to a method if the method is there, and with isActive() you call that method.
My idea was to test the existance of the method first and first afterwards try to invoke that method.

Soy you say that the same function can be called without problems, for example from a button when the applet is loaded?

Like this:
<form>
<input type=button value="Check" onClick="waitUntilAppletOK()">
</form>

0
 
mali_djuroAuthor Commented:
yes,

in this case it works, but it isn't very user friendly to have two stages of entrance in aplication.

also i found out this case, but i don't know will it works.

i made another page that chekc is applet loaded or not, and when it is loaded i call the main page

i have check.htm
<script language="JavaScript">
            function waitUntilAppletOK(){
                  if (parent.topFrame.document &&
                        parent.topFrame.document.myApplet &&
                            parent.topFrame.document.myApplet.isActive()){       
                          document.location = "main.htm";
                  }      
                  else{
                        setTimeout("waitUntilAppletOK();", 1000);
                  }      
            }

            function loadPage() {
                  if (parent.top_isLoaded == true)
                        waitUntilAppletOK();
                  else
                        setTimeout("loadPage();",2000);
            }

                        
            loadPage();
      </script>

and in main.htm i have

<script>
convert();
</script>

0
 
mali_djuroAuthor Commented:
i mean it works, but for me it is very similiar previous case. so i am not sure that it will fix problem.
0
 
ZvonkoSystems architectCommented:
And what do you expect from me?

Give it simply a try!

Most times are all cirmustances stupid side effects and you have no chance to overview them all.
That is my basic knowledge that I can pass to you ;-)
0
 
mali_djuroAuthor Commented:
"Most times are all cirmustances stupid side effects and you have no chance to overview them all."

every day i kearn that,
i hope that this problem has concrete sollution, but it is in some gray phase.

thanks for trying and not giving up.

0
 
ZvonkoSystems architectCommented:
It is difficult to simulate your environment for testing, but I am quiet sure and could bet that your problem is some timing problem or some cross domain access permission problem (cross domain can be on same machine).

Thanks for points.

See you around,
Zvonko

0
 
mali_djuroAuthor Commented:
btw. where are you coming from?
0
 
ZvonkoSystems architectCommented:
I am from Macedonia. But I am working in Munich.
Sada citam sta tvoje ime znaci!  LOL :-)
Iz Tetova sam.
0
 
mali_djuroAuthor Commented:
ja sam iz hrvatske, zagreb.

zivio.

hvala jos jednom!!
0
 
ZvonkoSystems architectCommented:
Now that I have looked to your profile I see that you are a Java programer.
Why do you not solve your problem from Java side?
Call in your init() method some JavaScript method wich will do the job as soon as init() is called.
0
 
ZvonkoSystems architectCommented:
This is not a very good description, but you will get some idea:
http://www.rgagnon.com/javadetails/java-0172.html

0
 
ZvonkoSystems architectCommented:
Here is a slightly better description:
http://www.netspade.com/articles/java/javascript.xml

0
 
mali_djuroAuthor Commented:
thanks,

after all, i will solve it on Java side, because it is only way, by now, that will work for sure.

0
 
ZvonkoSystems architectCommented:
Exactly.
0
 
zvisCommented:
I have a follow up question.  How can I tell from Javascript if a user has declined a signed applet.  I know how to detect if it has opened but I want to know after a few seconds if it is still in the process of opening or if the user declined the security alert. Any ideas please?

I launch the applet as follows


function createSampleClientApplet () {
	var myApplet = document.createElement("APPLET");
	myApplet.id = "SampleClientApplet";
	myApplet.archive = "/vcweb/clientApplet/lib/SampleClientApplet.jar";
	myApplet.code = "Sample.clientApplet.SampleClientApplet";
	myApplet.width = "1"; // On some browsers it wont work with width/height 0
	myApplet.height = "1";
	myApplet.MAYSCRIPT = "";  // It works without this but documentation says this is needed for JS<-->Applet comms
	var pageBody = document.getElementsByTagName("body")[0];
	pageBody.appendChild(myApplet);
};

Open in new window

0
 
ZvonkoSystems architectCommented:
Open your own question please.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 13
  • 8
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now