Search code examples
blackberryonclickbrowserfield

Blackberry 5.0 - BrowserField handle link clicked


I am trying to handle an event in BrowserField when the user actually clicks a link. I studied BrowserFieldListener, tried its documentCreated() method but that gives me a response when the page starts loading. I want a trigger the moment user clicks a link inside browserField.

What am i missing here?


Solution

  • Override handleNavigationRequest() of ProtocolController like

    ProtocolController controller = new ProtocolController(browserField) {
        public void handleNavigationRequest(BrowserFieldRequest request) throws Exception {
             /* 
             Here you get the redirection link using 
               request.getURL() 
             and do what you want to do 
              */
          // to display url in browserfield use
          InputConnection inputConnection = handleResourceRequest(request);
          browserField.displayContent(inputConnection, request.getURL()); 
    
        }
    };
    
    browserField.getConfig().setProperty(BrowserFieldConfig.CONTROLLER, controller);