You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Manohar Jeyaraj <ma...@gmail.com> on 2015/10/28 12:00:51 UTC

Not able to pass Object from stagewebview to javascript function

Hi,

My requirement is to pass object from stagewebview to javascript function
in HTML page.

Below is the sample code in Flex:

var obj:Object = new Object();
obj.firstName = "Simon";
obj.lastName = "Free";
webView.loadURL("javascript:myfunction('" + obj + "')");

Below is the code of JS function in HTML page:

function myfunction(obj)
{
        var str = obj.lastName;
        alert(str);
 }

The alert is showing up as 'undefined' in the application.
How to get the exact value of object in javascript? But if I write
alert(obj), it will display as [Object Object], which means there is object
value there but i am not able to extract it. Kindly let me know if there is
any way to extract object data in javascript.

Re: Not able to pass Object from stagewebview to javascript function

Posted by Alex Harui <ah...@adobe.com>.
If the alert is exactly the same, it could mean that there is some other
difference going on after this function gets called.  You might try one
final check using alert which is to display the typeof(str) to make sure
it is a string in both cases.  If it is, I think you will have to start
debugging the code after the alert.

-Alex

On 11/10/15, 7:34 PM, "manu" <ma...@gmail.com> wrote:

>Hi Alex,
>
>When i uncomment that line of alert it alerts the passed value from flex
>both in simulator and ipad. But the issue is when i run from ipad the
>polygon wont get showed in the map and the strange is its working in
>simulator.
>
>On Tue, Nov 10, 2015 at 9:20 PM, Alex Harui [via Apache Flex Users] <
>ml-node+s2333346n11455h79@n4.nabble.com> wrote:
>
>> I saw you commented out an alert of the “str” passed in.  What does it
>> look like when it works and when it doesn’t work?
>>
>> On 11/10/15, 3:06 AM, "Manohar Jeyaraj" <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=11455&i=0>> wrote:
>>
>> >Hi,
>> >
>> >Thanks Alex and Jude for the prompt reply. I tried with stagewebview
>> >wrapper it is working fine in simulator but not in ipad.
>> >Let me explain briefly.
>> >
>> >What I am trying to achieve is showing a polygon as a border for a
>> >particular state in a country based on geojson data file.
>> >
>> 
>>https://google-developers.appspot.com/maps/documentation/javascript/examp
>>l
>> >es/layer-data-dragndrop
>> >
>> >In the link above, if we drag and drop a geojson file of any geography,
>> >that particular region gets highlighted with a polygon.
>> >
>> >I am trying to achieve same thing by passing the geography\state code
>> from
>> >flex to html google map's javascript function.
>> >
>> >I am using tabbed view mobile flex application where i have a list(of
>> >various states of a particular country) and displaying Google Map
>>(which
>> >is
>> >Google Map javascript api HTML page).
>> >On change of list i am calling the stagewebview wrapper as Jude
>>suggested
>> >(webview.callJavaScript('myfunction',null,str)) and the selected
>> >value(which is the selected state's code) is being passed to html page
>> and
>> >it is working fine in the simulator as in the screenshot below link:
>> >
>> >http://pasteboard.co/21UN0O5N.png
>> >
>> >But when i deploy the code and run the ipa file in ipad the geography
>> wont
>> >be marked like in the screenshot above and it will display only the
>>empty
>> >map as in the screenshot below link:
>> >
>> >http://pasteboard.co/21Vf22LR.png
>> >
>> >This is the html page(code) that I am using within stagewebview:
>> >
>> >http://codepen.io/anon/pen/zvMBaz
>> >
>> >On selecting the list, i am calling following javascript function from
>> >flex:
>> >function myfunction(str)
>> >{
>> >    //alert(str);
>> >    loadJSON("./"+str+".geojson", function(response) {});   // this
>>loads
>> >the geojson file which has lat\long points that needs to be shown on
>>the
>> >map
>> >}
>> >
>> >Kindly let me know if i am missing anything or anything is wrong?.
>> >
>> >
>> >
>> >On Tue, Nov 10, 2015 at 4:09 AM, jude [via Apache Flex Users] <
>> >[hidden email] <http:///user/SendEmail.jtp?type=node&node=11455&i=1>>
>> wrote:
>> >
>> >> Manohar,
>> >>
>> >> Try this stagewebview wrapper,
>> >>
>> >>
>> >>
>> 
>>https://github.com/monkeypunch3/flexcapacitor/blob/master/MainMobileLibra
>> >>ry/src/com/flexcapacitor/controls/WebView.as.
>> >>
>> >> You would pass objects as stringified JSON as Alex mentioned. FYI In
>> the
>> >> latest Android a user reported you must add a fake protocol to get
>>the
>> >> event to fire,
>>https://github.com/monkeypunch3/flexcapacitor/issues/1.
>> >>
>> >> On Mon, Nov 9, 2015 at 8:38 AM, Alex Harui <[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=11451&i=0>> wrote:
>> >>
>> >> > Is your JS function being called, but just not with the right
>>value?
>> >> >
>> >> > If so, I would just JSON to stringify the object.
>> >> >
>> >> > -Alex
>> >> >
>> >> > On 11/9/15, 3:42 AM, "Manohar Jeyaraj" <[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=11451&i=1>> wrote:
>> >> >
>> >> > >ExternalInterface is not available as I am using this in mobile
>> >> > >application. Hence I am using stagewebview.
>> >> > >
>> >> > >I am using stagewebview(to display HTML Google map)  to call a
>> >> javascript
>> >> > >function in flex mobile application.
>> >> > >I am passing a selected item value(from flex) to a javascript
>> >>function
>> >> > >like
>> >> > >below:
>> >> > >
>> >> > >webView.loadURL(“javascript:myfunction(‘” +
>>lst.selectedItem[‘name’]
>> >>+
>> >> > >“‘)”);
>> >> > >
>> >> > >and in my html file  when i add an alert i am getting the value
>>too.
>> >> > >
>> >> > >But the problem is that the required function is working only
>>when i
>> >> add
>> >> > >it
>> >> > >under onload in body as below:
>> >> > >
>> >> > ><body onload="myfunction('value')">
>> >> > >
>> >> > >but when i remove the onload method from the body of html and call
>> it
>> >> from
>> >> > >flex the required action is not happening inside the JS function.
>> >> > >
>> >> > >Kindly help me out on what is causing the issue?
>> >> >
>> >> >
>> >>
>> >>
>> >> ------------------------------
>> >> If you reply to this email, your message will be added to the
>> discussion
>> >> below:
>> >>
>> >>
>> >>
>> 
>>http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-fr
>> >>om-stagewebview-to-javascript-function-tp11376p11451.html
>> >> To start a new topic under Apache Flex Users, email
>> >> [hidden email] <http:///user/SendEmail.jtp?type=node&node=11455&i=2>
>> >> To unsubscribe from Apache Flex Users, click here
>> >>
>> 
>>>><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jt
>>>>p?
>>
>> 
>>>>macro=unsubscribe_by_code&node=1&code=bWFudW1lOThAZ21haWwuY29tfDF8LTEyN
>>>>jk
>>
>> >>1NDc3NTE=>
>> >> .
>> >> NAML
>> >>
>> 
>>>><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jt
>>>>p?
>>
>> 
>>>>macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.na
>>>>ml
>>
>> 
>>>>.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nab
>>>>bl
>>
>> 
>>>>e.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabb
>>>>le
>>
>> 
>>>>%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%2
>>>>1n
>>
>> >>abble%3Aemail.naml>
>> >>
>> >
>> >
>> >
>> >--
>> >~M@nU~
>>
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> 
>>http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-fr
>>om-stagewebview-to-javascript-function-tp11376p11455.html
>> To start a new topic under Apache Flex Users, email
>> ml-node+s2333346n1h5@n4.nabble.com
>> To unsubscribe from Apache Flex Users, click here
>> 
>><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?
>>macro=unsubscribe_by_code&node=1&code=bWFudW1lOThAZ21haWwuY29tfDF8LTEyNjk
>>1NDc3NTE=>
>> .
>> NAML
>> 
>><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?
>>macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml
>>.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabbl
>>e.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble
>>%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21n
>>abble%3Aemail.naml>
>>
>
>
>
>-- 
>~M@nU~
>
>
>
>
>--
>View this message in context:
>http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-fro
>m-stagewebview-to-javascript-function-tp11376p11456.html
>Sent from the Apache Flex Users mailing list archive at Nabble.com.


Re: Not able to pass Object from stagewebview to javascript function

Posted by manu <ma...@gmail.com>.
Hi Alex,

When i uncomment that line of alert it alerts the passed value from flex
both in simulator and ipad. But the issue is when i run from ipad the
polygon wont get showed in the map and the strange is its working in
simulator.

On Tue, Nov 10, 2015 at 9:20 PM, Alex Harui [via Apache Flex Users] <
ml-node+s2333346n11455h79@n4.nabble.com> wrote:

> I saw you commented out an alert of the “str” passed in.  What does it
> look like when it works and when it doesn’t work?
>
> On 11/10/15, 3:06 AM, "Manohar Jeyaraj" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=11455&i=0>> wrote:
>
> >Hi,
> >
> >Thanks Alex and Jude for the prompt reply. I tried with stagewebview
> >wrapper it is working fine in simulator but not in ipad.
> >Let me explain briefly.
> >
> >What I am trying to achieve is showing a polygon as a border for a
> >particular state in a country based on geojson data file.
> >
> https://google-developers.appspot.com/maps/documentation/javascript/exampl
> >es/layer-data-dragndrop
> >
> >In the link above, if we drag and drop a geojson file of any geography,
> >that particular region gets highlighted with a polygon.
> >
> >I am trying to achieve same thing by passing the geography\state code
> from
> >flex to html google map's javascript function.
> >
> >I am using tabbed view mobile flex application where i have a list(of
> >various states of a particular country) and displaying Google Map (which
> >is
> >Google Map javascript api HTML page).
> >On change of list i am calling the stagewebview wrapper as Jude suggested
> >(webview.callJavaScript('myfunction',null,str)) and the selected
> >value(which is the selected state's code) is being passed to html page
> and
> >it is working fine in the simulator as in the screenshot below link:
> >
> >http://pasteboard.co/21UN0O5N.png
> >
> >But when i deploy the code and run the ipa file in ipad the geography
> wont
> >be marked like in the screenshot above and it will display only the empty
> >map as in the screenshot below link:
> >
> >http://pasteboard.co/21Vf22LR.png
> >
> >This is the html page(code) that I am using within stagewebview:
> >
> >http://codepen.io/anon/pen/zvMBaz
> >
> >On selecting the list, i am calling following javascript function from
> >flex:
> >function myfunction(str)
> >{
> >    //alert(str);
> >    loadJSON("./"+str+".geojson", function(response) {});   // this loads
> >the geojson file which has lat\long points that needs to be shown on the
> >map
> >}
> >
> >Kindly let me know if i am missing anything or anything is wrong?.
> >
> >
> >
> >On Tue, Nov 10, 2015 at 4:09 AM, jude [via Apache Flex Users] <
> >[hidden email] <http:///user/SendEmail.jtp?type=node&node=11455&i=1>>
> wrote:
> >
> >> Manohar,
> >>
> >> Try this stagewebview wrapper,
> >>
> >>
> >>
> https://github.com/monkeypunch3/flexcapacitor/blob/master/MainMobileLibra
> >>ry/src/com/flexcapacitor/controls/WebView.as.
> >>
> >> You would pass objects as stringified JSON as Alex mentioned. FYI In
> the
> >> latest Android a user reported you must add a fake protocol to get the
> >> event to fire, https://github.com/monkeypunch3/flexcapacitor/issues/1.
> >>
> >> On Mon, Nov 9, 2015 at 8:38 AM, Alex Harui <[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=11451&i=0>> wrote:
> >>
> >> > Is your JS function being called, but just not with the right value?
> >> >
> >> > If so, I would just JSON to stringify the object.
> >> >
> >> > -Alex
> >> >
> >> > On 11/9/15, 3:42 AM, "Manohar Jeyaraj" <[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=11451&i=1>> wrote:
> >> >
> >> > >ExternalInterface is not available as I am using this in mobile
> >> > >application. Hence I am using stagewebview.
> >> > >
> >> > >I am using stagewebview(to display HTML Google map)  to call a
> >> javascript
> >> > >function in flex mobile application.
> >> > >I am passing a selected item value(from flex) to a javascript
> >>function
> >> > >like
> >> > >below:
> >> > >
> >> > >webView.loadURL(“javascript:myfunction(‘” + lst.selectedItem[‘name’]
> >>+
> >> > >“‘)”);
> >> > >
> >> > >and in my html file  when i add an alert i am getting the value too.
> >> > >
> >> > >But the problem is that the required function is working only when i
> >> add
> >> > >it
> >> > >under onload in body as below:
> >> > >
> >> > ><body onload="myfunction('value')">
> >> > >
> >> > >but when i remove the onload method from the body of html and call
> it
> >> from
> >> > >flex the required action is not happening inside the JS function.
> >> > >
> >> > >Kindly help me out on what is causing the issue?
> >> >
> >> >
> >>
> >>
> >> ------------------------------
> >> If you reply to this email, your message will be added to the
> discussion
> >> below:
> >>
> >>
> >>
> http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-fr
> >>om-stagewebview-to-javascript-function-tp11376p11451.html
> >> To start a new topic under Apache Flex Users, email
> >> [hidden email] <http:///user/SendEmail.jtp?type=node&node=11455&i=2>
> >> To unsubscribe from Apache Flex Users, click here
> >>
> >><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?
>
> >>macro=unsubscribe_by_code&node=1&code=bWFudW1lOThAZ21haWwuY29tfDF8LTEyNjk
>
> >>1NDc3NTE=>
> >> .
> >> NAML
> >>
> >><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?
>
> >>macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml
>
> >>.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabbl
>
> >>e.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble
>
> >>%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21n
>
> >>abble%3Aemail.naml>
> >>
> >
> >
> >
> >--
> >~M@nU~
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-from-stagewebview-to-javascript-function-tp11376p11455.html
> To start a new topic under Apache Flex Users, email
> ml-node+s2333346n1h5@n4.nabble.com
> To unsubscribe from Apache Flex Users, click here
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=bWFudW1lOThAZ21haWwuY29tfDF8LTEyNjk1NDc3NTE=>
> .
> NAML
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
~M@nU~




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-from-stagewebview-to-javascript-function-tp11376p11456.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: Not able to pass Object from stagewebview to javascript function

Posted by Alex Harui <ah...@adobe.com>.
I saw you commented out an alert of the “str” passed in.  What does it
look like when it works and when it doesn’t work?

On 11/10/15, 3:06 AM, "Manohar Jeyaraj" <ma...@gmail.com> wrote:

>Hi,
>
>Thanks Alex and Jude for the prompt reply. I tried with stagewebview
>wrapper it is working fine in simulator but not in ipad.
>Let me explain briefly.
>
>What I am trying to achieve is showing a polygon as a border for a
>particular state in a country based on geojson data file.
>https://google-developers.appspot.com/maps/documentation/javascript/exampl
>es/layer-data-dragndrop
>
>In the link above, if we drag and drop a geojson file of any geography,
>that particular region gets highlighted with a polygon.
>
>I am trying to achieve same thing by passing the geography\state code from
>flex to html google map's javascript function.
>
>I am using tabbed view mobile flex application where i have a list(of
>various states of a particular country) and displaying Google Map (which
>is
>Google Map javascript api HTML page).
>On change of list i am calling the stagewebview wrapper as Jude suggested
>(webview.callJavaScript('myfunction',null,str)) and the selected
>value(which is the selected state's code) is being passed to html page and
>it is working fine in the simulator as in the screenshot below link:
>
>http://pasteboard.co/21UN0O5N.png
>
>But when i deploy the code and run the ipa file in ipad the geography wont
>be marked like in the screenshot above and it will display only the empty
>map as in the screenshot below link:
>
>http://pasteboard.co/21Vf22LR.png
>
>This is the html page(code) that I am using within stagewebview:
>
>http://codepen.io/anon/pen/zvMBaz
>
>On selecting the list, i am calling following javascript function from
>flex:
>function myfunction(str)
>{
>    //alert(str);
>    loadJSON("./"+str+".geojson", function(response) {});   // this loads
>the geojson file which has lat\long points that needs to be shown on the
>map
>}
>
>Kindly let me know if i am missing anything or anything is wrong?.
>
>
>
>On Tue, Nov 10, 2015 at 4:09 AM, jude [via Apache Flex Users] <
>ml-node+s2333346n11451h55@n4.nabble.com> wrote:
>
>> Manohar,
>>
>> Try this stagewebview wrapper,
>>
>> 
>>https://github.com/monkeypunch3/flexcapacitor/blob/master/MainMobileLibra
>>ry/src/com/flexcapacitor/controls/WebView.as.
>>
>> You would pass objects as stringified JSON as Alex mentioned. FYI In the
>> latest Android a user reported you must add a fake protocol to get the
>> event to fire, https://github.com/monkeypunch3/flexcapacitor/issues/1.
>>
>> On Mon, Nov 9, 2015 at 8:38 AM, Alex Harui <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=11451&i=0>> wrote:
>>
>> > Is your JS function being called, but just not with the right value?
>> >
>> > If so, I would just JSON to stringify the object.
>> >
>> > -Alex
>> >
>> > On 11/9/15, 3:42 AM, "Manohar Jeyaraj" <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=11451&i=1>> wrote:
>> >
>> > >ExternalInterface is not available as I am using this in mobile
>> > >application. Hence I am using stagewebview.
>> > >
>> > >I am using stagewebview(to display HTML Google map)  to call a
>> javascript
>> > >function in flex mobile application.
>> > >I am passing a selected item value(from flex) to a javascript
>>function
>> > >like
>> > >below:
>> > >
>> > >webView.loadURL(“javascript:myfunction(‘” + lst.selectedItem[‘name’]
>>+
>> > >“‘)”);
>> > >
>> > >and in my html file  when i add an alert i am getting the value too.
>> > >
>> > >But the problem is that the required function is working only when i
>> add
>> > >it
>> > >under onload in body as below:
>> > >
>> > ><body onload="myfunction('value')">
>> > >
>> > >but when i remove the onload method from the body of html and call it
>> from
>> > >flex the required action is not happening inside the JS function.
>> > >
>> > >Kindly help me out on what is causing the issue?
>> >
>> >
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> 
>>http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-fr
>>om-stagewebview-to-javascript-function-tp11376p11451.html
>> To start a new topic under Apache Flex Users, email
>> ml-node+s2333346n1h5@n4.nabble.com
>> To unsubscribe from Apache Flex Users, click here
>> 
>><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?
>>macro=unsubscribe_by_code&node=1&code=bWFudW1lOThAZ21haWwuY29tfDF8LTEyNjk
>>1NDc3NTE=>
>> .
>> NAML
>> 
>><http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?
>>macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml
>>.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabbl
>>e.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble
>>%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21n
>>abble%3Aemail.naml>
>>
>
>
>
>-- 
>~M@nU~


Re: Not able to pass Object from stagewebview to javascript function

Posted by Manohar Jeyaraj <ma...@gmail.com>.
Hi,

Thanks Alex and Jude for the prompt reply. I tried with stagewebview
wrapper it is working fine in simulator but not in ipad.
Let me explain briefly.

What I am trying to achieve is showing a polygon as a border for a
particular state in a country based on geojson data file.
https://google-developers.appspot.com/maps/documentation/javascript/examples/layer-data-dragndrop

In the link above, if we drag and drop a geojson file of any geography,
that particular region gets highlighted with a polygon.

I am trying to achieve same thing by passing the geography\state code from
flex to html google map's javascript function.

I am using tabbed view mobile flex application where i have a list(of
various states of a particular country) and displaying Google Map (which is
Google Map javascript api HTML page).
On change of list i am calling the stagewebview wrapper as Jude suggested
(webview.callJavaScript('myfunction',null,str)) and the selected
value(which is the selected state's code) is being passed to html page and
it is working fine in the simulator as in the screenshot below link:

http://pasteboard.co/21UN0O5N.png

But when i deploy the code and run the ipa file in ipad the geography wont
be marked like in the screenshot above and it will display only the empty
map as in the screenshot below link:

http://pasteboard.co/21Vf22LR.png

This is the html page(code) that I am using within stagewebview:

http://codepen.io/anon/pen/zvMBaz

On selecting the list, i am calling following javascript function from flex:
function myfunction(str)
{
    //alert(str);
    loadJSON("./"+str+".geojson", function(response) {});   // this loads
the geojson file which has lat\long points that needs to be shown on the map
}

Kindly let me know if i am missing anything or anything is wrong?.



On Tue, Nov 10, 2015 at 4:09 AM, jude [via Apache Flex Users] <
ml-node+s2333346n11451h55@n4.nabble.com> wrote:

> Manohar,
>
> Try this stagewebview wrapper,
>
> https://github.com/monkeypunch3/flexcapacitor/blob/master/MainMobileLibrary/src/com/flexcapacitor/controls/WebView.as.
>
> You would pass objects as stringified JSON as Alex mentioned. FYI In the
> latest Android a user reported you must add a fake protocol to get the
> event to fire, https://github.com/monkeypunch3/flexcapacitor/issues/1.
>
> On Mon, Nov 9, 2015 at 8:38 AM, Alex Harui <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=11451&i=0>> wrote:
>
> > Is your JS function being called, but just not with the right value?
> >
> > If so, I would just JSON to stringify the object.
> >
> > -Alex
> >
> > On 11/9/15, 3:42 AM, "Manohar Jeyaraj" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=11451&i=1>> wrote:
> >
> > >ExternalInterface is not available as I am using this in mobile
> > >application. Hence I am using stagewebview.
> > >
> > >I am using stagewebview(to display HTML Google map)  to call a
> javascript
> > >function in flex mobile application.
> > >I am passing a selected item value(from flex) to a javascript function
> > >like
> > >below:
> > >
> > >webView.loadURL(“javascript:myfunction(‘” + lst.selectedItem[‘name’] +
> > >“‘)”);
> > >
> > >and in my html file  when i add an alert i am getting the value too.
> > >
> > >But the problem is that the required function is working only when i
> add
> > >it
> > >under onload in body as below:
> > >
> > ><body onload="myfunction('value')">
> > >
> > >but when i remove the onload method from the body of html and call it
> from
> > >flex the required action is not happening inside the JS function.
> > >
> > >Kindly help me out on what is causing the issue?
> >
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-flex-users.2333346.n4.nabble.com/Not-able-to-pass-Object-from-stagewebview-to-javascript-function-tp11376p11451.html
> To start a new topic under Apache Flex Users, email
> ml-node+s2333346n1h5@n4.nabble.com
> To unsubscribe from Apache Flex Users, click here
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=bWFudW1lOThAZ21haWwuY29tfDF8LTEyNjk1NDc3NTE=>
> .
> NAML
> <http://apache-flex-users.2333346.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
~M@nU~

Re: Not able to pass Object from stagewebview to javascript function

Posted by jude <fl...@gmail.com>.
Manohar,

Try this stagewebview wrapper,
https://github.com/monkeypunch3/flexcapacitor/blob/master/MainMobileLibrary/src/com/flexcapacitor/controls/WebView.as.
You would pass objects as stringified JSON as Alex mentioned. FYI In the
latest Android a user reported you must add a fake protocol to get the
event to fire, https://github.com/monkeypunch3/flexcapacitor/issues/1.

On Mon, Nov 9, 2015 at 8:38 AM, Alex Harui <ah...@adobe.com> wrote:

> Is your JS function being called, but just not with the right value?
>
> If so, I would just JSON to stringify the object.
>
> -Alex
>
> On 11/9/15, 3:42 AM, "Manohar Jeyaraj" <ma...@gmail.com> wrote:
>
> >ExternalInterface is not available as I am using this in mobile
> >application. Hence I am using stagewebview.
> >
> >I am using stagewebview(to display HTML Google map)  to call a javascript
> >function in flex mobile application.
> >I am passing a selected item value(from flex) to a javascript function
> >like
> >below:
> >
> >webView.loadURL(“javascript:myfunction(‘” + lst.selectedItem[‘name’] +
> >“‘)”);
> >
> >and in my html file  when i add an alert i am getting the value too.
> >
> >But the problem is that the required function is working only when i add
> >it
> >under onload in body as below:
> >
> ><body onload="myfunction('value')">
> >
> >but when i remove the onload method from the body of html and call it from
> >flex the required action is not happening inside the JS function.
> >
> >Kindly help me out on what is causing the issue?
>
>

Re: Not able to pass Object from stagewebview to javascript function

Posted by Alex Harui <ah...@adobe.com>.
Is your JS function being called, but just not with the right value?

If so, I would just JSON to stringify the object.

-Alex

On 11/9/15, 3:42 AM, "Manohar Jeyaraj" <ma...@gmail.com> wrote:

>ExternalInterface is not available as I am using this in mobile
>application. Hence I am using stagewebview.
>
>I am using stagewebview(to display HTML Google map)  to call a javascript
>function in flex mobile application.
>I am passing a selected item value(from flex) to a javascript function
>like
>below:
>
>webView.loadURL(“javascript:myfunction(‘” + lst.selectedItem[‘name’] +
>“‘)”);
>
>and in my html file  when i add an alert i am getting the value too.
>
>But the problem is that the required function is working only when i add
>it
>under onload in body as below:
>
><body onload="myfunction('value')">
>
>but when i remove the onload method from the body of html and call it from
>flex the required action is not happening inside the JS function.
>
>Kindly help me out on what is causing the issue?


Re: Not able to pass Object from stagewebview to javascript function

Posted by Manohar Jeyaraj <ma...@gmail.com>.
ExternalInterface is not available as I am using this in mobile
application. Hence I am using stagewebview.

I am using stagewebview(to display HTML Google map)  to call a javascript
function in flex mobile application.
I am passing a selected item value(from flex) to a javascript function like
below:

webView.loadURL(“javascript:myfunction(‘” + lst.selectedItem[‘name’] +
“‘)”);

and in my html file  when i add an alert i am getting the value too.

But the problem is that the required function is working only when i add it
under onload in body as below:

<body onload="myfunction('value')">

but when i remove the onload method from the body of html and call it from
flex the required action is not happening inside the JS function.

Kindly help me out on what is causing the issue?

Re: Not able to pass Object from stagewebview to javascript function

Posted by Alex Harui <ah...@adobe.com>.

On 10/28/15, 11:26 AM, "omuppi1@gmail.com on behalf of OmPrakash
Muppirala" <omuppi1@gmail.com on behalf of bigosmallm@gmail.com> wrote:

>On Wed, Oct 28, 2015 at 9:58 AM, Alex Harui <ah...@adobe.com> wrote:
>
>> Did you try using JSON on both sides to stringify and parse obj?
>>
>
>I don't think it is required to stringify an object before passing flash
>to
>JS.

I agree for ExternalInterface.  I haven’t tried loadURL.  I would think
the URL has to be a string and is  parsed and run via eval() or
writeDocument.

-Alex


Re: Not able to pass Object from stagewebview to javascript function

Posted by OmPrakash Muppirala <bi...@gmail.com>.
On Wed, Oct 28, 2015 at 9:58 AM, Alex Harui <ah...@adobe.com> wrote:

> Did you try using JSON on both sides to stringify and parse obj?
>

I don't think it is required to stringify an object before passing flash to
JS.

In javascript, try to enumerate the passed object like this:

for (var key in obj)
{
    alert(key);
}


>
> On 10/28/15, 4:00 AM, "Manohar Jeyaraj" <ma...@gmail.com> wrote:
>
> >Hi,
> >
> >My requirement is to pass object from stagewebview to javascript function
> >in HTML page.
> >
> >Below is the sample code in Flex:
> >
> >var obj:Object = new Object();
> >obj.firstName = "Simon";
> >obj.lastName = "Free";
> >webView.loadURL("javascript:myfunction('" + obj + "')");
> >
> >Below is the code of JS function in HTML page:
> >
> >function myfunction(obj)
> >{
> >        var str = obj.lastName;
> >        alert(str);
> > }
> >
> >The alert is showing up as 'undefined' in the application.
> >How to get the exact value of object in javascript? But if I write
> >alert(obj), it will display as [Object Object], which means there is
> >object
> >value there but i am not able to extract it. Kindly let me know if there
> >is
> >any way to extract object data in javascript.
>
>

Re: Not able to pass Object from stagewebview to javascript function

Posted by Alex Harui <ah...@adobe.com>.
Did you try using JSON on both sides to stringify and parse obj?

On 10/28/15, 4:00 AM, "Manohar Jeyaraj" <ma...@gmail.com> wrote:

>Hi,
>
>My requirement is to pass object from stagewebview to javascript function
>in HTML page.
>
>Below is the sample code in Flex:
>
>var obj:Object = new Object();
>obj.firstName = "Simon";
>obj.lastName = "Free";
>webView.loadURL("javascript:myfunction('" + obj + "')");
>
>Below is the code of JS function in HTML page:
>
>function myfunction(obj)
>{
>        var str = obj.lastName;
>        alert(str);
> }
>
>The alert is showing up as 'undefined' in the application.
>How to get the exact value of object in javascript? But if I write
>alert(obj), it will display as [Object Object], which means there is
>object
>value there but i am not able to extract it. Kindly let me know if there
>is
>any way to extract object data in javascript.