invoke the url from the menu

Hello.  I need help, try to understand this.

I want to be able to go to a different location when you click a menu option.  I used the BrowserFieldSampleApplication sample that comes with the JDE and want to raise him.  Basically, the vehicle has currently the feature to display the browser has filed in the main screen.  So I want to add to the addition of adding a menu item and calling another url when this menu is click, but it does not work.  The code is below.  This essential element of this code is that sample application that came with the JDE, I didn't add the menu.

When I do:

Thread PrimaryResourceFetchThread = new PrimaryResourceFetchThread ("http://www.hotmail.com", null, null, null, this); THIS ME GIVE A COMPILATION ERROR, BUT I CAN'T UNDERSTAND WHY?

Thread PrimaryResourceFetchThread = new PrimaryResourceFetchThread ("http://www.google.com", null, null, null, new MyButtonListener()); IT DOES NOT DISPLAY THE PAGE

MyMenu MenuItem = new MenuItem ("Go to Hotmail", 1.1)
{
public void run()
{
Dialog.Alert ("display of the Hotmail Page");
          
Thread PrimaryResourceFetchThread = new PrimaryResourceFetchThread ("http://www.hotmail.com", null, null, null, this); THIS DISPLAYS A COMPILATION ERROR--> WHY COMPILATION ERROR HERE I CAN'T UNDERSTAND.
Thread PrimaryResourceFetchThread = new PrimaryResourceFetchThread ("http://www.google.com", null, null, null, new MyButtonListener()); IT DOES NOT DISPLAY THE PAGE
thread. Start();
}
};

class TestMe extends UiApplication{
    public static void main(String[] args)
    {
        TestMe buttonListener = new TestMe();
        buttonListener.enterEventDispatcher();
    }

    TestMe() {
        pushScreen(new MyButtonListener());

    }
} 

class MyButtonListener extends MainScreen implements RenderingApplication
{
    private static final String REFERER = "referer";   

    private RenderingSession _renderingSession;
    private HttpConnection  _currentConnection;

    public MyButtonListener()
    {
        _renderingSession = RenderingSession.getNewInstance();
        PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread("http://www.google.com", null, null, null, this);
        thread.start();
    }

    MenuItem myMenu = new MenuItem("Go to Hotmail", 1,1)
    {
        public void run()
        {
            Dialog.alert("Displaying Hotmail Page");

           // PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread("http://www.hotmail.com", null, null, null, this); //THIS IS GIVING ME A COMPILING ERROR
            PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread("http://www.google.com", null, null, null, new MyButtonListener()); //THIS ISN'T DISPLAYING THE PAGE
            thread.start();
        }

    };

    protected void makeMenu(Menu menu, int instance)
    {
        menu.add(myMenu);
    }    

    public boolean onClose()
    {
        Dialog.alert("You are about to close this app");
        return true;
    }

    // Process Connection Class
    public void processConnection(HttpConnection connection, Event e)
    {
        // Cancel previous request.
        if (_currentConnection != null)
        {
            try
            {
                _currentConnection.close();
            }
            catch (IOException e1)
            {
            }
        }

        _currentConnection = connection;

        BrowserContent browserContent = null;

        try
        {
            browserContent = _renderingSession.getBrowserContent(connection, this, e);

            if (browserContent != null)
            {
                Field field = browserContent.getDisplayableContent();

                if (field != null)
                {
                    synchronized (Application.getEventLock())
                    {
                        //_mainScreen.deleteAll();
                        deleteAll();
                        //_mainScreen.add(field);
                        add(field);
                    }
                }

                browserContent.finishLoading();
            }

        }
        catch (RenderingException re)
        {
        }
        finally
        {
            SecondaryResourceFetchThread.doneAddingImages();
        }

    }    

    /**
     * @see net.rim.device.api.browser.RenderingApplication#eventOccurred(net.rim.device.api.browser.Event)
     */
    public Object eventOccurred(Event event)
    {
        int eventId = event.getUID();

        switch (eventId)
        {
            case Event.EVENT_URL_REQUESTED :
            {
                UrlRequestedEvent urlRequestedEvent = (UrlRequestedEvent) event;
                String absoluteUrl = urlRequestedEvent.getURL();

                HttpConnection conn = null;

                System.out.println("Lcle: you requested" + absoluteUrl);

                PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread(urlRequestedEvent.getURL(),
                                                                                         urlRequestedEvent.getHeaders(),
                                                                                         urlRequestedEvent.getPostData(),
                                                                                         event, this);
                thread.start();

                break;

            }
            case Event.EVENT_BROWSER_CONTENT_CHANGED:
            {
                // Browser field title might have changed update title.
                BrowserContentChangedEvent browserContentChangedEvent = (BrowserContentChangedEvent) event; 

                if (browserContentChangedEvent.getSource() instanceof BrowserContent)
                {
                    BrowserContent browserField = (BrowserContent) browserContentChangedEvent.getSource();
                    String newTitle = browserField.getTitle();
                    if (newTitle != null)
                    {
                        /*synchronized (getAppEventLock())
                        {
                            //_mainScreen.setTitle(newTitle);
                            setTitle(newTitle);
                        }*/

                    }
                }                   

                break;                

            }
            case Event.EVENT_REDIRECT :
            {
                RedirectEvent e = (RedirectEvent) event;
                String referrer = e.getSourceURL();

                switch (e.getType())
                {
                    case RedirectEvent.TYPE_SINGLE_FRAME_REDIRECT :
                        // Show redirect message.
                        Application.getApplication().invokeAndWait(new Runnable()
                        {
                            public void run()
                            {
                                Status.show("You are being redirected to a different page...");
                            }
                        });

                    break;

                    case RedirectEvent.TYPE_JAVASCRIPT &colon
                        break;

                    case RedirectEvent.TYPE_META :
                        // MSIE and Mozilla don't send a Referer for META Refresh.
                        referrer = null;
                        break;

                    case RedirectEvent.TYPE_300_REDIRECT :
                        // MSIE, Mozilla, and Opera all send the original
                        // request's Referer as the Referer for the new
                        // request.
                        Object eventSource = e.getSource();
                        if (eventSource instanceof HttpConnection)
                        {
                            referrer = ((HttpConnection)eventSource).getRequestProperty(REFERER);
                        }

                        break;
                    }

                    HttpHeaders requestHeaders = new HttpHeaders();
                    requestHeaders.setProperty(REFERER, referrer);
                    PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread(e.getLocation(), requestHeaders,null, event, this);
                    thread.start();
                    break;

            }
            case Event.EVENT_CLOSE :
                // TODO: close the appication
                break;

            case Event.EVENT_SET_HEADER :        // No cache support.
            case Event.EVENT_SET_HTTP_COOKIE :   // No cookie support.
            case Event.EVENT_HISTORY :           // No history support.
            case Event.EVENT_EXECUTING_SCRIPT :  // No progress bar is supported.
            case Event.EVENT_FULL_WINDOW :       // No full window support.
            case Event.EVENT_STOP :              // No stop loading support.
            default :
        }

        return null;
    }

    /**
     * @see net.rim.device.api.browser.RenderingApplication#getAvailableHeight(net.rim.device.api.browser.BrowserContent)
     */
    public int getAvailableHeight(BrowserContent browserField)
    {
        // Field has full screen.
        return Display.getHeight();
    }

    /**
     * @see net.rim.device.api.browser.RenderingApplication#getAvailableWidth(net.rim.device.api.browser.BrowserContent)
     */
    public int getAvailableWidth(BrowserContent browserField)
    {
        // Field has full screen.
        return Display.getWidth();
    }

    /**
     * @see net.rim.device.api.browser.RenderingApplication#getHistoryPosition(net.rim.device.api.browser.BrowserContent)
     */
    public int getHistoryPosition(BrowserContent browserField)
    {
        // No history support.
        return 0;
    }

    /**
     * @see net.rim.device.api.browser.RenderingApplication#getHTTPCookie(java.lang.String)
     */
    public String getHTTPCookie(String url)
    {
        // No cookie support.
        return null;
    }

    /**
     * @see net.rim.device.api.browser.RenderingApplication#getResource(net.rim.device.api.browser.RequestedResource,
     *      net.rim.device.api.browser.BrowserContent)
     */
    public HttpConnection getResource( RequestedResource resource, BrowserContent referrer)
    {
        if (resource == null)
        {
            return null;
        }

        // Check if this is cache-only request.
        if (resource.isCacheOnly())
        {
            // No cache support.
            return null;
        }

        String url = resource.getUrl();

        if (url == null)
        {
            return null;
        }

        // If referrer is null we must return the connection.
        if (referrer == null)
        {
            HttpConnection connection = Utilities.makeConnection(resource.getUrl(), resource.getRequestHeaders(), null);

            return connection;

        }
        else
        {
            // If referrer is provided we can set up the connection on a separate thread.
            SecondaryResourceFetchThread.enqueue(resource, referrer);
        }

        return null;
    }

    /**
     * @see net.rim.device.api.browser.RenderingApplication#invokeRunnable(java.lang.Runnable)
     */
    public void invokeRunnable(Runnable runnable)
    {
        (new Thread(runnable)).start();
    }

}    

class PrimaryResourceFetchThread extends Thread
{
    private MyButtonListener _application;
    private Event _event;
    private byte[] _postData;
    private HttpHeaders _requestHeaders;
    private String _url;

    PrimaryResourceFetchThread(String url, HttpHeaders requestHeaders, byte[] postData,
                                  Event event, MyButtonListener application)
    {
        _url = url;
        _requestHeaders = requestHeaders;
        _postData = postData;
        _application = application;
        _event = event;
    }

    public void run()
    {
        HttpConnection connection = Utilities.makeConnection(_url, _requestHeaders, _postData);
        _application.processConnection(connection, _event);
    }
}

Hello

I'm not quite sure, but post your compiler error that would help.

The key word is perhaps not MyButtonListener instance?

Kind regards

Jochen

Tags: BlackBerry Developers

Similar Questions

  • When I run my script from a shortcut ExtendScript is invoked, but this isn't when I run the menu

    I use Photshop CS2 on Win XP

    I set up a keyboard shortcut (Ctrl + Alt + P) to execute a .jsx file in the folder... \Presets\Scripts\.

    When I activate the script via the keyboard shortcut ExtendScript is called and interrupts execution on main() statement (see below).

    When I activate the script via the menu file/Scripts that extendscript is not called and the script runs up to the end.

    The .jsx file is a wrapper for a .vbs script that does the 'real' work

    The .jsx is:-

    main() function
    {
    var VBSscript = file ("C:/Program Files/Adobe/Adobe Photoshop CS2/Presets/Scripts/GGN_PS_Code_v1_2.vbs");
    If (VBSscript.Exists) VBSscript.execute ();
    }
    main();

    Anyone have any ideas on how to disable the invocation of ExtendScript when I run the script from the skortcut?

    One thing to check is that the .jsx extension is associated with Photoshop and not ExtendScript.

  • I changed my url to white now, I can't find the Favorites or the menu bar of the browser, pls can someone tell me how to restore to the original url parameter?

    I tried to remove thumbnails of Firefox & advice line went to browser.newtab.url and changed to 'white', now when I open Firefox from the menu with bookmarks etc bar is missing, but when I opened a new tab thumbnails are still there, I don't have a lot of experience & would appreciate some advice on how to restore. I tried to restore the computer to an earlier time, but that does not restore the url from the browser to the State before you start playing with it. Help, please!

    Make sure that you run not Firefox mode full screen (press F11 or Fn + F11 to toggle; Mac: Command + SHIFT + F).

    If you are in full screen view then hover over with the mouse to the top of the screen to facilitate the bar appear Navigation and tab bar.
    Click the expand (in the top right Navigation bar) to exit full screen or right-click on a space empty on a toolbar and select "exit full screen" or press the F11 key.

    You can use one of them to set toolbars to display.

    • Firefox '3-bar' menu button > customize > show/hide toolbars
    • View > toolbars
      Press the ALT key, or press F10 to display the Menu bar
    • Right click on empty toolbar space

    What is the current value of the browser.newtab.url pref?

    If you do not keep the changes after a reboot or have problems with preferences, see:

    You can create a new Boolean pref on the on: page config to prevent the generation of thumbnails for Firefox the subject: newtab page.

    • name: browser.pagethumbnails.capturing_disabled value: true

    Delete the folder of thumbnails in the Firefox profile folder to remove the thumbnails already memorized web page.

  • Typing a wrong URL in the URL from Firefox 31.0 bar redirects me to us.yhs4 yahoo com search that displays the LAVASOFT logo. It is not the case with any of my

    Typing a wrong URL in the URL from Firefox 31.0 bar redirects me to us.yhs4 yahoo com search that displays the LAVASOFT logo. It is not the case with any of my other browsers (IE, Chrome, Opera, Safari). So this cannot be a problem ISP as shown in all current references to Firefox.
    This problem started after I uninstalled adaware from LAVASOFT. It itself instead of uninstall. Thus, it is malware behavior while LAVASOFT is pretending to protect against malware.
    Nevertheless, I would like to know how to get rid of this annoying 404 redirect hijack. My home page is about to startpage com, my default search engine is startpage com, all references to Lavasoft and adaware have been removed by subject: config and Windows registry...
    How to get rid of this spam redirect, please?

    Click Tools > Options, then general tab

    In the home page box, type the url you want to fire fox opens by default when you start the browser.

    KhalidXpert

  • I need to print from firefox icon as I used, because some pages that I need to print do not load with the menu.

    Since a recent automatic update, I was not able to print by clicking on the firefox tab icon. I have pages that I need to print, that do not load with the toolbar complete with the key of menu etc. I could always print by clicking on the icon, but no more. Help please.

    you could try pressing and use 'ctrl' then 'P' on your keyboard
    We also write 'ctrl + P', it's the printing system wide combination of shortcut keys.

    Alternatively, you can try, right-click in the title bar (where your loading tabs) and selecting 'Menu Bar', which will show the menu bar (with file, editing, display, etc.) on the tabs allowing you to print from the submenu file

    hope that helps!

    See you soon

  • Cannot restart, logoff or closed using 10.11.5. Cabins Finder; disappears from the menu bar, the dock still operational.

    I can't log off, restart or stop my MBP. Disappears from the menu bar, desktop files disappear, but dock is still operational. The only way is to force a stop down with the power button. Only a recent problem within the last week or 2. El Capitan updated in similar delays, could it be linked?

    MBP retina, 13-inch, mid-2014; Intel Core i5 at 2.8 GHz. 8 GB 1600 MHz; 8 GB RAM

    A Wacom tablet driver is installed on the MBP? In this case, you can try to uninstall or to verify that an update is available.

  • What is the URL from where I can download 10 Firefox for Mac?

    I can't use Firefox 11 for Mac because it does not yet support an add-on I need security. So, I want to go down to 10 Firefox for Mac in 32-bit and 64-bit versions.

    However, I could not find the URL from where I can download these two versions of Firefox for Mac 10. Yes, I tried to put several keywords in the search field: 'Download' 'downgrade' etc. 'Firefox' "previous versions". I still couldn't locate the URL.

    Would you be kind enough to send me the URL?

    I found my own answer. This answer works for all versions of Firefox, not only for version 10, not only for the Mac.

    The URL is ftp://ftp.mozilla.org/pub/mozilla.org.../releases/. From this URL, you then navigate to the directory (aka subfolder) for the version you want to download.

    Of course, you need to know how to download from an FTP: / / URL.

  • In Firefox v4.0.1, custom toolbars disappear from the menu of the toolbar when I open a 'new window '.

    1.
    I created a new toolbar in customize... / Add the new toolbar. It is on the list of the toolbars and opens upwards most of the time I start Firefox, but not always. I tested it and it is completely random.

    2.
    Same type of problem as 1., but whenever I use the function "New window" disappears from the custom toolbar in the menu of the toolbar, and if I need to use it, I have to Save all tabs bookmark and then close and reopen FireFox if I get my original window [where the toolbar]. AARRRGHH.

    I use FF for 7 years now, so I know enough to rule out corrupt localstore.rdf, new or updated modules updated (I could be wrong, but as I am often...).
    It comes back with other users? I am cursed? [lol] any help would be appreciated.

    See:

  • When I type or paste a URL into the address bar or select a url from the address bar dropdow, the "enter" button does nothing. I have to press the green arrow to load the url?

    Each time it manually to enter a url, past a url, or select a url from the address bar, the system requires that I click on the green arrow to go to the url. The entrance to key doe nothing. Am I the only one having this problem?

    This problem may be caused by an extension (possibly AVG Safe Search) which does not work properly.

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions of the origin of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

    If this does not work in mode without failure, then disable all extensions and then try to find out who is the cause by allowing both the problem reappears.

    • Choose "Disable all add-ons" on issues to troubleshoot Firefox in Safe Mode to set window to disable all extensions.
    • Close and restart Firefox after each change through "file > exit ' (Mac: ' Firefox > leave";) Linux: "file > exit ')

    In Firefox 4, you can use one of them to start in the questions to troubleshoot Firefox in Safe Mode:

    • Help > restart with disabled modules
    • Hold down the SHIFT key while double-clicking the shortcut from the desktop Firefox (Windows)
  • I can open a new browser window, but not a new tab, or by clicking on the sign more or select it from the menu. I have completely updated to firefox and also rebooted. What is going on?

    I can open a new browser window, but not a new tab, or by clicking on the sign more or select it from the menu. I have completely updated to firefox and also rebooted. What is going on?

    Try to disable or uninstall the extension "Ask Toolbar".

  • I can't remove a url from the address bar.

    After completely clearing on my history, cache and cookies, a single Web site remains when I down the address bar. If I mouse over it and press DELETE, it will disappear until I re - click the arrow of the menu drop down and it shows up again. It does not appear when I put the address bar to display only the bookmarks in the menu options, but it is there when I put to only show that history. Also, if I click on the url, I am unable to bookmark this particular site by clicking on the star either using the bookmarks menu (not sure if this is related). Thanks for any help.

    Operating system

    Vista

    places.SQLite could have been corrupted.

    Since it sounds like you already emptied, try to locate and rename/delete places.sqlite in your profile folder.

  • Router disappeared from the menu at the top of the right page, cant connect...

    On my PPC G5 my router suddenly disappeared from the menu at the top right.
    I made the mistake of accidentally click on BTWIFI-with-FON (which also appears in the list) and since then all except BTWIFI-with-FON has disappeared from the list.

    I tried unpugging my router for 2 minutes and restart my Mac, but nothing helped.

    My laptop is however always recognizing the router and able to connect to the internet.

    PPC G5 dual 2.3

    10.4.11

    Laptop:

    10.9.5

    Solved by rebooting router Mac was on.

  • My speakers on my Dell Latitude D820 suddenly emit only a low sound. I adjusted all the volume controls in the menu sounds from the Control Panel, and there is no change in volume.

    Low sound volume

    My speakers on my Dell Latitude D820 suddenly emit only a low sound. I adjusted all the volume controls in the menu sounds from the Control Panel, and there is no change in volume. It's real power radio on the internet and play music from a CD inserted into my machine. The sound icon does not appear in the toolbar.  I tried the fixit of automatic Wndows and it ran and said low volume has been set. Not the case.

    Hello

    1. what operating system do you use?

    2 did you change on your computer?

    Method 1:

    I suggest you follow the link and check.

    No sound in Windows

    http://Windows.Microsoft.com/en-us/Windows/help/no-sound-in-Windows?T1=tab02

    Method 2:

    I suggest to follow the link and search for the volume in the taskbar.

    (a) right click on an empty area of the taskbar and then click Properties.

    (b) in the Notification area, click Customize.

    (c) select the volume see the icons and taskbar notifications check box, and then click OK.

    I also suggest you to follow the link and check.

    Change icons appear in the notification area

    http://Windows.Microsoft.com/en-us/Windows7/change-how-icons-appear-in-the-notification-area

  • Uninstalled game still displayed in the menu "Uninstall/Change Program." Directory of the game deleted as well. How do I completely remove it from the system?

    I uninstalled a game, and for good measure, I also deleted the game program files directory. Nothing is left... However, I find one more persistent "title game" in the menu "Uninstall/Change Program." How do I remove it completely?

    -TACANDEL

    I would try using the Windows Installer Cleanup utility, which can be downloaded from Microsoft: http://support.microsoft.com/kb/290301. To install the tool, download and run as administrator.   Then, you must run the tool by clicking Start, typing Windows Installer Clean Up in the search field and clicking on the enter key.   Select the item you want to delete in the menu program uninstall/change, and then click Remove.    Click OK in the confirmation window.  It should work pretty quickly. Click on exit to close the tool.

    To learn more about this utility, read this article: http://en.wikipedia.org/wiki/Windows_Installer_CleanUp_Utility.

    Barbara

  • Windows xp: voice recorder has disappeared from the menu

    I have Windows XP Pro. PK 3 and sometimes there are many accessories disappeared from the menu.

    One of them was the recorder of the word in the entertainment Menu.  This moment's Real Player just about that.

    Anyone know how I can reinstall the recorder tool?

    Thank you.

    The shortcut is just... may be missing if the app is available
    the following command should launch.

    Try the following steps...

    Reach... Start / run and type or copy / paste the following text:

    SNDREC32

    Press ENTER.

    Also... Movie Maker allows to save... it's called the narrative but
    It will save whatever it is and it is not limited to 60 seconds
    like WinXP Sound Recorder.

Maybe you are looking for

  • How update macOS Sierra beta to final version?

    I've been running the "golden master" final beta pre release of macOS Sierra 10.12 for about a week with no problems. I'll be able to upgrade to the official version of 10.12 today (September 20) in the usual way via the Mac App Store? Or is there an

  • HP Pavilion p6604f: upgrade to a semi gaming computer

    Operaring system: Windows 7 64-bit Processor: AMD Athlon II X 2 220; 2.8 clocked GHz Memory: 6 GB Video graphics card: using ATI Radeon 4200 integrated graphics HDD: 750 GB Computer case: height: 38.7 cm (15.23 inches), width: 17.5 cm (6.89 in), leng

  • Satellite C660/C660D - screen background image does not

    Satellite C660/C660D: Try to load any image from any source fails, the message error "an internal error has occurred." I tried all procedures in the Panel; none allow a change of background image, although the colors can always be changed, as well as

  • Bad connection WiFi on my Portege R930-15E

    Hello I have a strange problem on my R930 which I tried to solve already for several months, but could not succeed. As I recently replaced the WLAN router and the problem remained to the laptop, I know now that it's really the Toshiba which hurts. Qu

  • New user Local via GPO - password field grey Out.

    I use all the 2012 R2 server group policy computer, when I try to reset the local administrator of windows domain controller password, the password field is dimmed. how it highlighted? Help, please...