Seems like an applet that is inside a DOM container and getting hidden by calling JQuery’s hide() method messes up the applet’s state.

In my case, I got an IllegalStateException and in some cases forced it to restart the applet which in turned messed up the operation that my code is doing.

I used the deployJava.js script to deploy the applet and enable me to call applet methods from Javascript.

So rather than using hide, user Danny Coulombe of StackOverflow gave a very workable solution. Using CSS, you can use JQuery to add the class attribute to hide or show the applet. See code.

To hide, call $(‘myapplet’).addClass(‘hide’).

To show, call $(‘myapplet’).removeClass(‘hide’).

A very useful solution to preserve your applet state in case you wish to hide it from the user’s view and show it later on using the same instance.

I came upon this problem because the site I wanted to access had server problems, meaning the website was down. When my code tried to access it again, it gave out this “Invalid use of SingleClientConnManager: connection still allocated” exception message.

My code uses Apache’s HttpClient 3rd party library and I thought at first calling the consumeContent() method of the HttpEntity class did the trick since I never even closed the InputStream when getting a reference to it. It did not.

Luckily, after much surfing I stumbled upon Jason Hudgin’s site where he created a convenience method that avoids this problem.

Related Posts Plugin for WordPress, Blogger...