Srcoll in BrowserField
Hi guys,.
I am now using browserField to open a URL and display a bird's-eye view. I found that I can only scroll up and down but not left to right. What I do in such situation? Is he related to set some attributes in BrowserFieldConfig?
Try like this:
public class LoadingScreen extends MainScreen implements FieldChangeListener { private ButtonField click; private String url; private BrowserField browserField; private VerticalFieldManager vertical; public LoadingScreen() { url="http://www.google.com/news/"; createGUI(); } private void createGUI() { click=new ButtonField("click"); click.setFont(StartUp.font); click.setChangeListener(this); add(click); vertical=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR|HORIZONTAL_SCROLL|HORIZONTAL_SCROLLBAR); browserField=new BrowserField(); vertical.add(browserField); add(vertical); } public void fieldChanged(Field field, int context) { if(click==field) { browserField.requestContent(url); delete(click); } } protected boolean onSavePrompt() { return true; } public boolean onMenu(int instance) { return false; } }
Tags: BlackBerry Developers
Similar Questions
-
Browserfield generates the internal server error
Hello
I've implemented an example usage of the guide on this link and its working quite right, but then I saw something. If I click on a link within the browserfield to a non html resource, say mp3 for example http://site.com/file.mp3 or the server redirects or a survey non - response to the browserfield html, I get an internal server error.
I tried the same in the native browser and everything works fine.
So I think, it is possible to intercept a request when the user clicks on a link and open the native browser instead when a particular url scheme is detected?
In addition, im having trouble changing the user-agent the browserfield, here is what Ive wrote
===========
BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty (BrowserFieldConfig.VIEWPORT_WIDTH, New Integer (Display.getWidth ()));
config.setProperty (BrowserFieldConfig.INITIAL_SCALE, new Float (1.0));
config.setProperty (BrowserFieldConfig.USER_SCALABLE, Boolean.FALSE);
config.setProperty (BrowserFieldConfig.ENABLE_COOKIES, Boolean.TRUE);
config.setProperty (BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
config.setProperty (BrowserFieldConfig.NAVIGATION_MODE, BrowserFieldConfig.NAVIGATION_MODE_POINTER);
config.setProperty (BrowserFieldConfig.USER_AGENT, "MyCustomUAString");BrowserField browserField = new BrowserField (config);
==============
Also, I would also like to be able to hide the Progress bar when the browserfield does not load any page, so that it shows only when it is needed (IE when a link is clicked)
Thank you
A code example. If you can't understand what it is supposed to do, please ask. Put shaped went squiffy, sorry about that.
BTW, I really struggle to test BrowserField treatment on simulators, they seem flaky and sometimes I can't debug. The one I usually use is actually a 5.0 OS simulator 9300.
/ public final class BrowserFieldScreen extends screen
implements BrowserFieldConnectionManager {}
Private BrowserField _bf2;
Private BrowserFieldConnectionManager standardBFConnectionManager;
public BrowserFieldScreen() {}
Super();
_bf2 = new BrowserField();
This.Add (_bf2);
our ConnectinManager hook
standardBFConnectionManager = _bf2.getConnectionManager ();
BrowserFieldConfig bfconfig = _bf2.getConfig ();
bfconfig.setProperty (BrowserFieldConfig.CONNECTION_MANAGER, this);
_bf2.requestContent ("http://www.google.co.uk");
}
Implementation of the BrowserFieldConnectionManager
public InputConnection makeRequest (application BrowserFieldRequest) {}
String requestURL = request.getURL ();
System.out.println ("request:" + requestURL);
Boolean toBrowser = false;
If {(requestURL.endsWith ("mp3"))
toBrowser = true;
}
If (requestURL.indexOf ("bbc.co.uk") > 0) {}
toBrowser = true;
}
If {(toBrowser)
Private browserSess = Browser.getDefaultSession ();
If (! requestURL.startsWith ("http")) {}
requestURL = "http://" + requestURL;
}
browserSess.displayPage (requestURL);
String codehtmla =
"
" +"
View in browser
" +"";
return new BrowserFieldResponse (requestURL, htmlToDisplay.getBytes (), HttpProtocolConstants.CONTENT_TYPE_TEXT_HTML);
}
try {}
Return standardBFConnectionManager.makeRequest (request);
} catch (Exception e) {}
System.out.println ("Exception:" + try ());
}
String codehtmla =
"
" +"
Exception
" +"";
return new BrowserFieldResponse (requestURL, htmlToDisplay.getBytes (), HttpProtocolConstants.CONTENT_TYPE_TEXT_HTML);
}
BackMenuItem MenuItem = new MenuItem ("Back", 110, 10) {}
public void run() {}
_bf2. Back();
}
};
ForwardMenuItem MenuItem = new MenuItem {("Forward", 110, 10)
public void run() {}
_bf2. Forward();
}
};
protected void makeMenu (menu Menu, for example int) {}
If (_bf2.getHistory () .canGoBack ()) {}
menu. Add (backMenuItem);
menu.setDefault (backMenuItem);
}
If (_bf2.getHistory () .canGoForward ()) {}
menu. Add (forwardMenuItem);
menu.setDefault (forwardMenuItem);
}
}
}
-
Why BrowserField demo does not use BrowserField?
I had some problems getting the BrowserField object to display all images on a page. When you search the formus, it was suggested to use the BrowserFieldDemo included in JDE for example. I tried and it works, but the back button does not work and you can not click on one of the links. Then I discovered that it does not actually use a BrowserField object as in
net.rim.device.api.browser.field2.BrowserField
Does anyone know how to make the browserField to work... WITH a functional back button and no image broken?
I'd appreciate all point in the right direction.
In fact, I realized that BrowserField demo uses OS 4.0 components while the BrowserField object is only OS 5.
-
BrowserField BlackBerry: How to get the value of the existing cookie
Hello
First of all, I want to let you know that I have to create a Web page at www.mydomain.com/whois.html
then I put a cookie with javascript named 'user name = adrian' on this page
In my Aplication BB I declare browserfield to load "whois.html".
Here is the code
Import net.rim.device.api.browser.field2.BrowserFieldCookieManager;
Import net.rim.device.api.browser.field2.BrowserFieldConfig;
Import net.rim.device.api.browser.field2.BrowserField;
Import net.rim.device.api.ui.component.Dialog;
Import net.rim.device.api.ui.container.MainScreen;/ public final class BrowserDemoScreen extends screen
{
public BrowserDemoScreen()
{
setTitle ("BrowserFieldScreen");BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty (BrowserFieldConfig.USER_AGENT, ' MyApplication 1.0 "');
BrowserField _bf2 = new BrowserField (config);_bf2.requestContent ("http://www.mydomain.com/whois.html");
Cookie String = _bf2.getCookieManager ().getCookie("__http://www.mydomain.com__").valueOf ("username");Dialog.Alert ("Cookie1 value =" + cookie);
Add (_bf2);
}
}and if I run the code it does not get the "username" value, what's wrong with my code? Thank you
Aaah... I have the cookie Manager to mydomain.com/whois.html instead of mydomain.com it prints all the information in "Add (new RichTextField (existingCookie));"
-
Browserfield, with cookies
If anyone could be kind enough to download an implementation of the browserfield with cookies enabled. I have a little trouble with it.
Thanks in advance
You can find an example here:
Enable cookies under BrowserField
http://supportforums.BlackBerry.com/T5/Java-development/enable-cookies-in-BrowserField/Ta-p/445032
-
BlackBerry JRE 5.0.0 BrowserField has no ScriptEngine
Hello
Ive got a BrowserField:
BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty (BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
This.Browser = new BrowserField (config);which returns the null value on:
this.browser.getScriptEngine ();
Prevents me to run scripts from the code Java, because browser.executeScript ("somejavascript"); throws IllegalStateException which States that there is no such thing as the ScriptEngine. Which is kinda funny, because when I load JQuery its able to compile the script and the BrowserFieldDebugger tell me, that JSON is not defined. Which is exactly why I want to run a script inside the Java code from in the first place. Well, I need to call javascript functions later as well so I would have needed this feature in one way or another. BTW. : browser.displayContent (' javascript : somejavascript ", someurl" ") seems to generate a kind of error page.
Test on a 9700, build against BlackBerry JRE 5.0.0
ID like to have this app running next Thursday, a quick (and useful) answer would be appreciated (if you need more information, ask away).
Thanks in advance.
Sorry not an area of expertise, but I have some thoughts.
Copy the following code
invokeLater (new Runnable() {public void run() {}
thing to run
(}, 500, flag);
you continue to repeat if the flag is true initially (it is not re-evaluated). So I think you really want to code something like:
Runnable testScriptEngine = new Runnable() {}
public void run() {}
ScriptEngine scriptEngine = mdBrowserField.getScriptEngine ();
If (scriptEngine == null) {}
invokeLater (this, 500, false);
} else {}
Dialog.Alert ("found Script engine");
}
};
invokeLater (testScriptEngine, 500, false);
If I was looking for something that could be triggered when the browserField 'worked', I would look at the method documentLoaded() of the BrowserField listener:
I'm guessing it is significant above using a Script engine, so I can see a reason to not create a Script engine up until you need it - so it does not surprise me that one is not created in BrowserField instantiation.
-
The images are not display with html content in browserfield
Hi friends, I am display local html content in the browserfield. It is are display fine but pictures are not display is also local resources stored in the project. I use jde 5.0. Whats to display pictures.
After so much, I solved it and the images are displayed correctly. I had the habit now of base64 class and image data are passed to the base64 format.
-
BlackBerry BrowserField: The Application crashes while downloading.
Hi, I use browserfield2 in my application to load Web pages, now the problem is the application is always unexpected crashes while downloading, no problem to download the file with size < 500kb="" but="" if="" the="" file="" has=""> = 1 mb size it will crash, the strange thing is I can get download process finished with the construction in the Blackberry browser, hmm... any guy of solution? Thanks in advance
Here is the code
public BrowserDemoScreen()
{
setTitle ("BrowserFieldScreen");
BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty (BrowserFieldConfig.USER_AGENT, ' MyApplication 1.0 "');
BrowserField _bf2 = new BrowserField (config);
_bf2 = new BrowserField();
_bf2.requestContent ("http://mydomain/upload.php");
Add (_bf2);
}HTML form
php code
<>
$uploaddir = '. / uploads /';
$filename = $_FILES ['uploadfile'] ['name'];
$filesize = $_FILES ['uploadfile'] ['size'];
$filetemp = $_FILES ['uploadfile'] ['tmp_name'];
$file = $uploaddir. baseName($_files['uploadfile']['name']);echo $filename. »
";
echo $filesize. »
";
echo $filetemp;If (move_uploaded_file ($filetemp, $file))
{
echo "success."
}
on the other
{
echo "error";
}
?>as you can see that I did not use any javascript on this page, it's pure php, which makes the BrowserField crash?
The solution is:
public class resignation against UiApplication
{
public Resignation()
{
If (filesize > = 1 MB)
Dialog.Alert ("use your personal desktop computer to download selected file!");
on the other
Dialog.Alert ("good boy, now, you understand that we have maximum file download size limit");
Close();
}
}
-
BrowserField fails to open a local resource within the PIMListListener
Hello
I have a problem with the opening of the resources of regional settings through BrowserField inside the PIMListListener implementation.
My local resources is an html element placed on ROOT_PROJECT/res/test.html
I opened it to principal in UIApplication and it works fine. Howevwe, I instantiated my PIMListListener which manages caledar event, when my PIMListListener is awake performed copy the following code:
UiApplication.getUiApplication () .pushScreen (new TestView());
Here he code of the manufacturer of the display:
_Config BrowserFieldConfig = new BrowserFieldConfig ();
BrowserField _bf2 = new BrowserField (_config);
Add (_bf2);
_bf2.requestContent("local:///test.html");After the insertion of the PIMListListener calendar events call display class (screen), but the result is an empty view with this error message:
...
Applicant content of error for:
local:///test.html
Error: resource does not exist
....
the same operation done very well in the principal works of the application!
Any ideas?
Thank you
You must requestForeground in your app - that's what I meant by putting you in the foreground:
requestForeground();
I think need you immediately after the pushScreen (_screen);
I see no reason why you need a Thread.sleep and I urge you to remove it. At this point in your application that you run on the thread of events, so a sleep blocks.
-
Hello! Please, help me! I spent almost all day, but have had no success. My BrouserField is showing '? ' characters instead of the non-English characters.
I need to get the Ribbon XML, analyze and display in the BrowserFiled.
I use these classes:(1) WaitScreen - PopupScreen from the example of knowledge base
public class WaitScreen extends PopupScreen { private LabelField _ourLabelField = null; private WaitScreen(String text) { super(new HorizontalFieldManager()); VerticalFieldManager _vfm = new VerticalFieldManager(); _ourLabelField = new LabelField(text, Field.FIELD_HCENTER); _vfm.add(_ourLabelField); this.add(_vfm); this.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.BLACK, 225)); } public static void showScreenAndWait(final Runnable runThis, String text) { final WaitScreen thisScreen = new WaitScreen(text); Thread threadToRun = new Thread() { public void run() { // First, Waintdisplay this screen UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { UiApplication.getUiApplication().pushScreen(thisScreen); } }); // Now run the code that must be executed in the Background try { runThis.run(); } catch (Throwable t) { t.printStackTrace(); throw new RuntimeException("Exception detected while waiting: " + t.toString()); } // Now dismiss this screen UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { UiApplication.getUiApplication().popScreen(thisScreen); } }); } }; threadToRun.start(); } }
(2) RSSHandler - class auxiliary for analysis
public class RSSHandler extends DefaultHandler { boolean isItem = false; boolean isTitle = false; boolean isLink = false; boolean isDescription = false; boolean isPubDate = false; boolean isGuid = false; public String[] title = new String[] {}; public String[] link = new String[] {}; public String[] description = new String[] {}; public String[] pubDate = new String[] {}; public String[] guid = new String[] {}; String value = ""; public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if (!isItem) { if (name.equalsIgnoreCase("item")) isItem = true; } else { if (name.equalsIgnoreCase("title")) isTitle = true; if (name.equalsIgnoreCase("link")) isLink = true; if (name.equalsIgnoreCase("description")) isDescription = true; if (name.equalsIgnoreCase("pubDate")) isPubDate = true; if (name.equalsIgnoreCase("guid")) isGuid = true; } } public void characters(char[] ch, int start, int length) throws SAXException { if (isTitle || isLink || isDescription || isPubDate || isGuid) value = value.concat(new String(ch, start, length)); } public void endElement(String uri, String localName, String name) throws SAXException { if (isItem && name.equalsIgnoreCase("item")) isItem = false; if (isTitle && name.equalsIgnoreCase("title")) { isTitle = false; Arrays.add(title, value); value = ""; } if (isLink && name.equalsIgnoreCase("link")) { isLink = false; Arrays.add(link, value); value = ""; } if (isDescription && name.equalsIgnoreCase("description")) { isDescription = false; Arrays.add(description, value); value = ""; } if (isPubDate && name.equalsIgnoreCase("pubDate")) { isPubDate = false; Arrays.add(pubDate, value); value = ""; } if (isGuid && name.equalsIgnoreCase("guid")) { isGuid = false; Arrays.add(guid, value); value = ""; } } }
(3) CaptionScreen (screen with BrowserField I need to show the result of the XML parsing)
public class CaptionScreen extends MyMainScreen { private BrowserField _browserField; public CaptionScreen(Application app, String section) { //.... GetArticles getArticles = new GetArticles("http://" + _urlWithArticles, _browserField); WaitScreen.showScreenAndWait(getArticles, "LOADING"); } static class GetArticles implements Runnable { String _url = null; BrowserField _resultBrowser; public GetArticles(String urlToGet, BrowserField resultBrowser) { this._url = urlToGet; this._resultBrowser = resultBrowser; } public void run() { // Try to download new articles and parse the answer HttpConnection httpConn = null; InputStream is = null; RSSHandler rssHandler = new RSSHandler(); try { httpConn = GetConnection(_url); is = httpConn.openInputStream(); try { SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); parser.parse(is, rssHandler); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } catch (IOException ioe) { } catch (Exception e) { } finally { try { if ( httpConn != null ) { httpConn.close(); } } catch (Exception e) { } httpConn = null; } final String htmlArticles = generateHtml(rssHandler); UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { _resultBrowser.displayContent(htmlArticles, ""); } }); } // Method for html generation to showing in BrowserField private String generateHtml(RSSHandler rssHandler) { String result = ""; if(rssHandler == null) { return result; } result += "
News "; for(int i = 0; i < rssHandler.title.length; i++) { result += rssHandler.title[i] + "
" + "LINK
" + rssHandler.description[i] + " "; } result += ""; return result; } private HttpConnection GetConnection(String _url) throws IOException { if (DeviceInfo.isSimulator()) { _url = _url + ";deviceSide=true"; } MyConnFact _myConnFact = new MyConnFact(); HttpConnection _httpConn = null; ConnectionDescriptor _connDesc = _myConnFact.getConnection(_url); if (_connDesc != null) { _httpConn = (HttpConnection)_connDesc.getConnection(); } return _httpConn; } } }It works very well (showing WaitScreeen, data download), but all characters not English shows as '?'
I found a few discussions with the same problem (especially this one)and this one
but I don't understand, how and where do I I implemented HttpConnection in my code.
Please, give me advice or tell, how I change my code to solve this problem? -
Browserfield invalid XMLHttpRequest
I am launching a javascript inside a BrowserField ajax request.
Here is a demo application, it's just an html element that is trying to perform an ajax request when the click on.
public MyScreen() { // Set the displayed title of the screen setTitle("MyTitle"); BrowserFieldConfig _myBrowserFieldConfig = new BrowserFieldConfig(); _myBrowserFieldConfig.setProperty( BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE); _myBrowserFieldConfig.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE); BrowserField browser = new BrowserField(_myBrowserFieldConfig); browser.displayContent( "" + "" + "
AJAX
Request data", "http://www.w3schools.com"); add(browser); }The problem is that even the first alert does not, so there should be a javascript syntax error, but well, everything looks good to me. I tried this code in Firefox on my computer, and alerts are displayed (I know cross-domain is not always possible). So, what is the error in my script?
I tested on the Simulator with BB 5.0.0 and 7.0.0.
I find the solution.
What is the problem, is to use an absolute url to open the XMLHttpRequest. Use a url relativie (demo_get.asp) and the browserfield must have correctly set baseurl (http://www.w3schools.com/ajax/).
It's very embarrassing.
-
Hello
I'm developing an application (for version 5.0) for a page Web in a browserfield I self-paced successfully but it takes the Web page fit to the screen it seems as compressed. I need to view this Web page with the actual width and height of the webpage... Currently I am add browserfield vertical Manager and give vertical scrolling for the Manager... Now, I want to display the web page as its width and its original height...
You get my point? If not please free to ask...
Can someone explain to me how to display the webpage in real width and height in the browerfield
The following code snippet shows how to set the width of the window you want and the value of the initial scale...
config = new BrowserFieldConfig();
config.setProperty (BrowserFieldConfig.VIEWPORT_WIDTH, whole (new)
(Display.getWidth ()));
config.setProperty (BrowserFieldConfig.INITIAL_SCALE, new Float (1.0));config.setProperty (BrowserFieldConfig.USER_SCALABLE, Boolean.FALSE);
browserField = new BrowserField (config);
The USER_SCALABLE prevents the user to change the zoom. You can or don't want according to your code.
VIEWPORT_WIDTH sets the width you want to see. In our application, limit us the width of the screen and do not allow for scaling.
-
BrowserField - open links in the current browser?
Hey guys, wondering if one can help me out or give a little guidance on this issue.
I have a local html string that I displays on a screen inside a BrowserField object, and I want to do is have any link in the field you click to open the link inside a real browsing session. I looked through the API for a method to substitute that manages links, but saw no one, even if I just missed it. Any suggestions?
Thank you
Kyle
Hey guys,.
I know this thread has been inactive for a while, but I found the solution so I thought id post her if someone else hasn't the same question.
BrowserFieldConfig bfc = new BrowserFieldConfig(); bfc.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_CARET); bfc.setProperty(BrowserFieldConfig.CONTROLLER, new BrowserFieldController(){ public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception { return (InputConnection)Connector.open(request.getURL()); } public void handleNavigationRequest(BrowserFieldRequest request) throws Exception { BrowserSession b = Browser.getDefaultSession(); b.displayPage(request.getURL()); } }); bf = new BrowserField(bfc);
-
How to set a cookie on browserfield
I hv retrieves a connection http cookie, will be identified, but now I want this cookie must be passed with the request in browserfield, but how can I do? while I managed to the same session through connection
Please help me as soon as possible...
solved my self... using the method requestContent (url, postdata, hashtable)
-
URGENT! BrowserField is very slow
I'm noticing that BrowserField is too slow. When I have the same Web site in the browser, and then its quick opening and mode loading Web taking too much time.
VerticalFieldManager Manager = new VerticalFieldManager (VerticalFieldManager.VERTICAL_SCROLL);
BrowserField browserField = new BrowserField();
browserField.requestContent ("http://www.domesticviolenceuk.org/find-support-near-you");
Manager.Add (browserField);
Add (Manager);Please help why its kind.
Thanks in advance
nothing you can do about it.
Maybe you are looking for
-
How to get better graphics performance on my Satellite C850?
Hello. I have a problem with my * Toshiba Satellite C850-B253 * and the problem is chart, in my PC when I run "* PES 2013 *" the game warned for me even my * GPU * is not insignificant and is very low to open this program. Please give me a number gam
-
Question about module memory for Satellite M100-222
Can someone please give me accurate information on a module of memory I need for above mentioned laptop. I would like to know if it is only good Transcend brand for above mentioned laptop or I also use another brand of memory, with the same specifica
-
iCloud account stopped working in post after the last update to El Capitan 10.11.2
Since the update to El Capitan 10.12.1, iCloud stopped sync properly on the Server mail account in Apple Mail. It can receive new messages when first opening the app, but it would stop working after that. He would not receive any new messages, would
-
issue tear the player 11 Windows Media - tracks have the end of the previous song.
I seem to have bad ripper CD - when I select all the tracks and then click Start rip. They rip ok and have the correct names etc. However when I play the tracks a few of them have a minutes from the end of the previous track before then playing the s
-
I have a gateway lap top that gave me and it has windows vista. I train download XP Pro, but when I press on enter, after starting from the cd, he says he is not any hard drive & to check if it is enabled. If it can mean my hard drive is not good? I