]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with cellphone number edit: (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Tue, 9 Aug 2016 15:06:06 +0000 (17:06 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 17 Aug 2016 19:45:40 +0000 (21:45 +0200)
- 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

src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java
src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
web/WEB-INF/templates/admin/cellphone/admin_form_cellphone_data.tpl
web/admin/cellphone/admin_cellphone_edit.xhtml

index 5099a0d83777a31b4f272c0add800eabdace1d3f..ee62859a5e37a09ddb250d4eb6ea9334b5f3c5db 100644 (file)
@@ -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<AdminUpdatedCellphoneNumberEvent> 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;
+       }
+
 }
index bb24e007d4de809ae35036f58e7e2fb196cb69d2..b2e1d8ce51456f6628b9b3f2637f265c34ef1bbe 100644 (file)
@@ -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
+        * <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);
+
 }
index 9dbeddc1f1b9afa46eeda7fae9e40f3e751429cc..fc8aeaf9a249adfdab52d4e9061d99290615028e 100644 (file)
@@ -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.
index a205cee2bb895d3d7af45708af76bdd28600da99..df788677b07834cb544ab57740818257b2a8f368 100644 (file)
@@ -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.
index 131cc654d48ac5d94da1731d50f5749fdc6b9aa0..88b55dbc2076b806919f4ce495d874f390c246cb 100644 (file)
@@ -31,7 +31,7 @@
                                </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})" />
@@ -51,7 +51,7 @@
                                </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>
index c31f08eadb372e719008cee2dbe64db033fddc46..159db8dc4981039876a752a6a44bf9fed935b9be 100644 (file)
@@ -19,7 +19,7 @@
                </ui:define>
 
                <ui:define name="content">
-                       <h:form id="form_edit_phone" rendered="#{not empty adminPhoneController.cellPhoneNumber}">
+                       <h:form id="form_edit_cellphone" rendered="#{not empty adminPhoneController.cellPhoneNumber}">
                                <div class="table_medium">
                                        <div class="table_header">
                                                #{msg.ADMIN_EDIT_CELLPHONE_TITLE}