Bug 851112

Summary: Invalid conversion of java Boolean type to javascript Boolean type
Product: [Other] RHQ Project Reporter: Libor Zoubek <lzoubek>
Component: CLIAssignee: Lukas Krejci <lkrejci>
Status: CLOSED NOTABUG QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.4CC: hrupp, theute
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-24 08:00:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.