Hi, I'm trying to implement a page containing a form and some links that allow the user to change the current locale.
Unlike the example at http://www.wicket-library.com/wicket-examples/forminput/ I do not want the form values to be reset when the user changes the locale. The first thing I tried was SubmitLinks where I changed the locale in the onSubmit method. This had that the problem that if there was a validation error, the locale would not be changed. So then what I did was to call setDefaultFormProcessing(false) on the SubmitLinks. This all seemed to work until I noticed a rather subtle bug. One of the fields on the form was a Float. Let's say I entered a value of 3000 into this field and submitted the form. Suppose the current locale was English. Now the value would be displayed as "3,000". Now suppose I change the language to Dutch. The display value would remain "3,000". Now when I submit the form the model is updated to 3.0, because the decimal point in the Dutch locale is a comma and not a period. With my third attempt I used a SubmitLink that looks like the following: mainForm.add(new SubmitLink("nl") { @Override public void onSubmit() { getMainForm().process(); setLanguage("nl"); } }.setDefaultFormProcessing(false)); So, I bypass default form processing so that I can set the locale regardless of whether the form validated or not. So the user can change locale even if there are validation errors. It also means that the model is updated before the locate is changed, so I don't have the float conversion problem I described above. I still have a problem though. The problem is that if there are validation errors, then they are displayed using the old language and not the new language the user has just changed to. For example if the user changes from English to Dutch and there is a validation error, the error will be displayed in English, while the rest of the page is rendered in Dutch. Does anyone know how I can fix this? I think the problem is that the validation error message string is resolved when the validation error is added to the component. If it were resolved just before the page was rendered I think my code would work. Ian. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
