]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Wed, 20 Apr 2016 15:09:16 +0000 (17:09 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 20 Apr 2016 18:00:09 +0000 (20:00 +0200)
- All optional data is now checked with "instanceof"
- added logging messages (direct output)
- maybe put the copy command here? (was not called)
- ignored strings for i18n

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/helper/PizzaAdminWebRequestHelper.java
web/admin/user/admin_user_edit.xhtml

index a7f3822be3c352dc1142cef404bf680e0432c5ff..565358b535a2a81e4961c97edfa6b23c132ac847 100644 (file)
@@ -33,6 +33,9 @@ import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
 import org.mxchange.jcontacts.contact.gender.Gender;
 import org.mxchange.jcontacts.events.contact.AdminAddedContactEvent;
 import org.mxchange.jcountry.data.Country;
+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;
 
 /**
@@ -198,13 +201,16 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ
 
        @Override
        public void copyContactToController (final Contact contact) {
+               // Log message
+               System.out.println(MessageFormat.format("AdminContactController::copyContactToController(): contact={0} - CALLED!", contact)); //NOI18N
+
                // The contact instance must be valid
                if (null == contact) {
                        // Throw NPE again
-                       throw new NullPointerException("this.user.userContact is null");
+                       throw new NullPointerException("this.user.userContact is null"); //NOI18N
                } else if (contact.getContactId() < 1) {
                        // Not valid
-                       throw new IllegalStateException(MessageFormat.format("this.user.userContact.contactId={0} is not valid.", contact.getContactId()));
+                       throw new IllegalStateException(MessageFormat.format("this.user.userContact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
                }
 
                // Set all fields: contact
@@ -221,22 +227,34 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ
                this.setStreet(contact.getContactStreet());
                this.setZipCode(contact.getContactZipCode());
 
-               // ... cellphone data
-               this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
-               this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
-               this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
-
-               // ... fax data
-               this.setFaxId(contact.getContactFaxNumber().getPhoneId());
-               this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
-               this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
-               this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
-
-               // .. land-line data
-               this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
-               this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
-               this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
-               this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
+               // Is the cell phone set?
+               if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
+                       // ... cellphone data
+                       this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
+                       this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
+                       this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
+               }
+
+               // Is the fax set?
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // ... fax data
+                       this.setFaxId(contact.getContactFaxNumber().getPhoneId());
+                       this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
+                       this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
+                       this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
+               }
+
+               // Is the land-line number set?
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // .. land-line data
+                       this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
+                       this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
+                       this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
+                       this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
+               }
+
+               // Log message
+               System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N
        }
 
        @Override
index fe347eea3b7587264b4244dba8e9d9db5c1339a0..4ca5964e06d395a40eb59e0c9dad78dfc82e62a9 100644 (file)
@@ -21,8 +21,8 @@ import javax.enterprise.context.RequestScoped;
 import javax.inject.Inject;
 import javax.inject.Named;
 import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController;
 import org.mxchange.pizzaapplication.beans.user.PizzaAdminUserWebRequestController;
 
 /**
@@ -64,16 +64,19 @@ public class PizzaAdminWebRequestHelper implements PizzaAdminWebRequestControlle
 
        @Override
        public void copyUserToController () {
+               // Log message
+               System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N
+
                // Validate user instance
                if (this.getUser() == null) {
                        // Throw NPE
-                       throw new NullPointerException("this.user is null");
+                       throw new NullPointerException("this.user is null"); //NOI18N
                } else if (this.getUser().getUserId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("this.user.userId is null");
+                       throw new NullPointerException("this.user.userId is null"); //NOI18N
                } else if (this.getUser().getUserId() < 1) {
                        // Not valid
-                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId()));
+                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
                }
 
                // Set all fields: user
@@ -84,6 +87,9 @@ public class PizzaAdminWebRequestHelper implements PizzaAdminWebRequestControlle
 
                // Call contact controller
                this.adminContactController.copyContactToController(contact);
+
+               // Log message
+               System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N
        }
 
        @Override
index 123924a444a672beebe75ccd023ef541010b6ff0..ebf3e1b698c6f083f880dc77b6c54eb3d44ccaf3 100644 (file)
@@ -10,6 +10,7 @@
 
        <f:metadata>
                <f:viewParam name="userId" value="#{adminHelper.user}" converter="UserConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_USER_ID_NOT_SET}" />
+               <f:viewAction action="#{adminHelper.copyUserToController()}" />
        </f:metadata>
 
        <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
@@ -23,9 +24,6 @@
                        <h:outputText styleClass="errors" value="#{msg.ERROR_USER_ID_NOT_FOUND}" rendered="#{empty adminHelper.user}" />
 
                        <h:form id="admin_edit_user" rendered="#{not empty adminHelper.user}">
-                               <f:metadata>
-                                       <f:viewAction action="#{adminHelper.copyUserToController()}" />
-                               </f:metadata>
                        </h:form>
                </ui:define>
        </ui:composition>