From: Roland Haeder Date: Tue, 20 Oct 2015 08:52:21 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=73562b86271ef24b41eebe5b78c3083ebe11620b;p=jfinancials-war.git Continued: - rewrote isProfileLinkVisible() to not accept an instance and use the current (in bean set) instance instead - well, don't use c:bla in your JSF pages - updated jar(s) Signed-off-by:Roland Häder --- diff --git a/lib/jcontacts-lib.jar b/lib/jcontacts-lib.jar index 4bcab606..811eebff 100644 Binary files a/lib/jcontacts-lib.jar and b/lib/jcontacts-lib.jar differ diff --git a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestBean.java index 5e7d87c3..0869a84b 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestBean.java @@ -69,28 +69,41 @@ public class UserProfileWebRequestBean implements UserProfileWebRequestControlle } @Override - public boolean isProfileLinkVisible (final User user) { + public boolean isProfileLinkVisible () { // Check on user - if (null == user) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { - // Throw NPE again - 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())); //NOI18N - } else if (user.getUserProfileMode() == null) { - // And another NPE ... - throw new NullPointerException("user.userProfileMode is null"); //NOI18N + if (null == this.getUser()) { + /* + * Not set, means wrong invocation of this method as the user + * instance needs to be set first. + */ + throw new NullPointerException("this.user is null"); //NOI18N + } else if (this.getUser().getUserId() == null) { + /* + * If the id number is not set it means that the user instance has + * not been persisted and the JPA has not been flushed. Or a + * "virgin" instance (e.g. from registration) has been used. + */ + throw new NullPointerException("this.user.userId is null"); //NOI18N + } else if (this.getUser().getUserId() < 1) { + /* + * The id number is set invalid for an unknown reason. + */ + throw new IllegalArgumentException(MessageFormat.format("this.user.userId={0} is invalid", this.getUser().getUserId())); //NOI18N + } else if (this.getUser().getUserProfileMode() == null) { + /* + * Possibly an out-dated user profile is being used. This should not + * happen. + */ + throw new NullPointerException("this.user.userProfileMode is null"); //NOI18N } - // Default profile mode is not visible - ProfileMode profileMode = user.getUserProfileMode(); + // Get profile mode from user instance (safe now) + ProfileMode profileMode = this.getUser().getUserProfileMode(); // Check all conditions (except for admin) // TODO: Add admin role somehow? - return ((profileMode.equals(ProfileMode.PUBLIC)) || (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS))); + return ((profileMode.equals(ProfileMode.PUBLIC)) + || (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS))); } @Override @@ -116,6 +129,6 @@ public class UserProfileWebRequestBean implements UserProfileWebRequestControlle } // Ask other method - return this.isProfileLinkVisible(u); + return this.isProfileLinkVisible(); } } diff --git a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestController.java b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestController.java index 5da13a3a..12e04ebd 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestController.java +++ b/src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestController.java @@ -27,13 +27,11 @@ import org.mxchange.jusercore.model.user.User; public interface UserProfileWebRequestController extends Serializable { /** - * Checks if the user profile link is visible - *

- * @param user User instance + * Checks if the current user profile link is visible *

* @return Whether the profile link is visible */ - boolean isProfileLinkVisible (final User user); + boolean isProfileLinkVisible (); /** * Checks if the user profile link is visible diff --git a/web/WEB-INF/templates/generic/user_profile_link.tpl b/web/WEB-INF/templates/generic/user_profile_link.tpl index bef7fcd5..379c763e 100644 --- a/web/WEB-INF/templates/generic/user_profile_link.tpl +++ b/web/WEB-INF/templates/generic/user_profile_link.tpl @@ -3,24 +3,12 @@ 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://java.sun.com/jsf/facelets" - xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"> + xmlns:ui="http://java.sun.com/jsf/facelets"> - - - - - - - - - - - - - - - - + + + + + + diff --git a/web/login/login_start_sharing_addressbook.xhtml b/web/login/login_start_sharing_addressbook.xhtml index d9c930b2..6704fb30 100644 --- a/web/login/login_start_sharing_addressbook.xhtml +++ b/web/login/login_start_sharing_addressbook.xhtml @@ -22,36 +22,31 @@

- - - - - #{msg.USER_ID} - - - - - #{msg.USER_NAME} - - - - - - - #{msg.LOGIN_START_SHARING_TITLE} - - - - - - - - - - - - - + + + + #{msg.USER_ID} + + + + + #{msg.USER_NAME} + + + + + + + #{msg.LOGIN_START_SHARING_TITLE} + + + + + + + + +