Bug 851112 - Invalid conversion of java Boolean type to javascript Boolean type
Summary: Invalid conversion of java Boolean type to javascript Boolean type
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: RHQ Project
Classification: Other
Component: CLI
Version: 4.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Lukas Krejci
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-23 09:36 UTC by Libor Zoubek
Modified: 2015-11-02 00:43 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2012-08-24 08:00:03 UTC
Embargoed:


Attachments (Terms of Use)

Description Libor Zoubek 2012-08-23 09:36:59 UTC
Description of problem: If I try to convert instance of java.lang.Boolean class to javascript Boolean type I am getting invalid value, see example:

var my = java.lang.Boolean.FALSE;

var myjs = Boolean(my);
myjs; // is TRUE!!!


Version-Release number of selected component (if applicable):
4.5.0-master

Comment 1 Lukas Krejci 2012-08-24 08:00:03 UTC
This is a consequence of javascript's rules of Boolean conversion - http://www.w3schools.com/js/js_obj_boolean.asp.

Because the variable "my" is an object (not a raw boolean value) and it is not null, javascript initializes the myjs variable to true, just as it should according to the rules outlined in the above link.

I think this works as expected, even though it is confusing.

If you had:

var my = java.lang.Boolean.FALSE.booleanValue();

the rest of the code would have worked as expected.


Note You need to log in before you can comment on or make changes to this bug.