tags:

views:

29

answers:

1

Hello,

I've deployed on Tomcat 6.0.29 on Mac OS X 10.5.8 a simple internationalized 2.0.4 GWT application using Eclipse (equivalent to HelloGWT sample) which has a drop-down list to get the locales and replace the url depending on the choice.

It works fine when in development mode, either in Firefox or Safari.

When deployed to Tomcat, in Safari, the application has all its functionalities but the spinned wheel in the url field runs continuously as soon as the mouse pointer leaves the url field.

In Firefox 3.6.10, on the other hand, there is no such behaviour but it opens directly the greet dialog box where the user-agent etc are shown, as though there would have been a click on the button.

In both case, I cannot see where is the problem.

Here is the code I use to change the url:

languageBox.addChangeHandler(new ChangeHandler() {
    @Override
    public void onChange(ChangeEvent event) {
        String languageName = languageBox.getValue(languageBox.getSelectedIndex());
        UrlBuilder builder = Location.createUrlBuilder().setParameter("locale", languageName);
        Window.Location.replace(builder.buildString());
    }
});

Is there something I do wrong in here?

Thanks in advance for any hint.

Additional information

I use a simplePanel to wrap the list box so that I can then center it and the title of the application together. I wonder if it can be a problem on Safari:

RootPanel.get("applicationName").add(new Label(constants.helloGWT()));
...
// Here comes the definition of languageBox
...
final SimplePanel languagePanel = new SimplePanel();
    languagePanel.add(languageBox);
    languagePanel.addStyleName("languagePanel");
    RootPanel.get("languagePanelContainer").add(languagePanel);

And then in the html page I have:

<div align="center">
    <h1 id="applicationName"></h1>
    <div id="languagePanelContainer"></div>
</div>

Any idea where I make an error here?

Thanks in advance for any answer.

A: 

This simple example just works fine for me:

    public void onModuleLoad() {
        final ListBox languageBox = new ListBox(false);
        languageBox.addItem("en");
        languageBox.addItem("de");
        languageBox.addItem("fr");

        languageBox.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {
                String languageName = languageBox.getValue(languageBox.getSelectedIndex());
                UrlBuilder url = Window.Location.createUrlBuilder().setParameter("locale", languageName);
                Window.Location.replace(url.buildString());
            }
        });

        RootPanel.get().add(languageBox);
    }

Does this work for you?

z00bs
The fact to change: Location to Window.Location in the handler solves the problem with Firefox. This way the user name field gets the focus as excepted. But it still remains the problem with Safari where the wheel spins in the url field.
Michèle Garoche
Does your code work correctly in development mode? It all works fine for me.
z00bs
Actually, I had to change Window.Location to Location in both lines, since otherwise Safari shows nothing. Apparently to solve the problem in Safari one should first test if the select has changed, but it is not possible without trigering the handler.
Michèle Garoche