X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fjjobs%2Fbeans%2Fcountry%2FJobsCountryWebApplicationBean.java;h=f2f15c02ca776551ede273b3666851e296215b2c;hb=9af5f7e8b841b05862cf025f64df8d4bab116583;hp=a39e2251afcedeca9e765f207c5ef2ce411bf37b;hpb=b989b49c06fef5d68554c867ae50f5b3bbaaf79b;p=jjobs-war.git diff --git a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java index a39e2251..f2f15c02 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsCountryWebApplicationBean.java @@ -16,10 +16,12 @@ */ package org.mxchange.jjobs.beans.country; +import java.text.MessageFormat; import java.util.Collections; import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; import javax.naming.Context; @@ -27,15 +29,17 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcountry.data.Country; import org.mxchange.jcountry.data.CountrySingletonBeanRemote; +import org.mxchange.jcountry.events.AdminAddedCountryEvent; +import org.mxchange.jjobs.beans.BaseJobsController; /** * A country bean *

* @author Roland Haeder */ -@Named ("country") +@Named ("countryController") @ApplicationScoped -public class JobsCountryWebApplicationBean implements JobsCountryWebApplicationController { +public class JobsCountryWebApplicationBean extends BaseJobsController implements JobsCountryWebApplicationController { /** * Serial number @@ -69,12 +73,38 @@ public class JobsCountryWebApplicationBean implements JobsCountryWebApplicationC } } + @Override + public void afterAdminAddedCountry (@Observes final AdminAddedCountryEvent event) { + // Is all valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getAddedCountry() == null) { + // Throw again ... + throw new NullPointerException("event.addedCountry is null"); //NOI18N + } else if (event.getAddedCountry().getCountryId() == null) { + // And again ... + throw new NullPointerException("event.addedCountry.countryId is null"); //NOI18N + } else if (event.getAddedCountry().getCountryId() < 1) { + // Id is invalid + throw new IllegalArgumentException(MessageFormat.format("event.addedCountry.countryId={0} is not valid.", event.getAddedCountry().getCountryId())); //NOI18N + } + + // Add the event + this.countryList.add(event.getAddedCountry()); + } + @Override public List allCountries () { // Return "cached" version return Collections.unmodifiableList(this.countryList); } + @Override + public boolean hasCountries () { + return (!this.countryList.isEmpty()); + } + /** * Post-initialization of this class */