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
Posts: 70
Registered: ‎12-19-2011
My Device: Bold 9780
My Carrier: Airtel

Need to open Browser field with post method hit

HI all,

 

i need to open a webpage in browserfield by post hit.I need to send some data with url.How to do that.

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Need to open Browser field with post method hit

Which platform and language? Best to ask in that specific form (eg AIR, Java, NDK, Cascade, Webworks).
Regular Contributor
Posts: 70
Registered: ‎12-19-2011
My Device: Bold 9780
My Carrier: Airtel

Re: Need to open Browser field with post method hit

Blackberry smartPhone

language java

Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Need to open Browser field with post method hit

Hi,

 

Check this :

 

	public static void openBrowser(String url, String contentType, 
			Object objBody ) { 

		final HttpHeaders requestHeaders = new HttpHeaders();
		requestHeaders.addProperty(HttpHeaders.HEADER_CONTENT_TYPE, contentType);

		final URLEncodedPostData postData = 
			new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);
		postData.setData(objBody);
		BrowserSession browserSession = Browser.getDefaultSession();
		browserSession.displayPage(url, null, requestHeaders, postData);
		browserSession.showBrowser();
	}

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Highlighted
Regular Contributor
Posts: 70
Registered: ‎12-19-2011
My Device: Bold 9780
My Carrier: Airtel

Re: Need to open Browser field with post method hit

Hi 

 

I have open webpage successfully by post method below is my code

 

final HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.addProperty(
HttpHeaders.HEADER_CONTENT_TYPE,
HttpHeaders.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED
);

final URLEncodedPostData postData =
new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);

postData.append("key", "value");


BrowserSession browserSession = Browser.getDefaultSession();
browserSession.displayPage("MYURL",
null, requestHeaders, postData);
browserSession.showBrowser();

 

 

 

But i need to open this page in browser field.I tried like this

 

BrowserField bf = new BrowserField();
add(bf);
Hashtable table = new Hashtable();
table.put(HttpHeaders.HEADER_CONTENT_TYPE,
HttpHeaders.CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
String temp = "key1=value1&key2=value2&key3=value";
bf.requestContent("MYURL", temp
.getBytes(), null);

 

 

it gives time out error.