]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued a bit: (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Wed, 10 Aug 2016 10:32:41 +0000 (12:32 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 19 Aug 2016 20:36:50 +0000 (22:36 +0200)
- implemented controller (bean) method deleteCellphoneData() with event being fired after the cell phone has been deleted. This can be used for later event logging or what ever.
- implemented form for deleting cell phone data
- fixed id for commandButton (is edit_cellphone)
- added missing i18n strings

Signed-off-by: Roland Häder <roland@mxchange.org>
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/admin/cellphone/admin_cellphone_delete.xhtml
web/admin/cellphone/admin_cellphone_edit.xhtml

index 861b3e12499c18deb6f6f275a20d64ddd6b1a644..b59be2767144c0824a421142e1c827eae7a8644e 100644 (file)
@@ -30,6 +30,8 @@ import javax.naming.NamingException;
 import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
 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.updated.AdminCellphoneNumberUpdatedEvent;
 import org.mxchange.jphone.events.updated.AdminUpdatedCellphoneNumberEvent;
 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
@@ -60,6 +62,13 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements
        @Inject
        private JobsWebRequestController beanHelper;
 
+       /**
+        * Event being fired when an administrator has deleted cell phone number
+        */
+       @Inject
+       @Any
+       private Event<AdminDeletedCellphoneNumberEvent> cellPhoneNumberDeletedEvent;
+
        /**
         * Event being fired when an administrator has updated cell phone number
         */
@@ -94,6 +103,45 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements
                }
        }
 
+       @Override
+       public String deleteCellphoneData () {
+               // Is all data set
+               if (this.beanHelper.getCellPhoneNumber() == null) {
+                       // Not set, throw NPE
+                       throw new NullPointerException("this.cellphoneNumber is null"); //NOI18N
+               } else if (this.beanHelper.getCellPhoneNumber().getPhoneId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.cellphoneNumber.phoneId is null"); //NOI18N
+               } else if (this.beanHelper.getCellPhoneNumber().getPhoneId() < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("this.cellphoneNumber.phoneId={0} is not valid", this.beanHelper.getCellPhoneNumber().getPhoneId())); //NOI18N
+               } else if (this.beanHelper.getCellPhoneNumber().getCellphoneProvider() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.cellphoneNumber.cellphoneProvider is null"); //NOI18N
+               } else if (this.beanHelper.getCellPhoneNumber().getCellphoneProvider().getProviderId() == null) {
+                       // ... throw again
+                       throw new NullPointerException("this.cellphoneNumber.cellphoneProvider.providerId is null"); //NOI18N
+               } else if (this.beanHelper.getCellPhoneNumber().getCellphoneProvider().getProviderId() < 1) {
+                       // Id not valid
+                       throw new IllegalArgumentException(MessageFormat.format("this.cellphoneNumber.cellphoneProvider.providerId={0} is not valid.", this.beanHelper.getCellPhoneNumber().getCellphoneProvider().getProviderId())); //NOI18N
+               } else if (this.beanHelper.getCellPhoneNumber().getPhoneNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.cellphoneNumber.phoneNumber is null"); //NOI18N
+               } else if (this.beanHelper.getCellPhoneNumber().getPhoneNumber() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("this.cellphoneNumber.phoneNumber={0} is not valid.", this.beanHelper.getCellPhoneNumber().getPhoneNumber())); //NOI18N
+               }
+
+               // Call EJB
+               this.adminPhoneBean.deleteCellphoneData(this.beanHelper.getCellPhoneNumber());
+
+               // Fire event
+               this.cellPhoneNumberDeletedEvent.fire(new AdminCellphoneNumberDeletedEvent(this.beanHelper.getCellPhoneNumber()));
+
+               // All fine, redirect
+               return "admin_list_cellphone?faces-redirect=true&includeViewParams=true"; //NOI18N
+       }
+
        @Override
        public String editCellphoneData () {
                // Is all data set
index c74a459322d328ff1c508ed755ed26dd90609793..82db717d406d8eed3743f0f82136ee2af52b4b11 100644 (file)
@@ -29,6 +29,13 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
 @Local
 public interface JobsAdminPhoneWebRequestController extends Serializable {
 
+       /**
+        * Deletes given cellphone entry data
+        * <p>
+        * @return Redirect outcome
+        */
+       String deleteCellphoneData ();
+
        /**
         * Changes cellphone entry data
         * <p>
index fc8aeaf9a249adfdab52d4e9061d99290615028e..7c143d8a6353a661974fe1de70b3a148c66fac85 100644 (file)
@@ -616,3 +616,5 @@ 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.
+BUTTON_ADMIN_DELETE_CELLPHONE=Mobilfunknummer l\u00f6schen
+ADMIN_DELETE_CELLPHONE_DATA_NOTICE=Wenn Sie die Mobilfunknummer l\u00f6schen, steht diese nicht mehr im System zur Verf\u00fcgung. Bitte \u00fcberlegen Sie genau, ob Sie dies wollen.
index df788677b07834cb544ab57740818257b2a8f368..fc455c031316c644ef73cb4bc6c71d29f99de200 100644 (file)
@@ -616,3 +616,5 @@ 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.
+BUTTON_ADMIN_DELETE_CELLPHONE=Delete cell phone number
+ADMIN_DELETE_CELLPHONE_DATA_NOTICE=If you delete the cell phone number, it won't be available anymore for anything. Please consider carefully if you really want this.
index 13f28dc0233795a3cebe22d679af80e8279aaded..186dfecc33100ca5ccc55a35235ee9f9d31ab348 100644 (file)
                </ui:define>
 
                <ui:define name="content">
-                       Here goes your content.
+                       <h:form id="form_delete_cellphone" rendered="#{not empty beanHelper.cellPhoneNumber}">
+                               <div class="table">
+                                       <div class="table_header">
+                                               <h:outputText value="#{msg.ADMIN_DELETE_CELLPHONE_TITLE}" />
+                                       </div>
+
+                                       <div class="para">
+                                               <ui:include src="/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl">
+                                                       <ui:param name="isShowPage" value="#{false}" />
+                                               </ui:include>
+                                       </div>
+
+                                       <div class="para">
+                                               <h:outputText value="#{msg.ADMIN_DELETE_CELLPHONE_DATA_NOTICE}"
+                                       </div>
+
+                                       <div class="table_footer">
+                                               <h:commandButton styleClass="delete_button" type="submit" id="delete_cellphone" value="#{msg.BUTTON_ADMIN_DELETE_CELLPHONE}" action="#{adminPhoneController.deleteCellphoneData()}" />
+                                       </div>
+                               </div>
+                       </h:form>
+
+                       <h:outputText styleClass="errors" value="#{msg.ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET}" rendered="#{empty beanHelper.cellPhoneNumber}" />
                </ui:define>
        </ui:composition>
 </html>
index 2c87088a156d216059117432bd2681c68a77cc40..2fbc982614e9c2777d1e6cf5aebaee49bd793cfa 100644 (file)
@@ -30,7 +30,7 @@
 
                                        <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()}" />
+                                               <h:commandButton styleClass="submit" type="submit" id="edit_cellphone" value="#{msg.BUTTON_ADMIN_EDIT_CELLPHONE}" action="#{adminPhoneController.editCellphoneData()}" />
                                        </div>
                                </div>
                        </h:form>