Hi Indunil,

Seems like the problem is in your script.

Boolean.toString(claimForProfile[i].getRequired())

 I believe your intention here is to call java.lang.Boolean#toString(boolean
b) method, right? But Nashorn doesn't know that, because you haven't
imported java.lang.Boolean class in your script. In order to use a Java
class in your script, first you have to import that class in your script
with Java.type Nashorn extension [1]. (see 'call Java class' sample in the
features-app sample)
Since you haven't imported java.lang.Boolean class, Nashorn thinks
Boolean.toString is a JS function, thus it is serialized to "function
Boolean() { [native code] }".

Anyway, You don't need to convert boolean values to strings here. So let's
remove Boolean.toString

[1]
https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/javascript.html#A1147187

Thanks.

On Fri, Jan 20, 2017 at 10:13 AM, SajithAR Ariyarathna <sajit...@wso2.com>
wrote:

> Hi Indunil,
>>
>> claimProfileMap["required"] = Boolean.toString(claimForProfile[i].
>> getRequired());
>>
> I don't see a particular reason to convert boolean to string. You can just
> use the boolean value directly.
>
> Anyhow, we will fix this.
> Thanks.
>
> On Fri, Jan 20, 2017 at 7:47 AM, Indunil Upeksha Rathnayake <
> indu...@wso2.com> wrote:
>
>> Hi,
>>
>> The code segment I have used as follows.
>>
>> function getProfile() {
>>     var claimProfile;
>>     try {
>>         // Get Claim Profile
>>         claimProfile = 
>> callOSGiService("org.wso2.is.portal.user.client.api.ProfileMgtClientService",
>>             "getProfile", ["self-signUp"]);
>>     } catch(e) {
>>         return {errorMessage: "Failed to retrieve the claim profile."};
>>     }
>>     var claimForProfile = claimProfile.claims;
>>
>>     var claimProfileArray = [];
>>
>>     for (var i = 0; i < claimForProfile.length; i++) {
>>         var claimProfileMap = {};
>>         claimProfileMap["displayName"] = claimForProfile[i].getDisplayName();
>>         claimProfileMap["claimURI"] = claimForProfile[i].getClaimURI();
>>         if (claimForProfile[i].getDefaultValue()) {
>>             claimProfileMap["defaultValue"] = 
>> claimForProfile[i].getDefaultValue();
>>         }
>>         claimProfileMap["claimLabel"] = 
>> claimForProfile[i].getClaimURI().replace("http://wso2.org/claims/";, "");
>>         claimProfileMap["required"] = 
>> Boolean.toString(claimForProfile[i].getRequired());
>>         claimProfileMap["regex"] = claimForProfile[i].getRegex();
>>         claimProfileMap["readonly"] = 
>> Boolean.toString(claimForProfile[i].getReadonly());
>>         claimProfileMap["dataType"] = claimForProfile[i].getDataType();
>>         claimProfileArray[i] = claimProfileMap;
>>     }
>>     sendToClient("signupClaims", claimProfileArray);
>>     return {
>>         "signupClaims": claimProfileArray
>>     };
>> }
>>
>> ​
>> Thanks and Regards
>>
>>
>> On Thu, Jan 19, 2017 at 10:03 PM, Manuranga Perera <m...@wso2.com> wrote:
>>
>>> when sending boolean value as a string(converting boolean to string
>>>> using "Boolean.toString()"
>>>
>>> Not very clear what you are saying here. Can you please show the code.
>>>
>>> On Thu, Jan 19, 2017 at 4:23 PM, Danushka Fernando <danush...@wso2.com>
>>> wrote:
>>>
>>>> HI
>>>> Seems its calling [1] and [2] is something its getting called. When we
>>>> have a boolean as a string probably that happens. But not sure that's
>>>> expected.
>>>>
>>>> [1] https://github.com/google/gson/blob/0636635cbffa08157bdb
>>>> d558b1212e4d806474eb/gson/src/main/java/com/google/gson/Gson.java#L580
>>>> [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/
>>>> Reference/Global_Objects/Object/toSource
>>>>
>>>> Thanks & Regards
>>>> Danushka Fernando
>>>> Senior Software Engineer
>>>> WSO2 inc. http://wso2.com/
>>>> Mobile : +94716332729 <+94%2071%20633%202729>
>>>>
>>>> On Thu, Jan 19, 2017 at 7:43 PM, Indunil Upeksha Rathnayake <
>>>> indu...@wso2.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> It's returning {"signupClaims": claimProfileArray} from the
>>>>> onRequest() method. claimProfileArray is an array with several map
>>>>> objects. I have just tested and found that this error comes when sending
>>>>> boolean value as a string(converting boolean to string using
>>>>> "Boolean.toString()").
>>>>> As an example like this.
>>>>> [{"claimURI":"http://wso2.org/claims/givenname","required":"true"},
>>>>> {"claimURI":"http://wso2.org/claims/lastname","required":"true"}].
>>>>>
>>>>> But passing as a boolean value it works. Is that an acceptable
>>>>> behavior?
>>>>>
>>>>> Thanks and Regards
>>>>>
>>>>> On Thu, Jan 19, 2017 at 7:08 PM, Kishanthan Thangarajah <
>>>>> kishant...@wso2.com> wrote:
>>>>>
>>>>>> We are using gson to serialize the json sent to client [1]. But we
>>>>>> need the sample data used here to test what could be the issue.
>>>>>>
>>>>>> [1] https://github.com/wso2/carbon-uuf/blob/master/component
>>>>>> s/uuf-renderablecreator-hbs/src/main/java/org/wso2/carbon/uu
>>>>>> f/renderablecreator/hbs/impl/js/JsFunctionsImpl.java#L152
>>>>>>
>>>>>> On Thu, Jan 19, 2017 at 7:04 PM, Manuranga Perera <m...@wso2.com>
>>>>>> wrote:
>>>>>>
>>>>>>> I think it's a java object. I think we need to use something like
>>>>>>> gson here
>>>>>>>
>>>>>>> On Thu, Jan 19, 2017 at 1:30 PM, Kishanthan Thangarajah <
>>>>>>> kishant...@wso2.com> wrote:
>>>>>>>
>>>>>>>> Can we have the json object to investigate this?
>>>>>>>>
>>>>>>>> On Thu, Jan 19, 2017 at 6:22 PM, SajithAR Ariyarathna <
>>>>>>>> sajit...@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> +{UUF Team]
>>>>>>>>>
>>>>>>>>> On Thu, Jan 19, 2017 at 5:34 PM, Indunil Upeksha Rathnayake <
>>>>>>>>> indu...@wso2.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> Having some problem when using sendToClient() method in the UUF
>>>>>>>>>> Server Side JS API. I am trying to send an array with a set of map 
>>>>>>>>>> elements
>>>>>>>>>> as in [1] including some boolean values. When we are sending this 
>>>>>>>>>> value to
>>>>>>>>>> client side using the sendToClient(), it's injecting the
>>>>>>>>>> variables to the "js" placeholder in the layout. But when evaluating 
>>>>>>>>>> the
>>>>>>>>>> variable, boolean values are not stored as it is but as follows.
>>>>>>>>>> *function Boolean() { [native code] }*
>>>>>>>>>>
>>>>>>>>>> Seems like in there, it's getting the value of
>>>>>>>>>> "booleanVaribale.constructor". I'm using uuf version "1.0.0-m9".
>>>>>>>>>> Is this expectable or an issue?
>>>>>>>>>>
>>>>>>>>>> [1] [ {"claimURI":"http://wso2.org/claims/givenname
>>>>>>>>>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.org%2Fclaims%2Fgivenname&sa=D&sntz=1&usg=AFQjCNHhpHtMY1eVUFZfM8A2n2iOnajUvg>
>>>>>>>>>> ","required":"function Boolean() { [native code] }"},
>>>>>>>>>> {"claimURI":"http://wso2.org/claims/lastname
>>>>>>>>>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.org%2Fclaims%2Flastname&sa=D&sntz=1&usg=AFQjCNGDQuIZMXiN8WMbgitjy9uIJ_jKDw>
>>>>>>>>>> ","required":"function Boolean() { [native code] }"}]
>>>>>>>>>>
>>>>>>>>>> Thanks and Regards
>>>>>>>>>> --
>>>>>>>>>> Indunil Upeksha Rathnayake
>>>>>>>>>> Software Engineer | WSO2 Inc
>>>>>>>>>> Email    indu...@wso2.com
>>>>>>>>>> Mobile   0772182255
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Sajith Janaprasad Ariyarathna
>>>>>>>>> Software Engineer; WSO2, Inc.;  http://wso2.com/
>>>>>>>>> <https://wso2.com/signature>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Kishanthan Thangarajah*
>>>>>>>> Technical Lead,
>>>>>>>> Platform Technologies Team,
>>>>>>>> WSO2, Inc.
>>>>>>>> lean.enterprise.middleware
>>>>>>>>
>>>>>>>> Mobile - +94773426635 <+94%2077%20342%206635>
>>>>>>>> Blog - *http://kishanthan.wordpress.com
>>>>>>>> <http://kishanthan.wordpress.com>*
>>>>>>>> Twitter - *http://twitter.com/kishanthan
>>>>>>>> <http://twitter.com/kishanthan>*
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dev mailing list
>>>>>>>> Dev@wso2.org
>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> With regards,
>>>>>>> *Manu*ranga Perera.
>>>>>>>
>>>>>>> phone : 071 7 70 20 50
>>>>>>> mail : m...@wso2.com
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Kishanthan Thangarajah*
>>>>>> Technical Lead,
>>>>>> Platform Technologies Team,
>>>>>> WSO2, Inc.
>>>>>> lean.enterprise.middleware
>>>>>>
>>>>>> Mobile - +94773426635 <+94%2077%20342%206635>
>>>>>> Blog - *http://kishanthan.wordpress.com
>>>>>> <http://kishanthan.wordpress.com>*
>>>>>> Twitter - *http://twitter.com/kishanthan
>>>>>> <http://twitter.com/kishanthan>*
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Indunil Upeksha Rathnayake
>>>>> Software Engineer | WSO2 Inc
>>>>> Email    indu...@wso2.com
>>>>> Mobile   0772182255
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> Dev@wso2.org
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> Dev@wso2.org
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> With regards,
>>> *Manu*ranga Perera.
>>>
>>> phone : 071 7 70 20 50
>>> mail : m...@wso2.com
>>>
>>
>>
>>
>> --
>> Indunil Upeksha Rathnayake
>> Software Engineer | WSO2 Inc
>> Email    indu...@wso2.com
>> Mobile   0772182255
>>
>> _______________________________________________
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Sajith Janaprasad Ariyarathna
> Software Engineer; WSO2, Inc.;  http://wso2.com/
> <https://wso2.com/signature>
>



-- 
Sajith Janaprasad Ariyarathna
Software Engineer; WSO2, Inc.;  http://wso2.com/
<https://wso2.com/signature>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to