public String save() { Country country = this.locationMBean.getCountry(); if (country != null) { this.city.setCountry(country); } Province province = this.locationMBean.getProvince(); if (province != null) { this.city.setProvince(province); } cityBean.save(this.city); return "cities?faces-redirect=true"; }
@PostConstruct public void load() { if (this.id != null && !this.id.isEmpty()) { this.city = cityBean.find(id); locationMBean.initialize(); if (this.city.getCountry() != null) { locationMBean.setSelectedCountry(this.city.getCountry().getAcronym()); } if (this.city.getProvince() != null) { locationMBean.setSelectedProvince(this.city.getProvince().getId()); } } }
public List<City> getCities() { if (this.cities == null) { this.cities = cityBean.findAll(); } return this.cities; }
public String remove() { cityBean.remove(city.getId()); return "cities?faces-redirect=true"; }