Browser Window Opener - for Application Help implementation

Hi,

Requirement:

  1. I want to iplement HELP functinality for my application.
  2. I want to open ‘Browser Window’ with specific URL which depends on Service trype present in Native Select UI compoenent.
  3. When user selects particular service say ‘ABC’ relavant help page (e.g. http://www.applicationhelp.com#ABC) should open in new Browser Window

My code looks like following:

//Class for application help

public class ApplicationHelp extends Button
{
public ApplicationHelp(String helpURL)
{
  System.out.println("helpURL = "+helpURL);
BrowserWindowOpener windowOpener = new BrowserWindowOpener(helpURL);
windowOpener.setFeatures("height=400,width=600,resizable");
//Setting window name so that same browser window is maintained for multiple clicks on button
windowOpener.setWindowName("APPLICATION_HELP");

this.setCaption("Help")
windowOpener.extend(this);
}
}
//Application clas in which i am utilizing help functinality
Class Application
{
String baseHelpURL = "http://www.applicationhelp.com"
ApplicationHelp applicationHelp = new ApplicationHelp(baseHelpURL);

//some code

//for value change of native select
String selectedService = serviceNativeSelect.getValue().toString();
applicationHelp = new ApplicationHelp(baseHelpURL.concat("#").concat(selectedService));

//some code
}

Following the issue:

  1. When no service is selcted:
    Browser window openes with the baseHelpURL

  2. When some service is selcted from native select:
    I see change in helpURL through ‘System.out.println("helpURL = "+helpURL);’
    However browser window still shows the baseHelpURL page

Can you please suggesst something to fix this.

Regards,
Kunal Patil

Did you remember to remove the old ApplicationHelp button from the UI and replace it with the new one? It isn’t enough to change the applicationHelp variable to refer to a new instance; the original is still referred to by the component hierarchy due to how Java variables work. You could replace the button every time like this:

    ApplicationHelp newHelp = new ApplicationHelp(baseHelpURL.concat("#").concat(selectedService));
    applicationHelp.getParent().replaceComponent(applicationHelp, newHelp);
    applicationHelp = newHelp;

However, a better way is probably be to keep the button and only replace the BrowserWindowOpener extension:

public class ApplicationHelp extends Button  {
    // Store the BrowserWindowOpener in a field
    private BrowserWindowOpener windowOpener;

    public ApplicationHelp(String helpURL) {
        setCaption("Help");
        setHelpURL(helpURL);
    }

    // ...
    public void setHelpURL(String helpURL) {
        if(windowOpener != null) {
            // remove the old opener if any
            windowOpener.remove();
        }
        windowOpener = new BrowserWindowOpener(helpURL);
        windowOpener.setFeatures("height=400,width=600,resizable");
        //Setting window name so that same browser window is maintained for multiple clicks on button
        windowOpener.setWindowName("APPLICATION_HELP");
        windowOpener.extend(this);
    }
}

Even better would be to simply change the URL in the BrowserWindowOpener. Unfortunately, this is not currently supported, but
a ticket
exists.

Thanks for the helpful comments.
Issue solved by replacing the BrowserWindowOpener extension.

Thanks!!! This save my weeks !!!
Regads