Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Contributor
rjrojas
Posts: 16
Registered: ‎09-21-2011
My Carrier: t-mobile

WebWorks Embedded Browserfield2 Facebook Login Issue

Hi everyone, 

 

    I'm having an issue integrating with Facebook and the Browserfield2.    

    Basically, what we do is we redirect the user to the Facebook login page with our tokens and the corresponding redirect URL.

    When user posts the login credentials, two (Status=Found - 302) redirects occur and then a partial HTML page is returned to the user with the contents similar to this:   

      

  <script type="text/JavaScript">         

       window.location.href="http:\/\/ourredirecturl.com\/FBRedirect.aspx?code=AQA6BAeJ71AoWuulNW7qEuD.....ZMtlGo1iDk#_=_";       

   </script>          

 

Notice that this is only the content sent back in that last page.      

The issue is that this last page sent with Status OK-200 and Content-Type=text/html; charset=utf-8 is just being rendered, but the Browserfield2 is not executing the Javascript, so the users ends up stuck on this page.           

Both the embedded Browserfield2 in Webworks and a Browserfield2 embedded in native page exhibit this issue, but the default browser provided with BB OS6 does execute the JavaScript and redirects the user to I'm referring above as "ourredirecturl.com" and the user is successfully logged in.   

This works fine with other browsers like Firefox, etc...       

Is there something that I need to set in the BrowserFieldConfig or the Brwoserfield2 to make the Browserfield2 to execute the JavaScript and redirect the user to the page?    

 

Thanks in advance,

- Roberto

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,693
Registered: ‎10-16-2008
My Carrier: Rogers

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

Have you tried wrapping HTML/HEAD/BODY tags around the content?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rjrojas
Posts: 16
Registered: ‎09-21-2011
My Carrier: t-mobile

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

tnell,

   Thanks for replying.

   Unfortunately, I don't control the HTML that comes back. It's coming directly from Facebook.

   

    I thought about trying to get the raw HTML, extract the URL, and then perform the redirect using a Browserfield Listener or Controller, but I haven't found a way to do that. The document.getChildNodes() returns null.

 

Thanks,

- Roberto 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,693
Registered: ‎10-16-2008
My Carrier: Rogers

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

Are you on the same origin?? could you do an ajax call, return the script and then eval() the contents?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rjrojas
Posts: 16
Registered: ‎09-21-2011
My Carrier: t-mobile

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

Tim,

 

I think I know what you mean, but I don't know how to get a hold of the raw content.

I've been looking at the two parameters passed to the BrowserFieldListener.documentLoaded(Browserfield, Document),but I don't see a way to get the text of the raw content with any of those parameters.

If you know way, please let me know and I can give it try.

 

Thanks,

- Roberto 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,693
Registered: ‎10-16-2008
My Carrier: Rogers

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

I'm talking more about moving your code out of Java and into JavaScript... doing the hard work inside the web content. Do you control/own the HTML/CSS that is making the initial request to the server inside BrowserField?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rjrojas
Posts: 16
Registered: ‎09-21-2011
My Carrier: t-mobile

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

Unfortunately, I don't have control of that page. The application I'm building uses WebWorks and the user navigates out of the starting page of Webworks app to the pages of an existing web site. That web site provides the options to login using Facebook. 

 

I do have access to the Browserfield provided by WebWorks and could instantiate other Browserfield objects if needed to.

Is there any other way to make this work? Or get a hold of the HTML content returned?

 

Thanks,

- Roberto 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,693
Registered: ‎10-16-2008
My Carrier: Rogers

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

I believe what you are looking for is at the bottom of this page:

 

http://supportforums.blackberry.com/t5/Java-Development/Retrieve-content-from-browserfield/td-p/1022...

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rjrojas
Posts: 16
Registered: ‎09-21-2011
My Carrier: t-mobile

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

Thanks fo the link, but that did not work for me.  :smileysad:

 

 The Document object provided by the BrowserField2 in WebWorks is of type: 

net.rim.device.apps.internal.browser.olympia.dom.OlympiaDocument

 

This object does not appear to implement the HTMLDoc interface and I get Cast exceptions when I try to cast.

I've tried both org.w3c.dom.html.HTMLDoc (the webworks compile process does not allow it) and org.w3c.dom.html2.HTMLDoc.

 

 

Anything else I could try?

 

Thanks,

- Roberto

 

 

 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,693
Registered: ‎10-16-2008
My Carrier: Rogers

Re: WebWorks Embedded Browserfield2 Facebook Login Issue

What I would likely do is create a JavaScript Extension that gets loaded for your desired domain (setup properly as a <feature> in the <access> element for that domain in your config.xml file).

 

For the sake of simplicity.. let's call this API  "foo.setText(string)"

 

In my extension, I would listen for the BrowserField loaded event and then I would run an "executeScript()" on the BrowserField object that would run the following code

 

foo.setText(document.toString());

 

This would fire my "setText" function on my "foo" extension and it wold have the whole document's content as a string.

 

Also, if you are going this route, make sure that if you pass a handle for the BrowserField into your extension, make sure you keep it as a weak reference so that you don't get any memory leaks.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.