From: Roland Häder Date: Tue, 9 Aug 2016 15:06:06 +0000 (+0200) Subject: Continued with cellphone number edit: (please cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=af7961acbf9a6a446d26749fac6744b50403d211;p=jjobs-war.git Continued with cellphone number edit: (please cherry-pick) - no, the data cannot be set in the object, it needs to be set in controller (backing bean, don't forget this) - made both fields required - if nothing has changed, nothing needs to be updated (check both, mobile provider and number) - added missing i18n strings - renamed form id form_edit_phone -> form_edit_cellphone --- diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java index 5099a0d8..ee62859a 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java @@ -17,6 +17,7 @@ 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; @@ -33,6 +34,7 @@ import org.mxchange.jphone.events.updated.AdminUpdatedCellphoneNumberEvent; 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 @@ -65,6 +67,11 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements @Any private Event cellPhoneNumberUpdatedEvent; + /** + * Cell phone provider + */ + private MobileProvider cellphoneProvider; + /** * Fax number */ @@ -75,6 +82,11 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements */ private DialableLandLineNumber landLine; + /** + * Phone number + */ + private Long phoneNumber; + /** * Default constructor */ @@ -119,8 +131,32 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements } 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()); @@ -141,6 +177,16 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements 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; @@ -161,4 +207,14 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements this.landLine = landLine; } + @Override + public Long getPhoneNumber () { + return this.phoneNumber; + } + + @Override + public void setPhoneNumber (final Long phoneNumber) { + this.phoneNumber = phoneNumber; + } + } diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java index bb24e007..b2e1d8ce 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java @@ -21,6 +21,7 @@ import javax.ejb.Local; 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 @@ -80,4 +81,32 @@ public interface JobsAdminPhoneWebRequestController extends Serializable { */ DialableFaxNumber getFax (); + /** + * Getter for cell phone provider + *

+ * @return Cell phone provider + */ + MobileProvider getCellphoneProvider (); + + /** + * Setter for cell phone provider + *

+ * @param cellphoneProvider Cell phone provider + */ + void setCellphoneProvider (final MobileProvider cellphoneProvider); + + /** + * Getter for dial number without prefix + *

+ * @return Dial number without prefix + */ + Long getPhoneNumber (); + + /** + * Setter for dial number without prefix + *

+ * @param phoneNumber Dial number without prefix + */ + void setPhoneNumber (final Long phoneNumber); + } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 9dbeddc1..fc8aeaf9 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -614,3 +614,5 @@ ADMIN_LINK_LOCK_USER=Benutzeraccount sperren ADMIN_LINK_LOCK_USER_TITLE=Sperren von freigeschalteten Benutzeraccounts, mit Angabe eines Sperrgrundes. ADMIN_CELLPHONE_DATA_LEGEND_TITLE=Mobilfunknummer und -anbieter ab\u00e4ndern. ERROR_CANNOT_LOCK_USER_ACCOUNT_UNCONFIRMED=Fehler: Kann das Benutzerkonto nicht sperren, da es noch nicht best\u00e4tigt ist. +ADMIN_MOBILE_PROVIDER_REQUIRED=Bitte einen Mobilfunkanbieter ausw\u00e4hlen. +ADMIN_CELLPHONE_NUMBER_REQUIRED=Bitte Mobilfunknummer angeben. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index a205cee2..df788677 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -614,3 +614,5 @@ ADMIN_LINK_LOCK_USER=Lock user account ADMIN_LINK_LOCK_USER_TITLE=Locking of confirmed user account with lock reason. ADMIN_CELLPHONE_DATA_LEGEND_TITLE=Change cell phone number and provider. ERROR_CANNOT_LOCK_USER_ACCOUNT_UNCONFIRMED=Error: Cannot lock user account, it is still unconfirmed. +ADMIN_MOBILE_PROVIDER_REQUIRED=Please choose a mobile provider. +ADMIN_CELLPHONE_NUMBER_REQUIRED=Please enter a cell phone number. diff --git a/web/WEB-INF/templates/admin/cellphone/admin_form_cellphone_data.tpl b/web/WEB-INF/templates/admin/cellphone/admin_form_cellphone_data.tpl index 131cc654..88b55dbc 100644 --- a/web/WEB-INF/templates/admin/cellphone/admin_form_cellphone_data.tpl +++ b/web/WEB-INF/templates/admin/cellphone/admin_form_cellphone_data.tpl @@ -31,7 +31,7 @@

- + @@ -51,7 +51,7 @@
- +
diff --git a/web/admin/cellphone/admin_cellphone_edit.xhtml b/web/admin/cellphone/admin_cellphone_edit.xhtml index c31f08ea..159db8dc 100644 --- a/web/admin/cellphone/admin_cellphone_edit.xhtml +++ b/web/admin/cellphone/admin_cellphone_edit.xhtml @@ -19,7 +19,7 @@ - +
#{msg.ADMIN_EDIT_CELLPHONE_TITLE}