package etf;

import java.io.Serializable;
import java.util.Locale;

import javax.faces.bean.ManagedBean; 
import javax.faces.bean.SessionScoped; 
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;

@ManagedBean(name="form")
@SessionScoped
public class RegisterForm implements Serializable {
   private String ulica;
   private String grad;
   private String regija;
   private String zemlja;

   private static final Locale[] zemlje = { Locale.ROOT, Locale.US, Locale.CANADA};
   public Locale[] getZemlje() { return zemlje; }
   
   public void setUlica(String novaVr) { ulica = novaVr; }
   public String getUlica() { return ulica; }

   public void setGrad(String novaVr) { grad = novaVr; }
   public String getGrad() { return grad; }

   public void setRegija(String novaVr) { regija = novaVr; }
   public String getRegija() { return regija; }

   public void setZemlja(String novaVr) { zemlja = novaVr; }
   public String getZemlja() { return zemlja; }

   public void promena(ValueChangeEvent event) {
      for (Locale loc : zemlje)
         if (loc.getCountry().equals(event.getNewValue()))
            FacesContext.getCurrentInstance().getViewRoot().setLocale(loc);
   }
}