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
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve
My Carrier: compny

How to Abort BrowserField manually

Hello all

 

 How to abort manually browser field so that time I can use this method of Browser field listener

 

any body can give me idea.

 

public void documentAborted(BrowserField browserField, Document document) throws Exception
{
if ((browserField != null) && (document != null))
{
String title = browserField.getDocumentTitle();
String url = document.getBaseURI();
browserField.getErrorHandler().displayContentError(url, "Aborted loading document '" + title + "'");
}
super.documentAborted(browserField, document);
}

 

Thanks .

Please use plain text.
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: How to Abort BrowserField manually

You can use this class :

public class CacheProtocolController extends ProtocolController
{
    //	 The BrowserField instance
    static  BrowserField browserField;

    public CacheProtocolController(BrowserField browserField) 
    {
        super(browserField);
        this.browserField = browserField;
    }


    /**
     * Handle navigation requests (e.g., link clicks)
     */	
    public void handleNavigationRequest(final BrowserFieldRequest request) throws Exception 
    {
    	try 
    	{    	
    		final InputConnection ic = handleResourceRequest(request);
    		if(ic!=null)
    		{	
    			UiApplication.getUiApplication().invokeLater(new Runnable() 
    			{	
    				public void run() 
    				{
    					try
    	    			{
    	    				browserField.displayContent(ic, request.getURL());
    	    			}
    	    			catch (Exception e) 
    	    			{
    	    				logFile.log("DisplayContent Exception :---> " + e.toString());
    					}
					}
				});
    		}
    	} 
    	catch (Exception e) 
    	{ 
    	       
    	}
    }
    /**
     * Handle resource request 
     * (e.g., images, external css/javascript resources)
     */
    public InputConnection handleResourceRequest(BrowserFieldRequest request) 
        throws Exception 
    {  
    	
        return super.handleResourceRequest(request);
    }
}

 and if you want to abort page on button click call it in below way :

browserField.getConfig().setProperty(BrowserFieldConfig.CONTROLLER,new CacheProtocolController(null));

 and also use this before where you are declaring your browser field like below:

BrowserField browserField = new BrowserField();
browserField.getConfig().setProperty(BrowserFieldConfig.CONTROLLER,new CacheProtocolController(browserField));
add(browserField);

 using this you can stop your page...
 Good Luck

 

Hit Like if you found your answer

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Abort BrowserField manually

I am not sure how this code helps - how can you interrupt a request?.

 

In case you actually want to understand what this code does, I suggest you look at the KB article from which this appears to have been extracted:

http://supportforums.blackberry.com/t5/Java-Development/How-to-Implement-a-Web-Cache-for-Your-Browse...

Please use plain text.