Calling the applet from Javascript

Post here questions and problems related to oXygen frameworks/document types.
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Calling the applet from Javascript

Post by sderrick »

I'm having intermittent crashes when calling the applet to load up a file and am sure its something I'm not doing right.

I see two different methods used..

this one elevates privileges

Code: Select all

 public String getSerializedDocument() {
//EXM-27477 This method might come from Javascript code, elevate privileges.
return AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(editorComponent
this one calls runnable, elevates privileges and waits on a thread.

Code: Select all


	public void setDocumentContent(final String url, final String xmlContent)
throws AuthorComponentException {
documentURL = url;
Runnable runnable = new Runnable() {
@Override
public void run() {
//EXM-27477 This method might come from Javascript code, elevate privileges.
AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
invokeOnAWT(new Runnable() {
@Override
public void run() {
1.) Why the difference?

2.) If I add a function which should I use?

3.) If I return a value there is no built in thread accessors?

4.) What happens if these get stacked? elevate, calls another elevate?

thanks,

Scott
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Calling the applet from Javascript

Post by sderrick »

I cleaned up and combined the function calls into the applet from javascript, and so far that has ended the odd crash.

Though I haven't been able to run the applet from a remote server yet to really test it. It did appear to be timing or thread issues..

Scott
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: Calling the applet from Javascript

Post by Radu »

Hi Scott,

I am not sure why those crashes occurred, did you find any meaningful information in the Java console view?
From what I remember, when the Javascript code calls the applet code, it calls it with restrictive security permissions so we elevated the rights in the Java code.
An alternative to elevating the rights in the Java functions called from JS would have been to call System.setSecurityManager(null); early when the applet was started.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Calling the applet from Javascript

Post by sderrick »

Radu,

When it happened, The browser would hang, no output in the console. When it would finally recover the console would close, and the web page would report the plugin had crashed.

If it happens again I will enable logging in the java control panel.

Scott
Post Reply