*/
package org.mxchange.jjobs.beans.country;
-import java.util.Iterator;
-import java.util.List;
import java.util.Objects;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
+import javax.faces.FacesException;
import javax.inject.Inject;
import javax.inject.Named;
import org.mxchange.jcountry.events.added.AdminAddedCountryEvent;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jcountry.model.data.CountryData;
import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.country.list.JobsCountryListWebViewController;
/**
* An administrative country bean
*/
private String countryCode;
- /**
- * Regular country controller
- */
- @Inject
- private JobsCountryWebRequestController countryController;
-
/**
* Local dial prefix
*/
*/
private Boolean countryIsLocalPrefixRequired;
+ /**
+ * Regular country controller
+ */
+ @Inject
+ private JobsCountryListWebViewController countryListController;
+
/**
* Phone code
*/
// Does it already exist?
if (this.isCountryAdded(country)) {
// Yes, then abort here
- throw new FaceletException(new CountryAlreadyAddedException(country));
+ throw new FacesException(new CountryAlreadyAddedException(country));
}
// Init variable
updatedCountry = this.adminCountryBean.addCountry(country);
} catch (final CountryAlreadyAddedException ex) {
// Throw again
- throw new FaceletException(ex);
+ throw new FacesException(ex);
}
// Fire event
// Default is not found
boolean isAdded = false;
- // Now get whole ist
- final List<Country> countries = this.countryController.allCountries();
-
- // Get iterator from it
- final Iterator<Country> iterator = countries.iterator();
-
// Check whole list
- while (iterator.hasNext()) {
- // Get next country
- final Country next = iterator.next();
-
+ for (final Country currentCountry : this.countryListController.getAllCountries()) {
// Is country code or i18n the same?
- if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nKey(), next.getCountryI18nKey()))) {
+ if ((Objects.equals(country.getCountryCode(), currentCountry.getCountryCode())) || (Objects.equals(country.getCountryI18nKey(), currentCountry.getCountryI18nKey()))) {
// Yes, then abort search
isAdded = true;
break;