0

I'd like to choose the locale from a p:selectOneMenu and resend the page captions rendered according to the new locale. My solution doesn't call the bean valueChangeListener handler (The test log does not appear on the System.out). I have got this error message rendered on the page: "Conversion Error setting value 'hu' for 'null Converter'"

The facelet:

...
<p:selectOneMenu id="localeID" value="#{localeBean.selectedLocale}" valueChangeListener="#{localeBean.onLocaleChanged(event_)}">
<f:selectItems value="#{localeBean.locales}"/>
<p:ajax update="@all"/>
</p:selectOneMenu>
...

The managed bean:

@ManagedBean
@SessionScoped
@Getter
@Setter
public class LocaleBean
{
  private Map<String,Locale> locales;
  private Locale selectedLocale;

  public void onLocaleChanged( ValueChangeEvent event_ )
  {
    System.out.println( "LocaleBean.onLocaleChanged called" );
    ...
  }

@PostConstruct
protected void initLocales()
{
  selectedLocale = facesContextBean.getLocale();
  locales = createLocalesMap();
  locales.put( "English", new Locale( "en" ) );
  locales.put( "Magyar", new Locale( "hu" ) );
}

Could anybody inform me about the reason and give me a solution?

The Bitman
  • 1,279
  • 1
  • 11
  • 25
  • 1
    Reason: You are trying to set non-primitive value in `p:selectOneMenu`. Solution: You need converter. The value in html page is of type `String` and when you submit it you need to convert it into `Locale` object. This should help: http://stackoverflow.com/questions/6848970/how-to-populate-options-of-hselectonemenu-from-database – Geinmachi Feb 14 '16 at 19:36
  • Thx. The rendering run now without any issue. Tell the true I have to change the LocalBean and the selectOneMenu to the correct processing, but now it is OK. – The Bitman Feb 14 '16 at 21:10

0 Answers0