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.

inside custom component

Java Development

Reply
Regular Contributor
anawara
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000
Accepted Solution

BrowserField rendering problems

Hello,

 

I'm writing an application that uses the BrowserField for OS 4.6. I am using the code provided in the sample called BrowserFieldDemo to try to open the following link:

 

https://graph.facebook.com/oauth/authorize?client_id=250246779365&redirect_uri=http://www.omnicoretech.com/fb/footprints/oauth_redirect.php&display=wap

 

The code retrieves and displays the page. However, some of the characters are rendered as Boxes and not the actual characters

 

The following is a code snippet which sets the options for my browserfield

 

 

 _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_ENABLED, true);
        _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.ENABLE_CSS, true);       
        _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.OVERWRITE_CHARSET_MODE, true);
        _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.WAP_MODE, true);

 

When I call the connection's getType() method the returned type is

Connection Type: application/xhtml+xml; charset=UTF-8

 

 

Any idea why I'm seeing blocks instead of some words?

Developer
luisfernando
Posts: 91
Registered: ‎11-24-2009
My Device: Storm

Re: BrowserField rendering problems

hello,

 

I opened the link you mentioned. It returns a string like: access_token=2453452345|6.4IddDTqSH_Y96KYdCpJMSg__.3600.1273291200-612870152|0_UJfap7A4XMgQwG8_IKOkKQADU.&expires=4406

 

I guess you want to process that response. I just have one question for you. If this is the case, why dont you use an HTTPConnection instead of a browserfield?

 

let me know.


-Luis Fernando

Remember to give Kudos(click on the star at your left) if this helped you.
Click on "Accept Solution" if the problem is resolved.
Espanol? Escribeme un mensaje privado.
Regular Contributor
anawara
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000

Re: BrowserField rendering problems

Thank you luis.

 

I have no problems with obtaining the string that has the access token. My problem is a step before submitting the login form. The page doesn't render properly when I open it. The image below might help you better understand my problem. As you can see a lot of characters are screwed for some reason when using a BrowserField. I have to use a browserfield because I am using Facebook as a sign in utility and hence cannot just create a normal form and capture the data and send it using a normal HttpConnection.

1920i76712A037378E470

Developer
luisfernando
Posts: 91
Registered: ‎11-24-2009
My Device: Storm

Re: BrowserField rendering problems

can you get the source of that page from your browserfield and paste it here? 

-Luis Fernando

Remember to give Kudos(click on the star at your left) if this helped you.
Click on "Accept Solution" if the problem is resolved.
Espanol? Escribeme un mensaje privado.
Regular Contributor
anawara
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000

Re: BrowserField rendering problems

I've printed out the data in the InputStream of the HttpConnection that I am using to connect to the link and passing to the browserfield and this is what I got.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>التواصل عبر فيس بوك | Facebook</title><meta name="description" content="Facebook helps you connect and share with the people in your life." /></head><body><div id="header"><span>التواصل عبر فيس بوك</span></div><div><b>يجب تسجيل الدخول أولاً.</b><hr /></div><div id="body"><div><div><img src="https://s-static.ak.facebook.com/rsrc.php/z5SFU/hash/3gjc00v4.gif" alt="apps" width="32" height="32" /><img src="images/connect.png" alt="connect" /><img src="images/fb-connect.png" alt="facebook" /></div><div><small>Log in to Facebook to connect it to <a href="http://www.omnicoretech.com/fb/footprints/">PhotoLife</a>. When you connect, you can bring your Facebook friends and info to <a href="http://www.omnicoretech.com/fb/footprints/">PhotoLife</a>, and bring content to your Wall and News Feed. Doing so means you have agreed to both the <a href="/terms.php">مصطلحات في الفيس بوك</a> and the شروط PhotoLife‏ .</small></div><div><form method="post" action="https://login.facebook.com/login.php?api_key=250246779365&amp;v=1.0&amp;fbconnect=1&amp;return_sessi..."><div>البريد الإلكتروني أو الهاتف:</div><input type="text" name="email" value="" /><div>كلمة السر</div><input type="password" name="pass" /><br /><input type="submit" name="login" value="إنشاء رابط" /> <span></span></form></div><div><div><b>Security note:</b>بعد تسجيل الدخول، من المفترض ألا يطالبك هذا الموقع بإدخال كلمة السر الخاصة بفيس بوك.</div><div>لديك مشكلة في تسجيل الدخول؟ <a href="/login.php?http&amp;next=https%3A%2F%2Fgraph.facebook.com%2Foauth%2Fauthorize_success%3Fclient_id%3D250246779365%26redirect_uri%3Dhttp%253A%252F%252Fwww.omnicoretech.com%252Ffb%252Ffootprints%252Foauth_redirect.php%26display%3Dwap%26type%3Dweb_server&amp;api_key=250246779365&amp;v=1.0&amp;fbconnect=1&amp;return_session=1&amp;refsrc=m.facebook.com%2Flogin.php">جرب تسجيل دخول بديل</a>‏</div></div></div></div><div id="footer"><a href="/r.php?r928212e0&amp;refid=9">التسجيل في فيس بوك</a><br /><a href="/home.php?r408f9437&amp;refid=9">اذهب إلى Facebook.com</a><br /><a href="http://developers.facebook.com/connect.php">لمعرفة المزيد حول ميزة التواصل</a></div></body></html>

 For some reason I am receiving the page source all screwed up like that.

 

What really baffles me is that if I attempt to open the same page from the normal browser application it actually works and renders properly and returns this source

 

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Connect with Facebook | Facebook</title><meta name="description" content="Facebook helps you connect and share with the people in your life." /><style type="text/css">#fb_header{height:24px} body{margin:0;padding:0;font-family:sans-serif;font-size:medium} a:link, a:visited{color:#3b5998;text-decoration:none} a:focus, a:hover{color:#fff;background-color:#3b5998} form{margin:0;border:0} .pad{padding:2px 3px} .border_top{border-top:1px solid #ccc} .border_top_light{border-top:1px solid #eee} .border_bottom{border-bottom:1px solid #ccc} .border_bottom_light{border-bottom:1px solid #eee} .separator{padding:1px 0} small{color:#555} img.p{border:1px solid #ccc} .zero_marquee{background-color:#193369;color:#fff;font-size:small} .zero_marquee a:link, .zero_marquee a:visited{color:#fff;text-decoration:underline} .zero_marquee a:focus, .zero_marquee a:hover{color:#193369;background-color:#fff} .zero_marquee_warning{background-color:#bb3e39;color:#fff;font-size:small} .marquee{background-color:#3b5998} .marquee table{border-spacing:0;width:100%} #marquee_tabs{padding:0 0 1px} .marquee a:link, .marquee a:visited{color:#fff;padding:2px 4px 2px} .marquee a:focus, .marquee a:hover{color:#3b5998;background-color:#fff} .marquee_tab_select{color:#fff;background-color:#6d84b4;padding-bottom:1px} .error{background-color:#ffebe8;border:1px solid #DD3C10} .notice{background-color:#fff8cc;border:1px solid #FFE222} #search{background-color:#f7f7f7;margin:2px} .summary{padding-top:1px} .wall{margin-bottom:2px} .section{padding:4px 0} #title, .section_title{font-weight:bold;color:#333} .subsection{padding:2px 0} .button{background-color:#3b5998;color:#fff} .highlight{background:#fff8cc;border-bottom:1px solid #ffe222} .comment{background-color:#d8dfea;border-bottom:1px solid #fff} .comment_box{background-color:#fff} .recent_activity{padding-left:8px} .dh{padding-top:3px} .note{background-color:#f7f7f7;border-top:1px solid #3b5998;border-bottom:1px solid #ccc} .likethumbicon{vertical-align:middle;margin-right:3px} .date_box, .wkday_box{height:27px;width:27px} .date_box a{color:#808080} .ev_exists a{color:#3b5998} .date_box{border:1px solid #ccc} .sel_wk_box{background-color:#d8dfea} .non_month_box{background-color:#ddd} .icon{vertical-align:middle;margin-right:2px}body{margin:0;padding:0;font-family:sans-serif} div{margin:0;padding:2px 4px} #header{background-color:#6d84b4;color:#fff} .title{font-weight:bold;margin:0;padding:0} p{font-size:small;margin:5px 0;line-height:16px} a{text-decoration:none;color:#3b5998} .button{background-color:#516899;border:1px solid #152f5f;color:#fff} .cancel{font-size:small} .action{background-color:#f7f7f7;border-top:1px solid #ccc;border-bottom:1px solid #ccc;padding:8px 2px} .help{font-size:x-small;color:#333} .diagram{text-align:center;padding:10px 4px} .footer{font-size:small;padding:10px 4px} .note{font-size:x-small} .datetime{color:#999;font-size:x-small} table{border-collapse:separate;border-spacing:0}</style></head><body><div id="header"><span class="title">Connect with Facebook</span></div><div class="notice pad"><b>You must log in first.</b></div><div id="body" class="pad"><div class="content"><div class="diagram"><img src="https://s-static.ak.facebook.com/rsrc.php/z5SFU/hash/3gjc00v4.gif" alt="apps" width="32" height="32" /><img src="images/connect.png" alt="connect" /><img src="images/fb-connect.png" alt="facebook" /></div><div><small>Log in to Facebook to connect it to <a href="http://www.omnicoretech.com/fb/footprints/">PhotoLife</a>. When you connect, you can bring your Facebook friends and info to <a href="http://www.omnicoretech.com/fb/footprints/">PhotoLife</a>, and bring content to your Wall and News Feed. Doing so means you have agreed to both the <a href="/terms.php">terms of Facebook</a> and the terms of PhotoLife .</small></div><div class="action"><form method="post" action="https://login.facebook.com/login.php?api_key=250246779365&amp;v=1.0&amp;fbconnect=1&amp;return_sessi..."><div>Email or Phone:</div><input type="text" name="email" value="" /><div>Password:</div><input type="password" name="pass" /><br /><input type="submit" class="button" name="login" value="Connect" /> <span class="cancel"></span></form></div><div class="content"><div class="note"><b>Security note:</b>After login, this site should not require your Facebook password.</div><div class="note">Trouble logging in? <a href="/login.php?http&amp;next=https%3A%2F%2Fgraph.facebook.com%2Foauth%2Fauthorize_success%3Fclient_id%3D250246779365%26redirect_uri%3Dhttp%253A%252F%252Fwww.omnicoretech.com%252Ffb%252Ffootprints%252Foauth_redirect.php%26display%3Dwap%26type%3Dweb_server&amp;api_key=250246779365&amp;v=1.0&amp;fbconnect=1&amp;return_session=1&amp;refsrc=m.facebook.com%2Flogin.php">Try the alternative login</a>.</div></div></div></div><div id="footer" class="pad"><a href="/r.php?r7ad23e1d&amp;refid=9">Sign up for Facebook</a><br /><a href="/home.php?r23049497&amp;refid=9">Go to Facebook.com</a><br /><a href="http://developers.facebook.com/connect.php">Learn more about Connect</a></div><script type="text/javascript">/* <![CDATA[ */if (top != self) { try { if (top.location.hostname.indexOf("apps") >= 0) { throw 1; } } catch (e) {setTimeout(function() {var fb_cj_img = new Image(); fb_cj_img.src="http:\/\/error.facebook.com\/common\/scribe_endpoint.php?c=si_clickjacking&m&t=1";}, 5000); }}/* ]]> */</script></body></html>

 

 

 

Developer
luisfernando
Posts: 91
Registered: ‎11-24-2009
My Device: Storm

Re: BrowserField rendering problems

Hello,

 

I copied your rendering session values into my browserfield demo and run it with no problems. The only thing I noticed is that the facebook is using geolocation(maybe using IP address) to send me the page in my language no matter that the OS is in english. Now, when I open my blackberry browser the page comes in english, so you might be in the same situation as me. If you are running your code from India, Japan or other country facebook might be sending you the page in other charset than utf-8 no matter that the headers say so. 

 

Let me do some more tests and see if I can reproduce your error or find a solution.

 

 

-Luis Fernando

Remember to give Kudos(click on the star at your left) if this helped you.
Click on "Accept Solution" if the problem is resolved.
Espanol? Escribeme un mensaje privado.
Regular Contributor
anawara
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000

Re: BrowserField rendering problems

Well I am running the code from Egypt so I guess Facebook is trying to send me some arabic characters? Its weird though because not all the page is in weird characters. Its mainly in English with a few exceptions. In addition when I inspect my httpconnection object and check the type I get the value "application/xhtml+xml; charset=UTF-8".

 

I've tried another approach which is having my own implementation of HttpConnection and storing a string representing the page code as a byte array in an input stream and returning that input stream to whoever wants it (in this case the browserfield) and it renders properly. Of course this isn't an acceptable solution as I need to fetch the page from facebook incase anything changes.

 

Thanks for all your help!

Developer
luisfernando
Posts: 91
Registered: ‎11-24-2009
My Device: Storm

Re: BrowserField rendering problems

Well I made my spanish change to english with this code:

 

 

 requestHeaders.setProperty("Content-Language","en-US");
                    requestHeaders.setProperty("Accept-Language","en-us,en;q=0.5");
                    requestHeaders.setProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7");
 requestHeaders.setProperty("Content-Language","en-US");                    requestHeaders.setProperty("Accept-Language","en-us,en;q=0.5");                    requestHeaders.setProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7");

 

 

Add those values below the line: 

 

requestHeaders.setProperty(REFERER, referrer);

that is aprox on line 198 of the original code.

 

With that you should be able to do it.

 

Please test it and let me know if works for you. If works please post your results and remember to kudos and mark as solved.

 

-Luis Fernando

Remember to give Kudos(click on the star at your left) if this helped you.
Click on "Accept Solution" if the problem is resolved.
Espanol? Escribeme un mensaje privado.
Regular Contributor
anawara
Posts: 64
Registered: ‎04-27-2010
My Device: Bold 9000

Re: BrowserField rendering problems

It worked!! God bless you! This has been making me go in circles since Thursday!

 

I'm kind of new to this so I'm about to ask a rather stupid question but.. whats kudos?

Developer
luisfernando
Posts: 91
Registered: ‎11-24-2009
My Device: Storm

Re: BrowserField rendering problems

At your left hand just below my avatar you will see a star that has a 0, just click on it. Kudos is the way you thanks my help. Please remember to click on options( at your right hand) and mark this as solved.

 

regards

-Luis Fernando

Remember to give Kudos(click on the star at your left) if this helped you.
Click on "Accept Solution" if the problem is resolved.
Espanol? Escribeme un mensaje privado.