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

Web and WebWorks Development

Reply
New Developer
furzana
Posts: 4
Registered: ‎12-31-2009

Embedded Browser Ajax support

Hi,

 

I am a new to blackberry application developement. My application uses embedded browser in a blackberry application. But my web page uses ajax. So i get a message saying "Your browser does not support AJAX".  But the same page is working properly in simulator browser. I use BB JDE 5.0. Can anyone help me to sort out this issue?

 

How can i know the version on Embedded browser i use ?

 

Thanks

 

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

Re: Embedded Browser Ajax support

In order to use the same rendering and JavaScript engine that the BlackBerry Browser uses on BlackBerry Operating System 5.0 you must use the new BrowserField class that was introduced:

 

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/browser/field2/BrowserField.ht...

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Developer
furzana
Posts: 4
Registered: ‎12-31-2009

Re: Embedded Browser Cookie support

Hi,

 

I tried to use BrowserField of "net.rim.device.api.browser.field2". This BrowserField displays the page i requested. But i am not able to login in my web page as it sets some cookies. I am getting the same login page again and again. Please find below my code and help me to solve this issue.

 

package com.hclt;

import net.rim.device.api.browser.field2.*;
import net.rim.device.api.io.http.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import java.lang.*;
import java.util.*;

public class BrowserFieldDemo extends UiApplication {
        public static void main(String[] args) {
                BrowserFieldDemo app = new BrowserFieldDemo();
                app.enterEventDispatcher();
        }

        public BrowserFieldDemo() {
                pushScreen(new BrowserFieldDemoScreen());
        }
}

class BrowserFieldDemoScreen extends MainScreen {
        public BrowserFieldDemoScreen() {
                 BrowserFieldConfig config = new BrowserFieldConfig();
                 config.setProperty(BrowserFieldConfig.USER_AGENT, "MyApplication 1.0");
                 config.setProperty(BrowserFieldConfig.ENABLE_COOKIES,Boolean.TRUE);
                 BrowserField myBrowserField = new BrowserField(config);
                 add(myBrowserField);
                 BrowserFieldRequest bfr = new BrowserFieldRequest("http://10.113.41.60/Blackberry.ui/login.aspx");
                 myBrowserField.requestContent(bfr);
        }
}

Please use plain text.
New Developer
rodrifox
Posts: 35
Registered: ‎12-22-2009

Re: Embedded Browser Cookie support

Hi there... have you tried using browserField.getCookieManager() ? There is some docs in BB 5 api (http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/browser/field2/BrowserFieldCoo...)

-------------
Rodrigo Bravo
http://www.wilkonit.com
Please use plain text.
New Developer
furzana
Posts: 4
Registered: ‎12-31-2009

Re: Embedded Browser Cookie support

Hi ,

 

I tried using cookieManager also.

                 BrowserFieldCookieManager cookieManager = myBrowserField.getCookieManager();
                 System.out.println("MobilityAuth:"+cookieManager.getCookie("MobilityAuth"));
                 System.out.println("FormsAuthentication:"+cookieManager.getCookie("FormsAuthentication"));

 

But the output is null only. Actually i think that this code is getting executed when the first login page is loaded. So when i press login button, how can i check the request and response data i got from the server when loading the next page?

 

Thanks

Furzana

Please use plain text.
New Developer
rodrifox
Posts: 35
Registered: ‎12-22-2009

Re: Embedded Browser Cookie support

I don't know how to do this with the 5.0 BrowserField (field2 package) but here is a sample using 4.7 api, class net.rim.device.api.browser.field.Event and implementing RenderingApplication interface:

 

public Object eventOccurred(final Event event) {

 

        int eventId = event.getUID();
        switch (eventId) {

        case Event.EVENT_SET_HTTP_COOKIE :
        String cookie = ((SetHttpCookieEvent) event).getCookie();
        browserField.getCookieManager().setCookie(your_url, cookie);
....

 

}

 

I believe your browser should trigger that set cookie event if there's one.

-------------
Rodrigo Bravo
http://www.wilkonit.com
Please use plain text.