- renamed template to admin_form_add_contact_cellphone.tpl to make it more clear
- adminContactPhoneController is a request-scoped controller
- implemented allNonLinkedCellphoneNumbers() which fires an event to remove already used contacts
- this may become handy when more than one entity (now only contact) links to cellphone numbers
- added missing i18n strings
Signed-off-by: Roland Häder <roland@mxchange.org>
package org.mxchange.jjobs.beans.phone;
import java.text.MessageFormat;
+import java.util.List;
import java.util.Objects;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.naming.NamingException;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.helper.JobsWebRequestController;
+import org.mxchange.jphone.events.cellphone.deleted.AdminCellphoneNumberDeletedEvent;
+import org.mxchange.jphone.events.cellphone.deleted.AdminDeletedCellphoneNumberEvent;
+import org.mxchange.jphone.events.cellphone.remove.AdminCellphoneNumberRemovedFromListEvent;
+import org.mxchange.jphone.events.cellphone.remove.AdminRemoveCellphoneNumberFromListEvent;
+import org.mxchange.jphone.events.cellphone.updated.AdminCellphoneNumberUpdatedEvent;
+import org.mxchange.jphone.events.cellphone.updated.AdminUpdatedCellphoneNumberEvent;
import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
*/
private MobileProvider cellphoneProvider;
+ /**
+ * Cell phone number
+ */
+ private DialableCellphoneNumber choosenCellphoneNumber;
+
+ /**
+ * Generic hone controller
+ */
+ @Inject
+ private JobsPhoneWebApplicationController phoneController;
+
/**
* Phone number
*/
private Long phoneNumber;
+ /**
+ * Event being fired when a list of all unsed cell phone numbers is being
+ * created.
+ */
+ private Event<AdminRemoveCellphoneNumberFromListEvent> removeLinkedCellphoneNumbersEvent;
+
/**
* Default constructor
*/
}
}
+ @Override
+ public List<DialableCellphoneNumber> allNonLinkedCellphoneNumbers () {
+ // Get list of all cell phone numbers
+ List<DialableCellphoneNumber> list = this.phoneController.allCellphoneNumbers();
+
+ // Visit all controllers to reduce the list
+ this.removeLinkedCellphoneNumbersEvent.fire(new AdminCellphoneNumberRemovedFromListEvent(list));
+
+ // Return it
+ return list;
+ }
+
@Override
public String deleteCellphoneData () {
// Is all data set
this.cellphoneProvider = cellphoneProvider;
}
+ @Override
+ public DialableCellphoneNumber getChoosenCellphoneNumber () {
+ return this.choosenCellphoneNumber;
+ }
+
+ @Override
+ public void setChoosenCellphoneNumber (final DialableCellphoneNumber choosenCellphoneNumber) {
+ this.choosenCellphoneNumber = choosenCellphoneNumber;
+ }
+
@Override
public Long getPhoneNumber () {
return this.phoneNumber;
package org.mxchange.jjobs.beans.phone;
import java.io.Serializable;
+import java.util.List;
import javax.ejb.Local;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
/**
@Local
public interface JobsAdminPhoneWebRequestController extends Serializable {
+ /**
+ * Returns a list of all unused ("non-linked") cell phone numbers
+ * <p>
+ * @return List with all unused cell phone numbers
+ */
+ List<DialableCellphoneNumber> allNonLinkedCellphoneNumbers ();
+
/**
* Deletes given cellphone entry data
* <p>
*/
void setCellphoneProvider (final MobileProvider cellphoneProvider);
+ /**
+ * Getter for choosen cell phone number
+ * <p>
+ * @return Choosen cell phone number
+ */
+ DialableCellphoneNumber getChoosenCellphoneNumber ();
+
+ /**
+ * Setter for choosen cell phone number
+ * <p>
+ * @param choosenCellphoneNumber Choosen cell phone number
+ */
+ void setChoosenCellphoneNumber (final DialableCellphoneNumber choosenCellphoneNumber);
+
/**
* Getter for dial number without prefix
* <p>
ERROR_EMAIL_ADDRESSES_MISMATCHING=Die eingegebenen Email-Addressen stimmen nicht \u00fcberein.
ERROR_EMAIL_ADDRESS_ALREADY_USED=Die eingegebene Email-Adresse wird bereits verwendet und kann nicht erneut verwendet werden.
ERROR_CELLPHONE_CONTACT_NOT_LINKED=Fehler: Mobilfunk-Id {0} ist nicht mit Kontakt-Id {1} verkn\u00fcpft.
+ADMIN_ADD_CONTACT_CELLPHONE_FORM_TITLE=Mobilfunknummer einem Kontakt hinzuf\u00fcgen
+ADMIN_SELECT_CELLPHONE=Mobilfunknummer ausw\u00e4hlen:
+BUTTON_ADMIN_LINK_ADD_CONTACT_CELLPHONE=Mobilfunknummer zum Kontakt hinzuf\u00fcgen
ERROR_EMAIL_ADDRESSES_MISMATCHING=Both entered email addresses are not the same.
ERROR_EMAIL_ADDRESS_ALREADY_USED=Your entered email address is already used. Please enter another and try again.
ERROR_CELLPHONE_CONTACT_NOT_LINKED=Error: Cell phone id {0} is not linked with contact id {1}.
+ADMIN_ADD_CONTACT_CELLPHONE_FORM_TITLE=Add cell phone number to contact
+ADMIN_SELECT_CELLPHONE=Choose cell phone number:
+BUTTON_ADMIN_LINK_ADD_CONTACT_CELLPHONE=Add cell phone number to contact
<h:outputText styleClass="errors" value="#{msg.ERROR_BEAN_HELPER_CONTACT_NOT_SET}" rendered="#{empty beanHelper.contact}" />
<ui:fragment rendered="#{empty beanHelper.contact.contactCellphoneNumber and not empty beanHelper.contact}">
- <ui:include src="/WEB-INF/templates/admin/cellphone/admin_form_contact_cellphone.tpl" />
+ <ui:include src="/WEB-INF/templates/admin/cellphone/admin_form_add_contact_cellphone.tpl" />
</ui:fragment>
<ui:fragment rendered="#{not empty beanHelper.contact.contactCellphoneNumber and not empty beanHelper.contact}">
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+
+ <h:outputText styleClass="errors" value="#{msg.ERROR_BEAN_HELPER_CONTACT_NOT_SET}" rendered="#{empty beanHelper.contact}" />
+
+ <h:form id="form_add_contact_cellphone" rendered="#{not empty beanHelper.contact}">
+ <h:panelGroup styleClass="table_medium" layout="block">
+ <div class="table_header">
+ <h:outputText value="#{msg.ADMIN_ADD_CONTACT_CELLPHONE_FORM_TITLE}" />
+ </div>
+
+ <div class="para">
+ <ui:include src="/WEB-INF/templates/admin/contact/admin_contact_data_mini.tpl" />
+ </div>
+
+ <div class="table_row">
+ <div class="table_left_medium">
+ <h:outputLabel for="choosenCellphoneNumber" value="#{msg.ADMIN_SELECT_CELLPHONE}" />
+ </div>
+
+ <div class="table_right_medium">
+ <h:selectOneMenu styleClass="select right_space" id="choosenCellphoneNumber" value="#{adminPhoneController.choosenCellphoneNumber}">
+ <f:converter converterId="CellphoneConverter" />
+ <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
+ <f:selectItems value="#{adminPhoneController.allNonLinkedCellphoneNumbers()}" var="cellphoneNumber" itemValue="#{cellphoneNumber}" itemLabel="#{cellphoneNumber.cellphoneProvider.providerCountry.countryExternalDialPrefix} (#{cellphoneNumber.cellphoneProvider.providerDialPrefix}) #{cellphoneNumber.phoneNumber}" />
+ </h:selectOneMenu>
+ </div>
+ </div>
+
+ <div class="para">
+ <h:outputText value="#{msg.ADMIN_OR_ENTER_CONTACT_NEW_CELLPHONE_DATA}" />
+ </div>
+
+ <div class="table_row">
+ <div class="table_left_medium">
+ <h:outputLabel for="cellphoneNumber" value="#{msg.ADMIN_PERSONAL_DATA_CELLPHONE_NUMBER}" />
+ </div>
+
+ <div class="table_right_medium">
+ <ui:include src="/WEB-INF/templates/generic/mobile_selection_box.tpl">
+ <ui:param name="targetController" value="#{adminPhoneController}" />
+ </ui:include>
+ </div>
+ </div>
+
+ <div class="table_footer">
+ <h:commandButton styleClass="reset right_space" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
+ <h:commandButton styleClass="submit" type="submit" action="#{adminContactPhoneController.doLinkAddCellphone(beanHelper.contact)}" value="#{msg.BUTTON_ADMIN_LINK_ADD_CONTACT_CELLPHONE}" />
+ </div>
+ </h:panelGroup>
+ </h:form>
+</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
- <h:outputText styleClass="errors" value="#{msg.ERROR_BEAN_HELPER_CONTACT_NOT_SET}" rendered="#{empty beanHelper.contact}" />
-
- <h:form id="form_add_contact_cellphone">
- </h:form>
-</ui:composition>