@Override
public List<Contact> allCellphoneContacts () {
// Get id
- Long phoneId = this.adminPhoneController.getCellPhone().getPhoneId();
+ Long phoneId = this.adminPhoneController.getCellPhoneNumber().getPhoneId();
// Is cache there?
if (this.contacts.containsKey(phoneId)) {
// "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);
}
// 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?
*/
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;
/**
* Cell phone number
*/
- private DialableCellphoneNumber cellPhone;
+ private DialableCellphoneNumber cellPhoneNumber;
+
+ /**
+ * Event being fired when an administrator has updated cell phone number
+ */
+ @Inject
+ @Any
+ private Event<AdminUpdatedCellphoneNumberEvent> cellPhoneNumberUpdatedEvent;
/**
* Fax number
}
@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
@Local
public interface JobsAdminPhoneWebRequestController extends Serializable {
+ /**
+ * Changes cellphone entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ String editCellphoneData ();
+
/**
* Getter for dialable cellphone number instance
* <p>
* @return Dialable cellphone number instance
*/
- DialableCellphoneNumber getCellPhone ();
+ DialableCellphoneNumber getCellPhoneNumber ();
+
+ /**
+ * Setter for dialable cellphone number instance
+ * <p>
+ * @param cellPhone Dialable cellphone number instance
+ */
+ void setCellPhoneNumber (final DialableCellphoneNumber cellPhone);
/**
* Setter for dialable land-line number instance
*/
DialableFaxNumber getFax ();
- /**
- * Setter for dialable cellphone number instance
- * <p>
- * @param cellPhone Dialable cellphone number instance
- */
- void setCellPhone (final DialableCellphoneNumber cellPhone);
-
}
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.
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
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.
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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+
+ <h:outputText styleClass="errors" value="#{msg.ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET}" rendered="#{empty adminPhoneController.cellPhoneNumber}" />
+
+ <div class="para">
+ <fieldset id="phone_data">
+ <legend title="#{msg.ADMIN_CELLPHONE_DATA_LEGEND_TITLE}">
+ <h:outputText value="#{msg.ADMIN_CELLPHONE_DATA_LEGEND}" />
+ </legend>
+
+ <div class="table_row">
+ <div class="table_left_medium">
+ <h:outputLabel for="cellphoneId" value="#{msg.ADMIN_SHOW_CELLPHONE_ID}" />
+ </div>
+
+ <div class="table_right_medium">
+ <h:outputText id="cellphoneId" value="#{adminPhoneController.cellPhoneNumber.phoneId}" />
+ </div>
+
+ <div class="clear"></div>
+ </div>
+
+ <div class="table_row">
+ <div class="table_left_medium">
+ <h:outputLabel for="cellphoneProvider" value="#{msg.ADMIN_EDIT_CELLPHONE_PROVIDER}" />
+ </div>
+
+ <div class="table_right_medium">
+ <h:selectOneMenu styleClass="select" id="cellphoneCarrier" value="#{adminPhoneController.cellPhoneNumber.cellphoneProvider}">
+ <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})" />
+ </h:selectOneMenu>
+ </div>
+
+ <div class="clear"></div>
+ </div>
+
+ <div class="error_container">
+ <h:message for="cellphoneProvider" errorClass="errors" fatalClass="errors" warnClass="errors" />
+ </div>
+
+ <div class="table_row">
+ <div class="table_left_medium">
+ <h:outputLabel for="cellphoneNumber" value="#{msg.ADMIN_EDIT_CELLPHONE_NUMBER}" />
+ </div>
+
+ <div class="table_right_medium">
+ <h:inputText styleClass="input" id="cellphoneNumber" size="10" maxlength="20" value="#{adminPhoneController.cellPhoneNumber.phoneNumber}">
+ <f:validator for="cellphoneNumber" validatorId="PhoneNumberValidator" />
+ </h:inputText>
+ </div>
+
+ <div class="clear"></div>
+ </div>
+
+ <div class="error_container">
+ <h:message for="cellphoneNumber" errorClass="errors" fatalClass="errors" warnClass="errors" />
+ </div>
+ </fieldset>
+ </div>
+</ui:composition>
>
<f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhoneNumber}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
</f:metadata>
<ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
>
<f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhoneNumber}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
</f:metadata>
<ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
</ui:define>
<ui:define name="content">
- Here goes your content.
+ <h:form id="form_edit_phone" rendered="#{not empty adminPhoneController.cellPhoneNumber}">
+ <div class="table_medium">
+ <div class="table_header">
+ #{msg.ADMIN_EDIT_PHONE_TITLE}
+ </div>
+
+ <ui:include src="/WEB-INF/templates/admin/cellphone/admin_form_cellphone_data.tpl" />
+
+ <div class="table_footer">
+ <h:commandButton styleClass="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
+ <h:commandButton styleClass="submit" type="submit" id="edit_user" value="#{msg.BUTTON_ADMIN_EDIT_CELLPHONE}" action="#{adminPhoneController.editCellphoneData()}" />
+ </div>
+ </div>
+ </h:form>
+
+ <h:outputText styleClass="errors" value="#{msg.ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET}" rendered="#{empty adminPhoneController.cellPhoneNumber}" />
</ui:define>
</ui:composition>
</html>
>
<f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhoneNumber}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
</f:metadata>
<ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
<h:dataTable id="contact_cellphone_link" var="contact" value="#{contactPhoneController.allCellphoneContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
<f:facet name="header">
<h:outputFormat value="#{msg.ADMIN_HEADER_SHOW_CELLPHONE_LINKS}">
- <f:param value="#{adminPhoneController.cellPhone.phoneId}" />
+ <f:param value="#{adminPhoneController.cellPhoneNumber.phoneId}" />
</h:outputFormat>
</f:facet>
<li class="mini_link">
<h:link outcome="admin_unlink_contact_cellphone">
<h:outputText styleClass="unlink_link" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_SHORT_TITLE}" />
- <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
+ <f:param name="phoneId" value="#{adminPhoneController.cellPhoneNumber.phoneId}" />
<f:param name="contactId" value="#{contact.contactId}" />
</h:link>
</li>
>
<f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhoneNumber}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
<f:viewParam name="contactId" value="#{beanHelper.contact}" converter="ContactConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_CONTACT_ID_NOT_SET}" />
</f:metadata>
}
.table_medium {
- width: 620px;
+ width: 650px;
}
.table_big {
.data_label {
font-weight: bold;
background-color: #dddddd;
+ padding-left: 2px;
}
.unlink_link {