From: Roland Häder Date: Tue, 9 Aug 2016 14:04:04 +0000 (+0200) Subject: Continued with cellphone data: (please cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c4b0b435d577211961a50c1377ed1b6ed50a5d13;p=jjobs-war.git Continued with cellphone data: (please cherry-pick) - added form template for editing cellphone data (yes, generic) - renamed cellPhone -> cellPhoneNumber - CSS class table_medium needs to be a bit bigger - implemented method editCellphoneData() - including fireing new event - fixed i18n strings Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java index a566b33c..280e3db7 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java @@ -163,7 +163,7 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement @Override public List allCellphoneContacts () { // Get id - Long phoneId = this.adminPhoneController.getCellPhone().getPhoneId(); + Long phoneId = this.adminPhoneController.getCellPhoneNumber().getPhoneId(); // Is cache there? if (this.contacts.containsKey(phoneId)) { @@ -176,7 +176,7 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement // "Walk" through all contacts for (final Contact contact : this.contactController.allContacts()) { // Is cellphone instance the same? - if (Objects.equals(contact.getContactCellphoneNumber(), this.adminPhoneController.getCellPhone())) { + if (Objects.equals(contact.getContactCellphoneNumber(), this.adminPhoneController.getCellPhoneNumber())) { // Found one list.add(contact); } diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java index f4872825..4d440cd6 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java @@ -208,7 +208,7 @@ public class JobsWebRequestHelper implements JobsWebRequestController { // Is cellphone set? if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) { // Yes, then set it in admin controller - this.adminPhoneController.setCellPhone(contact.getContactCellphoneNumber()); + this.adminPhoneController.setCellPhoneNumber(contact.getContactCellphoneNumber()); } // Is land-line set? diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java index 801352f4..5099a0d8 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java @@ -16,14 +16,20 @@ */ package org.mxchange.jjobs.beans.phone; +import java.text.MessageFormat; import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; import javax.faces.view.facelets.FaceletException; +import javax.inject.Inject; import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote; import org.mxchange.jjobs.beans.BaseJobsController; +import org.mxchange.jphone.events.updated.AdminCellphoneNumberUpdatedEvent; +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; @@ -50,7 +56,14 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements /** * Cell phone number */ - private DialableCellphoneNumber cellPhone; + private DialableCellphoneNumber cellPhoneNumber; + + /** + * Event being fired when an administrator has updated cell phone number + */ + @Inject + @Any + private Event cellPhoneNumberUpdatedEvent; /** * Fax number @@ -80,13 +93,52 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements } @Override - public DialableCellphoneNumber getCellPhone () { - return this.cellPhone; + public String editCellphoneData () { + // Is all data set + if (this.getCellPhoneNumber() == null) { + // Not set, throw NPE + throw new NullPointerException("this.cellphoneNumber is null"); //NOI18N + } else if (this.getCellPhoneNumber().getPhoneId() == null) { + // Throw NPE again + throw new NullPointerException("this.cellphoneNumber.phoneId is null"); //NOI18N + } else if (this.getCellPhoneNumber().getPhoneId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("this.cellphoneNumber.phoneId={0} is not valid", this.getCellPhoneNumber().getPhoneId())); //NOI18N + } else if (this.getCellPhoneNumber().getCellphoneProvider() == null) { + // Throw NPE + throw new NullPointerException("this.cellphoneNumber.cellphoneProvider is null"); //NOI18N + } else if (this.getCellPhoneNumber().getCellphoneProvider().getProviderId() == null) { + // ... throw again + throw new NullPointerException("this.cellphoneNumber.cellphoneProvider.providerId is null"); //NOI18N + } else if (this.getCellPhoneNumber().getCellphoneProvider().getProviderId() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("this.cellphoneNumber.cellphoneProvider.providerId={0} is not valid.", this.getCellPhoneNumber().getCellphoneProvider().getProviderId())); //NOI18N + } else if (this.getCellPhoneNumber().getPhoneNumber() == null) { + // Throw NPE again + throw new NullPointerException("this.cellphoneNumber.phoneNumber is null"); //NOI18N + } 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 + } + + // Send to bean + DialableCellphoneNumber updatedNumber = this.adminPhoneBean.updateCellphoneData(this.getCellPhoneNumber()); + + // Fire event + this.cellPhoneNumberUpdatedEvent.fire(new AdminCellphoneNumberUpdatedEvent(updatedNumber)); + + // All fine, redirect + return "admin_edit_cellphone?faces-redirect=true&includeViewParams=true"; //NOI18N + } + + @Override + public DialableCellphoneNumber getCellPhoneNumber () { + return this.cellPhoneNumber; } @Override - public void setCellPhone (final DialableCellphoneNumber cellPhone) { - this.cellPhone = cellPhone; + public void setCellPhoneNumber (final DialableCellphoneNumber cellPhoneNumber) { + this.cellPhoneNumber = cellPhoneNumber; } @Override diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java index 62b7b102..bb24e007 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestController.java @@ -31,12 +31,26 @@ import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; @Local public interface JobsAdminPhoneWebRequestController extends Serializable { + /** + * Changes cellphone entry data + *

+ * @return Redirect outcome + */ + String editCellphoneData (); + /** * Getter for dialable cellphone number instance *

* @return Dialable cellphone number instance */ - DialableCellphoneNumber getCellPhone (); + DialableCellphoneNumber getCellPhoneNumber (); + + /** + * Setter for dialable cellphone number instance + *

+ * @param cellPhone Dialable cellphone number instance + */ + void setCellPhoneNumber (final DialableCellphoneNumber cellPhone); /** * Setter for dialable land-line number instance @@ -66,11 +80,4 @@ public interface JobsAdminPhoneWebRequestController extends Serializable { */ DialableFaxNumber getFax (); - /** - * Setter for dialable cellphone number instance - *

- * @param cellPhone Dialable cellphone number instance - */ - void setCellPhone (final DialableCellphoneNumber cellPhone); - } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 1fbb69c2..207dd657 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -406,19 +406,18 @@ ADMIN_LINK_DELETE_SHORT=L\u00f6schen ADMIN_LINK_DELETE_SHORT_TITLE=Eintrag l\u00f6schen. ADMIN_LINK_UNLINK_SHORT=Abtrennen ADMIN_LINK_UNLINK_SHORT_TITLE=Entfernt Verkn\u00fcpfung zum Eintrag. -PAGE_TITLE_ADMIN_DELETE_CELLPHONE=Mobiletelefoneintrag eines Kontaktes l\u00f6schen -CONTENT_TITLE_ADMIN_DELETE_CELLPHONE=Mobiltelefoneintrag eines Kontaktes l\u00f6schen: -PAGE_TITLE_ADMIN_EDIT_CELLPHONE=Mobiltelefoneintrag eines Kontaktes editieren -CONTENT_TITLE_ADMIN_EDIT_CELLPHONE=Mobiltelefoneintrag eines Kontaktes editieren: -PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE=Eintr\u00e4ge von Mobiletelefonen auflisten -PAGE_TITLE_ADMIN_SHOW_CELLPHONE=Mobiltelefoneintrag eines Kontaktes anzeigen +PAGE_TITLE_ADMIN_DELETE_CELLPHONE=Mobiletelefoneintrag l\u00f6schen +CONTENT_TITLE_ADMIN_DELETE_CELLPHONE=Mobiletelefoneintrag l\u00f6schen: +PAGE_TITLE_ADMIN_EDIT_CELLPHONE=Mobiletelefoneintrag editieren +CONTENT_TITLE_ADMIN_EDIT_CELLPHONE=Mobiletelefoneintrag editieren: +PAGE_TITLE_ADMIN_SHOW_CELLPHONE=Mobiletelefoneintrag anzeigen CONTENT_TITLE_ADMIN_SHOW_CELLPHONE=Anzeigen eines Mobiltelefoneintrags eines Kontaktes: PAGE_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Verkn\u00fcpfung Kontakt-Mobiletelfon l\u00f6schen CONTENT_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Entfernen einer Verkn\u00fcpfung Kontakt-Mobiltelefon: ERROR_PARAMETER_PHONE_ID_NOT_SET=Fehler: Parameter 'phoneId' ist nicht gesetzt. PAGE_TITLE_ADMIN_SHOW_MOBILE_PROVIDER=Mobilfunkbetreiber anzeigen CONTENT_TITLE_ADMIN_SHOW_MOBILE_PROVIDER=Mobilfunkbetreiber anzeigen: -TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE=Ein einzelner Mobiltelefoneintrag eines Kontaktes. +TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE=Ein einzelner Mobiletelefoneintrag. TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE_LINKS=Diese Tabelle zeigt Verkn\u00fcpfungen von der Mobilfunknummern zu allen Kontaktdaten an. ADMIN_HEADER_SHOW_CELLPHONE_LINKS=Alle Kontakt-Mobiltelefon-Verkn\u00fcpfungen f\u00fcr Id-Nummer {0}: ERROR_PARAMETER_CONTACT_ID_NOT_SET=Fehler: Parameter 'contactId' ist nicht gesetzt. @@ -607,3 +606,8 @@ LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS=Handynummern ... LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS_TITLE=Alle Mobilfunknummern auflisten. ADMIN_SHOW_CELLPHONE_CREATED=Erstellt: ADMIN_SHOW_CELLPHONE_UPDATED=Zuletzt ge\u00e4ndert: +ADMIN_EDIT_CELLPHONE_TITLE=Mobiltelefoneintrag editieren: +ADMIN_CELLPHONE_DATA_LEGEND=Mobiltelefonnummerdaten editeren: +ADMIN_EDIT_CELLPHONE_PROVIDER=Mobilfunkanbieter \u00e4ndern: +ADMIN_EDIT_CELLPHONE_NUMBER=Rufnummer \u00e4ndern: +BUTTON_ADMIN_EDIT_CELLPHONE=Mobiltelefonnumer \u00e4ndern diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 855dcb0e..bdf705fa 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -389,19 +389,18 @@ ADMIN_LINK_DELETE_SHORT=Delete ADMIN_LINK_DELETE_SHORT_TITLE=Delete entry. ADMIN_LINK_UNLINK_SHORT=Unlink ADMIN_LINK_UNLINK_SHORT_TITLE=Removes link to entry. -PAGE_TITLE_ADMIN_DELETE_CELLPHONE=Delete contact's cellphone entry -CONTENT_TITLE_ADMIN_DELETE_CELLPHONE=Delete contact's cellphone entry: -PAGE_TITLE_ADMIN_EDIT_CELLPHONE=Edit contact's cellphone entry -CONTENT_TITLE_ADMIN_EDIT_CELLPHONE=Edit contact's cellphone entry: -PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE=List all cellphone entries -PAGE_TITLE_ADMIN_SHOW_CELLPHONE=Show contact's cellphone entry -CONTENT_TITLE_ADMIN_SHOW_CELLPHONE=Show contact's cellphone entry: +PAGE_TITLE_ADMIN_DELETE_CELLPHONE=Delete cellphone entry +CONTENT_TITLE_ADMIN_DELETE_CELLPHONE=Delete cellphone entry: +PAGE_TITLE_ADMIN_EDIT_CELLPHONE=Edit cellphone entry +CONTENT_TITLE_ADMIN_EDIT_CELLPHONE=Edit cellphone entry: +PAGE_TITLE_ADMIN_SHOW_CELLPHONE=Show cellphone entry +CONTENT_TITLE_ADMIN_SHOW_CELLPHONE=Show cellphone entry: PAGE_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Remove link contact-cellphone CONTENT_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Remove link between contact-cellphone: ERROR_PARAMETER_PHONE_ID_NOT_SET=Error: Parameter 'phoneId' is not set. PAGE_TITLE_ADMIN_SHOW_MOBILE_PROVIDER=Show mobile provider CONTENT_TITLE_ADMIN_SHOW_MOBILE_PROVIDER=Show mobile provider: -TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE=A single contact's cellphone entry. +TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE=A single cellphone entry. TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE_LINKS=This table shows links of of this cellphone number to all contacts. ADMIN_HEADER_SHOW_CELLPHONE_LINKS=All links between contact-cellphone for id {0}: ERROR_PARAMETER_CONTACT_ID_NOT_SET=Error: Parameter 'contactId' is not set. @@ -607,3 +606,8 @@ LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS=Cell phone numbers ... LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS_TITLE=List all cell phone numbers. ADMIN_SHOW_CELLPHONE_CREATED=Created: ADMIN_SHOW_CELLPHONE_UPDATED=Last changed: +ADMIN_EDIT_CELLPHONE_TITLE=Edit cell phone entry: +ADMIN_CELLPHONE_DATA_LEGEND=Edit cell phone data: +ADMIN_EDIT_CELLPHONE_PROVIDER=Change mobile phone provider: +ADMIN_EDIT_CELLPHONE_NUMBER=Change call number: +BUTTON_ADMIN_EDIT_CELLPHONE=Edit 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 new file mode 100644 index 00000000..bf43e065 --- /dev/null +++ b/web/WEB-INF/templates/admin/cellphone/admin_form_cellphone_data.tpl @@ -0,0 +1,67 @@ + + + + + +

+
+ + + + +
+
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ + + + + +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + +
+ +
+
+ +
+ +
+
+
+ diff --git a/web/admin/cellphone/admin_cellphone_delete.xhtml b/web/admin/cellphone/admin_cellphone_delete.xhtml index 72a387f4..829047db 100644 --- a/web/admin/cellphone/admin_cellphone_delete.xhtml +++ b/web/admin/cellphone/admin_cellphone_delete.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/cellphone/admin_cellphone_edit.xhtml b/web/admin/cellphone/admin_cellphone_edit.xhtml index 31a3d1cd..b263f958 100644 --- a/web/admin/cellphone/admin_cellphone_edit.xhtml +++ b/web/admin/cellphone/admin_cellphone_edit.xhtml @@ -8,7 +8,7 @@ > - + @@ -19,7 +19,22 @@ - Here goes your content. + +
+
+ #{msg.ADMIN_EDIT_PHONE_TITLE} +
+ + + + +
+
+ +
diff --git a/web/admin/cellphone/admin_cellphone_show.xhtml b/web/admin/cellphone/admin_cellphone_show.xhtml index 26e34fd1..0dac78b4 100644 --- a/web/admin/cellphone/admin_cellphone_show.xhtml +++ b/web/admin/cellphone/admin_cellphone_show.xhtml @@ -8,7 +8,7 @@ > - + @@ -26,7 +26,7 @@ - + @@ -79,7 +79,7 @@ diff --git a/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml b/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml index 715d7bc9..0fa8d3c4 100644 --- a/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml +++ b/web/admin/cellphone/admin_contact_cellphone_unlink.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/resources/css/cssLayout.css b/web/resources/css/cssLayout.css index c2176e14..2c9f27de 100644 --- a/web/resources/css/cssLayout.css +++ b/web/resources/css/cssLayout.css @@ -67,7 +67,7 @@ table, .table, .table_medium { } .table_medium { - width: 620px; + width: 650px; } .table_big { @@ -237,6 +237,7 @@ ul.footer_nav li.footer_copyright { .data_label { font-weight: bold; background-color: #dddddd; + padding-left: 2px; } .unlink_link {