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
Developer
Posts: 45
Registered: ‎08-29-2013
My Device: Blackberry curve-9360 and Blackberry bold-9860
My Carrier: Company

BrowserField displayContent show Blank Screen

Hello,

 

I have used BrowserField to load URL. The URL first show form, When i enter text and submit it, it switches to thanks page.

The browser field always load form page but when i submit the text it sometimes show me white page. I have also try in device browser and it always load url properly.

 

Here is my code :

 

BrowserField browserField = new BrowserField();

add( browserField );

browserField.requestContent( "myURL;interface=wifi" );

 

I also tried with browsetfieldlistener

 

       StreamConnection c = null;
        InputStream s = null;
        byte[] response = null;
        
       
        try {
            c = (StreamConnection)Connector.open("myURL;interface=wifi");
            s = c.openInputStream();

            response = IOUtilities.streamToBytes(s);
            
        
        } catch (Exception e) {
            System.err.println("---error---"+e.getMessage());
        } finally {
            if (s != null)
                try {
                    s.close();
                } catch (IOException e) {
                    System.err.println("---error---"+e.getMessage());
                    e.printStackTrace();
                }
            if (c != null )
                try {
                    c.close();
                } catch (IOException e) {
                    System.err.println("---error---"+e.getMessage());
                    e.printStackTrace();
                }
        }
        String html = new String(response);
        
        System.out.println("----html content---"+html);        
        
         BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
              myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
         myBrowserFieldConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
         
         BrowserField browserField = new BrowserField(myBrowserFieldConfig);
         add(browserField);
         
         BrowserFieldListener bfl = new BrowserFieldListener() {
            
                public void documentLoaded(BrowserField browserField,
                    Document document) throws Exception {

                        super.documentLoaded(browserField, document);
                        // Performing some operation
                    }
                }

            
         };
         browserField.addListener(bfl);
         browserField.displayContent(html, "myURL;interface=wifi");

 

Please suggest me whats the problem

 

Thanks in advance