From: Roland Häder Date: Thu, 21 Apr 2016 12:38:35 +0000 (+0200) Subject: Added redirect outcome + updated jar(s) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=533b53f3afaeacb0d629a06350d7599deb0ca4ee;p=jfinancials-war.git Added redirect outcome + updated jar(s) Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java index b6e537ec..9b537028 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java @@ -33,9 +33,14 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController; +import org.mxchange.addressbook.beans.helper.AddressbookAdminWebRequestController; import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jusercore.container.login.UserLoginContainer; import org.mxchange.jusercore.events.user.AdminAddedUserEvent; import org.mxchange.jusercore.events.user.AdminUserAddedEvent; +import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent; +import org.mxchange.jusercore.events.user.update.AdminUserDataUpdatedEvent; +import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNotFoundException; @@ -72,7 +77,7 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW * Admin helper instance */ @Inject - private RateCalcAdminWebRequestController adminHelper; + private AddressbookAdminWebRequestController adminHelper; /** * Regular contact controller @@ -136,7 +141,7 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW } @Override - public void addUser () { + public String addUser () { // Create new user instance User localUser = new LoginUser(); @@ -199,6 +204,9 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW // Clear contact instance this.contactController.clear(); + + // Return to user list (for now) + return "admin_list_user"; //NOI18N } @Override @@ -206,16 +214,16 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW // Check parameter if (null == event) { // Throw NPE - throw new NullPointerException("event is null"); + throw new NullPointerException("event is null"); //NOI18N } else if (event.getUpdatedUser() == null) { // Throw NPE again - throw new NullPointerException("event.updatedUser is null"); + throw new NullPointerException("event.updatedUser is null"); //NOI18N } else if (event.getUpdatedUser().getUserId() == null) { // ... and again - throw new NullPointerException("event.updatedUser.userId is null"); + throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N } else if (event.getUpdatedUser().getUserId() < 1) { // Invalid value - throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); + throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N } // All fine, so update list @@ -229,7 +237,7 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW } @Override - public void editUserData () { + public String editUserData () { // Get user instance User user = this.adminHelper.getUser(); @@ -239,31 +247,31 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW // Check if user instance is in helper and valid if (null == user) { // Throw NPE - throw new NullPointerException("adminHelper.user is null"); + throw new NullPointerException("adminHelper.user is null"); //NOI18N } else if (user.getUserId() == null) { // Throw NPE again - throw new NullPointerException("adminHelper.user.userId is null"); + throw new NullPointerException("adminHelper.user.userId is null"); //NOI18N //NOI18N } else if (user.getUserId() < 1) { // Invalid id throw new IllegalStateException(MessageFormat.format("adminHelper.user.userId={0} is invalid", user.getUserId())); } else if (this.getUserName() == null) { // Not all required fields are set - throw new NullPointerException("this.userName is null"); + throw new NullPointerException("this.userName is null"); //NOI18N } else if (this.getUserName().isEmpty()) { // Not all required fields are set - throw new IllegalArgumentException("this.userName is empty"); + throw new IllegalArgumentException("this.userName is empty"); //NOI18N } else if (((!this.getUserPassword().isEmpty()) || (!this.getUserPasswordRepeat().isEmpty())) && (!this.isSamePasswordEntered())) { // Not same password entered this.setUserPassword(null); this.setUserPasswordRepeat(null); // Throw exception - throw new FaceletException("Not same password entered"); + throw new FaceletException("Not same password entered"); //NOI18N } else if (this.isSamePasswordEntered()) { // Same password entered, create container if (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword()))) { // Same password entered - throw new FaceletException("Same password as stored entered."); + throw new FaceletException("Same password as stored entered."); //NOI18N } // Encrypt password @@ -287,6 +295,9 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW // Fire event this.updatedUserDataEvent.fire(new AdminUserDataUpdatedEvent(updatedUser)); + + // Return to user list (for now) + return "admin_list_user"; //NOI18N } @Override @@ -388,13 +399,13 @@ public class AddressbookAdminUserWebRequestBean implements AddressbookAdminUserW // The user should be valid if (null == user) { // Throw NPE - throw new NullPointerException("user is null"); + throw new NullPointerException("user is null"); //NOI18N } else if (user.getUserId() == null) { // ... again NPE - throw new NullPointerException("user.userId is null"); + throw new NullPointerException("user.userId is null"); //NOI18N } else if (user.getUserId() < 1) { // Invalid id - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N } // Get iterator diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestController.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestController.java index 5564dd69..9433b920 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestController.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestController.java @@ -66,13 +66,17 @@ public interface AddressbookAdminUserWebRequestController extends Serializable { * Adds user instance to database by preparing a complete user instance and * sending it to the EJB. The data set in the controller is being verified, * e.g. if the user name or email address is not used yet. + *

+ * @return Redirect outcome */ - void addUser (); + String addUser (); /** * Edits cuirrently loaded user's data in database. + *

+ * @return Redirect outcome */ - void editUserData(); + String editUserData(); /** * Getter for user name diff --git a/web/admin/user/admin_user_edit.xhtml b/web/admin/user/admin_user_edit.xhtml index 33695cb4..90a46c0f 100644 --- a/web/admin/user/admin_user_edit.xhtml +++ b/web/admin/user/admin_user_edit.xhtml @@ -31,7 +31,9 @@ #{msg.ADMIN_PERSONAL_DATA_MINIMUM_NOTICE} - + + +