ptreves
asked on
Unable to read Javascript from Java
Hello,
I am attempting to read the value of a flag variable written from a button onclick event in javascript from a Java Applet. I am making a JSObject call.
The JSObject call throws an JSException and does not return any values.
I write setter/getter methods in javascript to increment the value of variable PowerbarClicked each time a powerbar is clicked. I made sure to load the applet from javascript from an <OBJECT tag and specifying MAYSCRIPT.
Any ideas what could be the issue ?
Paolo
I am attempting to read the value of a flag variable written from a button onclick event in javascript from a Java Applet. I am making a JSObject call.
The JSObject call throws an JSException and does not return any values.
I write setter/getter methods in javascript to increment the value of variable PowerbarClicked each time a powerbar is clicked. I made sure to load the applet from javascript from an <OBJECT tag and specifying MAYSCRIPT.
Any ideas what could be the issue ?
Paolo
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, I'm not quite clear.
Do you mean that you do have working interaction between javascript and the applet in your browser for some
case, but it is not working for another case?
Do you mean that you do have working interaction between javascript and the applet in your browser for some
case, but it is not working for another case?
ASKER
Yes, that is exactly my situation.
The ActiveAlarm button Applet JSObject calls work.
From the configuration normal button, JSObject calls don't work.
Paolo
The ActiveAlarm button Applet JSObject calls work.
From the configuration normal button, JSObject calls don't work.
Paolo
Sorry, I'm still trying to understand.
When you are writing
>One of the buttons called ActiveAlarm is itself an applet.
do you mean that you have an applet and within the applet you have the button.
So this applet indeed can access the elements of the web page which are not
part of this applet but some general HTML say text elements or anything.
Well, if this is correct, it is understandable.
Then what you mean by "the configuration is a normal button" - just plain HTML button.
So then what do you want from this button then?
I'm sorry, I'm still missing something
When you are writing
>One of the buttons called ActiveAlarm is itself an applet.
do you mean that you have an applet and within the applet you have the button.
So this applet indeed can access the elements of the web page which are not
part of this applet but some general HTML say text elements or anything.
Well, if this is correct, it is understandable.
Then what you mean by "the configuration is a normal button" - just plain HTML button.
So then what do you want from this button then?
I'm sorry, I'm still missing something
ASKER
The javascript document (or web-page) is divided in 2 frames, 1 top frame called a powerbar frame with about 10 buttons. The rest of the document or web page is another frame called the displayframe.
The powerbar buttons are divided in 3 categories.
1 category numbers only 1 powerbar button which is called the ActiveAlarm button and is basically a Java class that extends JApplet. The other 9 powerbar buttons are divided in 2 other groups, 1 group called the normal buttons and the last group called the popup buttons. The popup buttons open another browser window whcih basically contains row sets of data.
The normal buttons are programmed in javascript and have events associated to them. These events call Java applets on the displayframe.
One of the normal buttons is called the Configuration button.
I am trying to make JSObject calls to read a flag that would let me know if any of the powerbar buttons was clicked thsi in turn would allow me to call a JOptionPane on the active applet in the display frame.
The problem is that the JSObject calls I make don't return anything.
They work for the ActiveAlarm Applet button but not for the Configuration normal button.
Suggestions ?
Paolo
The powerbar buttons are divided in 3 categories.
1 category numbers only 1 powerbar button which is called the ActiveAlarm button and is basically a Java class that extends JApplet. The other 9 powerbar buttons are divided in 2 other groups, 1 group called the normal buttons and the last group called the popup buttons. The popup buttons open another browser window whcih basically contains row sets of data.
The normal buttons are programmed in javascript and have events associated to them. These events call Java applets on the displayframe.
One of the normal buttons is called the Configuration button.
I am trying to make JSObject calls to read a flag that would let me know if any of the powerbar buttons was clicked thsi in turn would allow me to call a JOptionPane on the active applet in the display frame.
The problem is that the JSObject calls I make don't return anything.
They work for the ActiveAlarm Applet button but not for the Configuration normal button.
Suggestions ?
Paolo
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The ActiveAlarm button is itself an Applet (a Java class that extends JApplet).
The ActiveAlarm button is responsible for monitoring communications with an external IO device. If a communication problem occurs a JDialog is displayed in the displayframe. The width, height, Xoffset and YOffset of the JDialog get their values from JSObject calls to coresponding javascript functions.
I would like to do read a flag called PowerbarClicked from the configuration button (which is a NORMAL button) and if this flag is set display a JOptionPane to prompt the user.
All my attempts to read the PowerbarClicked variable using JSObject calls do not return anything (no object is returned).
The JDialog parameters associated JSObject calls return JSObject which is converted to a string and then parsed to a Float or Integer.
Paolo
The ActiveAlarm button is responsible for monitoring communications with an external IO device. If a communication problem occurs a JDialog is displayed in the displayframe. The width, height, Xoffset and YOffset of the JDialog get their values from JSObject calls to coresponding javascript functions.
I would like to do read a flag called PowerbarClicked from the configuration button (which is a NORMAL button) and if this flag is set display a JOptionPane to prompt the user.
All my attempts to read the PowerbarClicked variable using JSObject calls do not return anything (no object is returned).
The JDialog parameters associated JSObject calls return JSObject which is converted to a string and then parsed to a Float or Integer.
Paolo
Your PowerbarClicked variable exists in the upper frame and your applet, which gets loaded when you press configuration button
is coming from the page in the lower frame - is this my udnderstanding correct?
ASKER
yes, that is correct. PowerbarClicked is written in javascript. The applet is written in java.
But one additional issue is that your oowerbarclicked script is not on the same web page from where your applet with which you want to communoicate is loaded.
Post your code in the applet throuigh which you try to communicate with the web page
Also poost your code from the ActiveAlarm code where it successfuly communicastes (as it is coming from the same page). Maybe we stil could think of simething
- myabe there is a way of communicating between two pages in the different frames
Post your code in the applet throuigh which you try to communicate with the web page
Also poost your code from the ActiveAlarm code where it successfuly communicastes (as it is coming from the same page). Maybe we stil could think of simething
- myabe there is a way of communicating between two pages in the different frames
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is the Java Applet methods that set the size and position of the JDialog based on javascript parameters read through JSObject calls:
/**
* Returns the size of the dialog.
*
* @param parameters parameters for the js call
* @return dialog size
*/
private Dimension getDialogSize(String[] parameters) {
Dimension size = null;
Object width = null;
Object height = null;
//Object clicks = null;
//try {
if (isRunningInBrowser()) {
//width = this.getJSObject().call("g etWidth", parameters);
//height = this.getJSObject().call("g etHeight", parameters);
//clicks = this.getJSObject().call("g etPowerbar Clicked", parameters);
width = this.getJSObject().call("g etWidth", null);
height = this.getJSObject().call("g etHeight", null);
//clicks = this.getJSObject().call("g etPowerbar Clicked", null);
}
//} catch (JSException jse) {
//System.out.println("JSEx ception method getJSObject from ActiveAlarmButton");
//}
if (width != null && height != null) {
if (logger.isDebugEnabled()) {
logger.debug("Got size from browser; width = " + width + ", height = " + height);
}
// FF reports them with decimal points
try {
float newWidth = Float.parseFloat(width.toS tring());
float newHeight = Float.parseFloat(height.to String());
//float newClicks = Float.parseFloat(clicks.to String());
//int newiClicks = (int) newClicks;
newWidth = newWidth / 2;
newHeight = newHeight / 2;
size = new Dimension((int) newWidth, (int) newHeight);
//System.out.println("**** ********** *********" );
//System.out.println("Powe rbar clicked: %d \n" + newiClicks);
//System.out.println("**** ********** *********" );
//JOptionPane.showMessageD ialog(null , "Dialog width: %d; Powerbar clicked: %d times." + newWidth + newiClicks);
} catch (NumberFormatException e) {
// do nothing if the browser reports it incorrectly
e.printStackTrace();
}
}
return size;
}
/**
* Returns the location of the dialog.
*
* @param parameters parameters for the js call
* @return dialog location
*/
private Point getDialogLocation(String[] parameters) {
Point location = null;
Object offsetX = null;
Object offsetY = null;
if (isRunningInBrowser()) {
offsetX = getJSObject().call("getOff setX", parameters);
offsetY = getJSObject().call("getOff setY", parameters);
}
if (offsetX != null && offsetY != null) {
if (logger.isDebugEnabled()) {
logger.debug("Got offset from browser; offsetX = " + offsetX + ", offsetY = " + offsetY);
}
// FF reports them with decimal points
try {
float newOffsetX = Float.parseFloat(offsetX.t oString()) ;
float newOffsetY = Float.parseFloat(offsetY.t oString()) ;
if (newOffsetX >= 0 && newOffsetY >= 0) {
location = new Point((int) newOffsetX, (int) newOffsetY);
}
} catch (NumberFormatException e) {
// do nothing if the browser reports it incorrectly
}
}
return location;
}
/**
* Returns the size of the dialog.
*
* @param parameters parameters for the js call
* @return dialog size
*/
private Dimension getDialogSize(String[] parameters) {
Dimension size = null;
Object width = null;
Object height = null;
//Object clicks = null;
//try {
if (isRunningInBrowser()) {
//width = this.getJSObject().call("g
//height = this.getJSObject().call("g
//clicks = this.getJSObject().call("g
width = this.getJSObject().call("g
height = this.getJSObject().call("g
//clicks = this.getJSObject().call("g
}
//} catch (JSException jse) {
//System.out.println("JSEx
//}
if (width != null && height != null) {
if (logger.isDebugEnabled()) {
logger.debug("Got size from browser; width = " + width + ", height = " + height);
}
// FF reports them with decimal points
try {
float newWidth = Float.parseFloat(width.toS
float newHeight = Float.parseFloat(height.to
//float newClicks = Float.parseFloat(clicks.to
//int newiClicks = (int) newClicks;
newWidth = newWidth / 2;
newHeight = newHeight / 2;
size = new Dimension((int) newWidth, (int) newHeight);
//System.out.println("****
//System.out.println("Powe
//System.out.println("****
//JOptionPane.showMessageD
} catch (NumberFormatException e) {
// do nothing if the browser reports it incorrectly
e.printStackTrace();
}
}
return size;
}
/**
* Returns the location of the dialog.
*
* @param parameters parameters for the js call
* @return dialog location
*/
private Point getDialogLocation(String[]
Point location = null;
Object offsetX = null;
Object offsetY = null;
if (isRunningInBrowser()) {
offsetX = getJSObject().call("getOff
offsetY = getJSObject().call("getOff
}
if (offsetX != null && offsetY != null) {
if (logger.isDebugEnabled()) {
logger.debug("Got offset from browser; offsetX = " + offsetX + ", offsetY = " + offsetY);
}
// FF reports them with decimal points
try {
float newOffsetX = Float.parseFloat(offsetX.t
float newOffsetY = Float.parseFloat(offsetY.t
if (newOffsetX >= 0 && newOffsetY >= 0) {
location = new Point((int) newOffsetX, (int) newOffsetY);
}
} catch (NumberFormatException e) {
// do nothing if the browser reports it incorrectly
}
}
return location;
}
ASKER
Here is the OBJECT tage for the ActiveAlarm button (which is itself an applet):
if($TypeOfButton[$Button] eq "ActiveAlarms")
{
print "<span style='border-right: #3A73BA 2px solid;'>";
print "<!--[if !IE]> Firefox and others will use outer object -->";
print "<object id='activeAlarmButtonApple t' classid='java:com.gepower. d400.view. runtime.Ac tiveAlarmB utton.clas s'";
print " type='application/x-java-a pplet'";
print " height='38' width='37.5' align='absbottom'>";
print " <param name ='java_arguments' value='-XX:ThreadStackSize =512' />";
print " <param name='code' value='com.gepower.d400.vi ew.runtime .ActiveAla rmButton.c lass' />";
print " <param name='codebase' value='../d400/' />";
print " <param name='name' value='PowerBarButton' />";
print " <param name='mayscript' value='true' />";
print " <param name='type' value='application/x-java- applet;ver sion=1.5' />";
print " <param name='location' value='/cgi-push/PowerBarA larm.cgi' />";
print " <param name='toolTip' value='$ToolTip[$Button]' />";
print " <param name='authCookie' value='$cookie' />";
print " <param name='displayUrl' value='$actualUrl' />";
print " <param name='sessID' value='$sessionKey' />";
print " <param name='logoutUrl' value='$logoutUrl' />";
print " <param name = 'cache_archive' value='$jars' />";
print " <param name = 'cache_version' value='$versions' />";
print " <param name = 'device_type' value='$device_type' />";
print "<!--<![endif]-->";
if($TypeOfButton[$Button] eq "ActiveAlarms")
{
print "<span style='border-right: #3A73BA 2px solid;'>";
print "<!--[if !IE]> Firefox and others will use outer object -->";
print "<object id='activeAlarmButtonApple
print " type='application/x-java-a
print " height='38' width='37.5' align='absbottom'>";
print " <param name ='java_arguments' value='-XX:ThreadStackSize
print " <param name='code' value='com.gepower.d400.vi
print " <param name='codebase' value='../d400/' />";
print " <param name='name' value='PowerBarButton' />";
print " <param name='mayscript' value='true' />";
print " <param name='type' value='application/x-java-
print " <param name='location' value='/cgi-push/PowerBarA
print " <param name='toolTip' value='$ToolTip[$Button]' />";
print " <param name='authCookie' value='$cookie' />";
print " <param name='displayUrl' value='$actualUrl' />";
print " <param name='sessID' value='$sessionKey' />";
print " <param name='logoutUrl' value='$logoutUrl' />";
print " <param name = 'cache_archive' value='$jars' />";
print " <param name = 'cache_version' value='$versions' />";
print " <param name = 'device_type' value='$device_type' />";
print "<!--<![endif]-->";
ASKER
This the code for a Configuration (normal button):
elsif($userLevel ne "$HmiAccessManager::HMI_SU PERVISOR")
{
if ($TypeOfButton[$Button] ne "Configuration")
{
printNormalButton($ToolTip [$Button], $displayUrl, $Image[$Button], $TypeOfButton[$Button]);
}
}
else
{
printNormalButton($ToolTip [$Button], $displayUrl, $Image[$Button], $TypeOfButton[$Button]);
}
elsif($userLevel ne "$HmiAccessManager::HMI_SU
{
if ($TypeOfButton[$Button] ne "Configuration")
{
printNormalButton($ToolTip
}
}
else
{
printNormalButton($ToolTip
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think you might have an interesting point.
The ActiveAlarm button is programmed is Java as an Applet and exists on the top level frame called the powerbar frame. It's JSObject calls are calling javascript methods in the same frame.
I could try something like:
width = this.getJSObject().call("p arent.powe rbarframe. getWidth", null);
height = this.getJSObject().call("p arent.powe rbarframe. getHeight" , null);
powerbarClick = this.getJSObject().call("p arent.powe rbarframe. getPowerba rClick", null);
My configuration applet being called from the bottom frame: parent.displayframe.
The ActiveAlarm button is programmed is Java as an Applet and exists on the top level frame called the powerbar frame. It's JSObject calls are calling javascript methods in the same frame.
I could try something like:
width = this.getJSObject().call("p
height = this.getJSObject().call("p
powerbarClick = this.getJSObject().call("p
My configuration applet being called from the bottom frame: parent.displayframe.
ASKER
I wrote a method from the ConfigurationController that manages applets in the bottom displayframe
The method is called getJSValues:
private void getJSValues() {
Object width = null;
Object height = null;
try {
width = currentApplet.getJSObject( ).call("pa rent.power frame.getW idth", null);
height = currentApplet.getJSObject( ).call("pa rent.power frame.getH eight", null);
} catch (JSException jse) {
jse.printStackTrace();
}
if (width != null && height != null) {
try {
float newWidth = Float.parseFloat(width.toS tring());
float newHeight = Float.parseFloat(height.to String());
System.out.println("****** ********** ********** ********** ********** ********** *");
System.out.println("Powerb ar clicked: %d, width: %d, height: %d \n" + newWidth + newHeight);
System.out.println("****** ********** ********** ********** ********** ********** *");
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}
The method is called getJSValues:
private void getJSValues() {
Object width = null;
Object height = null;
try {
width = currentApplet.getJSObject(
height = currentApplet.getJSObject(
} catch (JSException jse) {
jse.printStackTrace();
}
if (width != null && height != null) {
try {
float newWidth = Float.parseFloat(width.toS
float newHeight = Float.parseFloat(height.to
System.out.println("******
System.out.println("Powerb
System.out.println("******
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}
ASKER
When executing the code, I get the following Stack Trace in the Java Console Window:
netscape.javascript.JSExce ption
at netscape.javascript.JSObje ct.getWind ow(Unknown Source)
at com.gepower.d400.view.D400 Applet.get JSObject(D 400Applet. java:395)
at com.gepower.d400.view.conf ig.Configu rationCont roller.get JSValues(C onfigurati onControll er.java:66 1)
at com.gepower.d400.view.conf ig.Configu rationCont roller.pow erbarClick (Configura tionContro ller.java: 441)
at com.gepower.d400.view.conf ig.Configu rationCont roller.shu tdown(Conf igurationC ontroller. java:311)
at com.gepower.d400.view.Life CycleContr ollerApple t.destroy( LifeCycleC ontrollerA pplet.java :62)
at sun.plugin2.applet.Plugin2 Manager$Ap pletExecut ionRunnabl e.run(Unkn own Source)
at java.lang.Thread.run(Unkno wn Source)
Caused by: java.lang.NullPointerExcep tion
at java.applet.Applet.getAppl etContext( Unknown Source)
... 8 more
JSException method getJSObject from ConfigurationController
netscape.javascript.JSExce
at netscape.javascript.JSObje
at com.gepower.d400.view.D400
at com.gepower.d400.view.conf
at com.gepower.d400.view.conf
at com.gepower.d400.view.conf
at com.gepower.d400.view.Life
at sun.plugin2.applet.Plugin2
at java.lang.Thread.run(Unkno
Caused by: java.lang.NullPointerExcep
at java.applet.Applet.getAppl
... 8 more
JSException method getJSObject from ConfigurationController
ASKER
netscape.javascript.JSExce ption
at netscape.javascript.JSObje ct.getWind ow(Unknown Source)
It is not finding the parent.powerframe window ?
What is the cause of this Exception ?
at netscape.javascript.JSObje
It is not finding the parent.powerframe window ?
What is the cause of this Exception ?
ASKER
Maybe I am not calling my powerframe. Should I use some call similar to this javascript method:
function setHeight(){
if (window.mozInnerScreenY === undefined) {
// internet explorer
height = document.body.clientHeight + parent.displayframe.docume nt.body.cl ientHeight ;
} else {
// firefox
height = top.innerHeight;
}
}
function setHeight(){
if (window.mozInnerScreenY === undefined) {
// internet explorer
height = document.body.clientHeight
} else {
// firefox
height = top.innerHeight;
}
}
ASKER
I noticed this entry in my Stack Trace:
network: Cache entry not found [url: http://3.94.247.54/jsobject.jar, version: null]
Could this have anything to do with it ?
network: Cache entry not found [url: http://3.94.247.54/jsobject.jar, version: null]
Could this have anything to do with it ?
ASKER
Here are other entries of the Stack Trace:
network: Cache entry found [url: http://3.94.247.54/jsobject.jar, version: 2011.9.27.3546] prevalidated=false/0
cache: Reading Signers from 1000 http://3.94.247.54/jsobject.jar | D:\Users\502001950\AppData \LocalLow\ Sun\Java\D eployment\ cache\6.0\ 27\55532c9 b-7447a742 -2011.9.27 .3546-.idx
cache: Read manifest for http://3.94.247.54/jsobject.jar: read=236 full=236
network: Cache entry not found [url: http://3.94.247.54/jsobject.jar, version: null]
network: Cache entry found [url: http://3.94.247.54/jsobject.jar, version: 2011.9.27.3546] prevalidated=false/0
cache: Reading Signers from 1000 http://3.94.247.54/jsobject.jar | D:\Users\502001950\AppData
cache: Read manifest for http://3.94.247.54/jsobject.jar: read=236 full=236
network: Cache entry not found [url: http://3.94.247.54/jsobject.jar, version: null]
Are your lower frame and upperframe coming from the same domain ?
ASKER
Take a look at this:
<frameset rows="47,0,*" border="0">
<Frame name="powerframe" src="../cgi-bin/hmipowerba r.cgi" scrolling="no" noresize="noresize" onload="setTimeout(powerfr ameLoaded, 0)"/>
<Frame name="JSCalls" src="blank.html" scrolling="no" noresize="noresize"/>
<Frame name="displayframe" src="$homePageURL" onload="setTimeout(display frameLoade d, 0)"/>
</frameset>
<frameset rows="47,0,*" border="0">
<Frame name="powerframe" src="../cgi-bin/hmipowerba
<Frame name="JSCalls" src="blank.html" scrolling="no" noresize="noresize"/>
<Frame name="displayframe" src="$homePageURL" onload="setTimeout(display
</frameset>
ASKER
Also, take a look at this:
<object id='config' classid='clsid:8AD9C840-04 4E-11D1-B3 E9-00805F4 99D93'
codebase='https://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab'
height='99%' width='100%'>
<param name ='java_arguments' value='-XX:ThreadStackSize =512' />
<param name='code' value='com.gepower.d400.vi ew.config. Configurat ionApplet. class' />
<param name='codebase' value='../d400/' />
<param name='mayscript' value='true' />
<param name='type' value='application/x-java- applet;ver sion=1.5' />
<param name='authCookie' value='$cookie' />
<param name='userName' value='$userName' />
<param name='sessID' value='$sessionKey' />
<param name = 'cache_option' value='Plugin' />
<param name = 'cache_archive' value='$jars' />
<param name = 'cache_version' value='$versions' />
<param name ='device_type' value='$device_type' />
</object>
<object id='config' classid='clsid:8AD9C840-04
codebase='https://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab'
height='99%' width='100%'>
<param name ='java_arguments' value='-XX:ThreadStackSize
<param name='code' value='com.gepower.d400.vi
<param name='codebase' value='../d400/' />
<param name='mayscript' value='true' />
<param name='type' value='application/x-java-
<param name='authCookie' value='$cookie' />
<param name='userName' value='$userName' />
<param name='sessID' value='$sessionKey' />
<param name = 'cache_option' value='Plugin' />
<param name = 'cache_archive' value='$jars' />
<param name = 'cache_version' value='$versions' />
<param name ='device_type' value='$device_type' />
</object>
We don't know what is
$homePageURL
but I assume that it is the same domain
Especially you are actully using frameset (i was for some reason thinking in the sense of iFrame).
With frameset in order to reach right frame, you proabbly can also try top.powerframe.getWidth...
Another option to try would be to add a javscript method to your displayfFrame, which would be calling
this method from top.powerframe
so that Applet will call method form its own frame
I think ithese interactions within javaScript should be much more ofetn used
than when applet reaches out to another frame,
so they are more likely free of bugs seems to me than interactions between applet and the web page
which are less often used.
ASKER
Here is a method I wrote:
private void getJSValues() {
Object width = null;
Object height = null;
Object clicks = null;
Object clicks2 = null;
System.out.println("getJSV alues - inside method");
try {
//if (currentApplet.isRunningIn LocalBrows erHMI()) {
System.out.println("getJSV alues - running in Browser");
//width = currentApplet.getJSObject( ).call("pa rent.power frame.getW idth", null);
//height = currentApplet.getJSObject( ).call("pa rent.power frame.getH eight", null);
width = currentApplet.getJSObject( ).call("to p.powerfra me.getWidt h", null);
height = currentApplet.getJSObject( ).call("to p.powerfra me.getHeig ht", null);
clicks = currentApplet.getJSObject( ).call("pa rent.frame [0].powerb arClicked" , null);
clicks2 = currentApplet.getJSObject( ).call("pa rent.power frame.powe rbarClicke d", null);
System.out.println("getJSV alues - get width/height");
//}
} catch (JSException jse) {
jse.printStackTrace();
System.out.println("JSExce ption method getJSObject from ConfigurationController");
}
if (width != null && height != null) {
// FF reports them with decimal points
try {
float newWidth = Float.parseFloat(width.toS tring());
float newHeight = Float.parseFloat(height.to String());
float newClicks = Float.parseFloat(clicks.to String());
float newClicks2 = Float.parseFloat(clicks2.t oString()) ;
int newiClicks = (int) newClicks;
int newiClicks2 = (int) newClicks2;
newWidth = newWidth / 2;
newHeight = newHeight / 2;
System.out.println("****** ********** ********** ********** ********** ********** ********** ********** ******");
System.out.println("Powerb ar width: %d, height: %d \n" + newWidth + newHeight);
System.out.println("Powerb ar clicks: %d,clicks2: %d \n" + newiClicks + newiClicks2);
System.out.println("****** ********** ********** ********** ********** ********** ********** ********** ******");
} catch (NumberFormatException e) {
// do nothing if the browser reports it incorrectly
e.printStackTrace();
}
}
}
private void getJSValues() {
Object width = null;
Object height = null;
Object clicks = null;
Object clicks2 = null;
System.out.println("getJSV
try {
//if (currentApplet.isRunningIn
System.out.println("getJSV
//width = currentApplet.getJSObject(
//height = currentApplet.getJSObject(
width = currentApplet.getJSObject(
height = currentApplet.getJSObject(
clicks = currentApplet.getJSObject(
clicks2 = currentApplet.getJSObject(
System.out.println("getJSV
//}
} catch (JSException jse) {
jse.printStackTrace();
System.out.println("JSExce
}
if (width != null && height != null) {
// FF reports them with decimal points
try {
float newWidth = Float.parseFloat(width.toS
float newHeight = Float.parseFloat(height.to
float newClicks = Float.parseFloat(clicks.to
float newClicks2 = Float.parseFloat(clicks2.t
int newiClicks = (int) newClicks;
int newiClicks2 = (int) newClicks2;
newWidth = newWidth / 2;
newHeight = newHeight / 2;
System.out.println("******
System.out.println("Powerb
System.out.println("Powerb
System.out.println("******
} catch (NumberFormatException e) {
// do nothing if the browser reports it incorrectly
e.printStackTrace();
}
}
}
ASKER
This is the stack trace in the Java Console:
getJSValues - inside method
getJSValues - running in Browser
netscape.javascript.JSExce ption
at netscape.javascript.JSObje ct.getWind ow(Unknown Source)
at com.gepower.d400.view.D400 Applet.get JSObject(D 400Applet. java:395)
at com.gepower.d400.view.conf ig.Configu rationCont roller.get JSValues(C onfigurati onControll er.java:66 5)
at com.gepower.d400.view.conf ig.Configu rationCont roller.pow erbarClick (Configura tionContro ller.java: 429)
at com.gepower.d400.view.conf ig.Configu rationCont roller.shu tdown(Conf igurationC ontroller. java:311)
at com.gepower.d400.view.Life CycleContr ollerApple t.destroy( LifeCycleC ontrollerA pplet.java :62)
at sun.plugin2.applet.Plugin2 Manager$Ap pletExecut ionRunnabl e.run(Unkn own Source)
at java.lang.Thread.run(Unkno wn Source)
Caused by: java.lang.NullPointerExcep tion
at java.applet.Applet.getAppl etContext( Unknown Source)
... 8 more
JSException method getJSObject from ConfigurationController
getJSValues - inside method
getJSValues - running in Browser
netscape.javascript.JSExce
at netscape.javascript.JSObje
at com.gepower.d400.view.D400
at com.gepower.d400.view.conf
at com.gepower.d400.view.conf
at com.gepower.d400.view.conf
at com.gepower.d400.view.Life
at sun.plugin2.applet.Plugin2
at java.lang.Thread.run(Unkno
Caused by: java.lang.NullPointerExcep
at java.applet.Applet.getAppl
... 8 more
JSException method getJSObject from ConfigurationController
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>getJSValues - running in Browser
waht does it mean?
Just a comment to the Java Console.
waht does it mean?
Just a comment to the Java Console.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all your help.
I was able to get this working using a BrowserContext class.
Regards,
Paolo
I was able to get this working using a BrowserContext class.
Regards,
Paolo
ASKER
The comments guided me towards a solution.
ASKER
My javascript document is divided in 2 frames. A top frame called powerbar frame that contains 10 different buttons. One of the buttons called ActiveAlarm is itself an applet. The other 9 buttons are divided half and half in help buttons and normal buttons. One of the normal buttons is called the configuration button.
The ActiveAlarm button handles communication. When a timeout occurs a Faulty Communication Warning Dialog is displayed in the bottom frame called the display frame. The width, height, Xoffset and yoffset are set in javascript code and read through JSOject calls in the java applet code.
I want to replicate the same functionality from the configuration button which is programmed as a normal button (not an applet). My JSObject calls return no values.
What could be the issue ?
Paolo
PS: I am always using INternet Explorer under Windows 7.