package org.mxchange.jjobs.beans.phone;
import java.text.MessageFormat;
+import java.util.Objects;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
/**
* Administrative bean (controller) for phone numbers
@Any
private Event<AdminUpdatedCellphoneNumberEvent> cellPhoneNumberUpdatedEvent;
+ /**
+ * Cell phone provider
+ */
+ private MobileProvider cellphoneProvider;
+
/**
* Fax number
*/
*/
private DialableLandLineNumber landLine;
+ /**
+ * Phone number
+ */
+ private Long phoneNumber;
+
/**
* Default constructor
*/
} else if (this.getCellPhoneNumber().getPhoneNumber() < 1) {
// Throw NPE again
throw new NullPointerException(MessageFormat.format("this.cellphoneNumber.phoneNumber={0} is not valid.", this.getCellPhoneNumber().getPhoneNumber())); //NOI18N
+ } else if (this.getCellphoneProvider() == null) {
+ // Not provided
+ this.showFacesMessage("form_edit_cellphone:cellphoneProvider", "No mobile provider selected"); //NOI18N
+ return ""; //NOI18N
+ } else if (this.getCellphoneProvider().getProviderId() == null) {
+ // Throw NPE again ...
+ throw new NullPointerException("this.cellphoneProvider.providerId is null"); //NOI18N
+ } else if (this.getCellphoneProvider().getProviderId() < 0) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("this.cellphoneProvider.providerId={0} is not valid.", this.getCellphoneProvider().getProviderId())); //NOI18N
+ } else if (this.getPhoneNumber() == null) {
+ // Not provided
+ this.showFacesMessage("form_edit_cellphone:cellphoneNumber", "No cell phone number selected"); //NOI18N
+ return ""; //NOI18N
}
+ // Is the mobile provider and number the same?
+ if ((Objects.equals(this.getCellphoneProvider(), this.getCellPhoneNumber().getCellphoneProvider())) && (Objects.equals(this.getPhoneNumber(), this.getCellPhoneNumber().getPhoneNumber()))) {
+ // No difference in both together, no need to edit
+ return ""; //NOI18N
+ }
+
+ // Set all data
+ this.getCellPhoneNumber().setCellphoneProvider(this.getCellphoneProvider());
+ this.getCellPhoneNumber().setPhoneNumber(this.getPhoneNumber());
+
// Send to bean
DialableCellphoneNumber updatedNumber = this.adminPhoneBean.updateCellphoneData(this.getCellPhoneNumber());
this.cellPhoneNumber = cellPhoneNumber;
}
+ @Override
+ public MobileProvider getCellphoneProvider () {
+ return this.cellphoneProvider;
+ }
+
+ @Override
+ public void setCellphoneProvider (final MobileProvider cellphoneProvider) {
+ this.cellphoneProvider = cellphoneProvider;
+ }
+
@Override
public DialableFaxNumber getFax () {
return this.fax;
this.landLine = landLine;
}
+ @Override
+ public Long getPhoneNumber () {
+ return this.phoneNumber;
+ }
+
+ @Override
+ public void setPhoneNumber (final Long phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
}
import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
/**
* An interface for a request web controller (bean) for administrative phone
*/
DialableFaxNumber getFax ();
+ /**
+ * Getter for cell phone provider
+ * <p>
+ * @return Cell phone provider
+ */
+ MobileProvider getCellphoneProvider ();
+
+ /**
+ * Setter for cell phone provider
+ * <p>
+ * @param cellphoneProvider Cell phone provider
+ */
+ void setCellphoneProvider (final MobileProvider cellphoneProvider);
+
+ /**
+ * Getter for dial number without prefix
+ * <p>
+ * @return Dial number without prefix
+ */
+ Long getPhoneNumber ();
+
+ /**
+ * Setter for dial number without prefix
+ * <p>
+ * @param phoneNumber Dial number without prefix
+ */
+ void setPhoneNumber (final Long phoneNumber);
+
}
</div>
<div class="table_right_medium">
- <h:selectOneMenu styleClass="select" id="cellphoneProvider" value="#{adminPhoneController.cellPhoneNumber.cellphoneProvider}">
+ <h:selectOneMenu styleClass="select" id="cellphoneProvider" value="#{adminPhoneController.cellphoneProvider}" required="true" requiredMessage="#{msg.ADMIN_MOBILE_PROVIDER_REQUIRED}">
<f:converter converterId="MobileProviderConverter" />
<f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems value="#{mobileProviderController.allMobileProvider()}" var="mobileProvider" itemValue="#{mobileProvider}" itemLabel="#{mobileProvider.providerCountry.countryExternalDialPrefix}#{mobileProvider.providerDialPrefix} (#{mobileProvider.providerName})" />
</div>
<div class="table_right_medium">
- <h:inputText styleClass="input" id="cellphoneNumber" size="10" maxlength="20" value="#{adminPhoneController.cellPhoneNumber.phoneNumber}">
+ <h:inputText styleClass="input" id="cellphoneNumber" size="10" maxlength="20" value="#{adminPhoneController.phoneNumber}" required="true" requiredMessage="#{msg.ADMIN_CELLPHONE_NUMBER_REQUIRED}">
<f:validator for="cellphoneNumber" validatorId="PhoneNumberValidator" />
</h:inputText>
</div>