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
New Contributor
Posts: 7
Registered: ‎03-03-2010
My Device: None
My Carrier: None

BrowserContentManager and HTMLBrowserField

Hi guys,

 

I'm new to BlackBerry development, and I'm developing an application that has a screen with an embeded browser. I could find out all the information I needed to build the app, but now I'm stuck.

 

In my application, when the user access a specific URL, I want to fill one form field automatically. Handling the EVENT_URL_REQUESTED I know that the user requested that specific URL, and then, after loading the URL I'm trying to use the BrowserContentManager to get the fields.

 

The problem is the following:

 

browserContentManager.getFieldCount() returns 1, and

browserContentManager.getField(0) returns a Field

 

Through debbuging I found out that it is an instance of HTMLBrowserField (net.rim.device.apps.internal.browser.html.HTMLBrowserField). And also through debbuging I found out that inside this HTMLBrowserField, there are many fields, including a HTMLTextInputField (that contains a RigidManager that contains a BrowserEditField), that is the one I want to set.

 

The problem is that all these classes are not included in the API, and seems to be loaded in runtime or something like that. Is there a way to use those objects somehow? Can I use those classes from package net.rim.device.apps.internal.browser.html.* ? Where are them?

 

I'm using Eclipse as IDE, with the BlackBerry plugin, that basically uses the net_rim_api.jar in the build path. And just for information, I'm using the JDE 4.6 with the 9000 simulator, but I need my app running in all Blackberry devices (or the most possible number of devices).

 

Any information/thoughts are appreciated!

 

Thanks in advance,

Diego

New Contributor
Posts: 7
Registered: ‎03-03-2010
My Device: None
My Carrier: None

Re: BrowserContentManager and HTMLBrowserField

Guys, please help me!

 

Anyone has any ideas if I can use classes from package net.rim.device.apps.internal.browser.html.* somehow or how to accomplish what I want to do (accessing/modifying a form field inside the "embeded browser") in some other way?

 

Thanks!

Developer
Posts: 499
Registered: ‎06-24-2008
My Device: Not Specified

Re: BrowserContentManager and HTMLBrowserField

Trying to use undocumented internal APIs probably isnt a great idea, not least since they're liable to be changed at any moment.

 

And while some of the API's may well be accessible, I doubt there's any documentation.

 

But since you're using 4.6 couldn't you achieve the same effect using javascript + DOM Events or similar?

 

If you want the function for earlier OS versions I guess you're out of luck (as am I).

 

But if you're capturing browser events, and you clearly know which URI was selected, why not take responsibility for the get/post yourself and inject values into the url/stream.

New Contributor
Posts: 7
Registered: ‎03-03-2010
My Device: None
My Carrier: None

Re: BrowserContentManager and HTMLBrowserField

[ Edited ]

First of all, thank you very much for replying br14.

 

Regarding injecting values directly on post, I did this, but there is two main downsides with this solution:

- I need to know, as you mentioned, the URI.

- There is no feedback (for the user) regarding what is happening.

 

To help you understanding my problem (and especially my second point), think as an example in an application that have a password saved which the goal of saving time avoiding the need for the user to type the password in websites.

If the password insertion would be directly in the post, basically the user would have to click the Login button without filling the password field in the form (what is a bit wierd/not user friendly). What I would want than is to have, for example, a menu item "insert my password" that would fill the field for me. But to make that possible I would need to parse/change the page contents... Another possible solution would be to directly submit the form, manipulating the post data, when the user selects this menu option. But the problem is that I would also need to parse the page to find out which is the link to submit that form (or somehow "simulate" the click in the submit button (that I don't know where it is located in the website).

 

Regarding your first proposal, javascript + DOM Events, can I run any java script in any webpage (I mean, can I "inject" some javascript prior to run it) or does the javascript needs to be in the page already? And in any case, how can I call javascript methods using the blackberry API 4.6?

 

Thanks again!

Diego

Contributor
Posts: 13
Registered: ‎06-18-2009
My Device: Not Specified

Re: BrowserContentManager and HTMLBrowserField

Hi Guys,

 

I am also stuck at the same position where i would like to execute a certain javascript based upon some external events (may be user events or some external device inputs).

 

If any of you guys knows a solution or a pointer to the solution will be of great help.

 

thanks

dcdel

Highlighted
Contributor
Posts: 13
Registered: ‎06-18-2009
My Device: Not Specified

Re: BrowserContentManager and HTMLBrowserField

till the blackberry version 4.7 its not possible to inject the java script in to page after loading, but since BB version 5.0 its been enhanced to support the JS injection with help of the API provided in BrowserField2 class i.e. (executeScript(String script)) its very usefull try it once.