Bug 851112 - Invalid conversion of java Boolean type to javascript Boolean type
Invalid conversion of java Boolean type to javascript Boolean type
Status: CLOSED NOTABUG
Product: RHQ Project
Classification: Other
Component: CLI (Show other bugs)
4.4
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: Lukas Krejci
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-23 05:36 EDT by Libor Zoubek
Modified: 2015-11-01 19:43 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-24 04:00:03 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Libor Zoubek 2012-08-23 05:36:59 EDT
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 04:00:03 EDT
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.