package com.fibiler.book.jsf;
import java.util.Locale;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
@ManagedBean(name="helloLocaleBean")
public class HelloLocaleBean {
public boolean isLocaleTr(){
System.out.println(FacesContext.getCurrentInstance().getViewRoot().
getLocale().getLanguage());
if (FacesContext.getCurrentInstance().getViewRoot().
getLocale().getLanguage().equals("tr")){
return true;
}
return false;
}
public void changeEn(ActionEvent event){
FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
}
public void changeTr(ActionEvent event){
FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale("tr"));
}
}
Dosyayı İndir