]> git.mxchange.org Git - addressbook-war.git/commitdiff
Why is this stupid JSF so complex? Why can't things be done more easier?
authorRoland Haeder <roland@mxchange.org>
Fri, 30 Oct 2015 14:52:48 +0000 (15:52 +0100)
committerRoland Haeder <roland@mxchange.org>
Fri, 30 Oct 2015 14:52:48 +0000 (15:52 +0100)
src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestBean.java
src/java/org/mxchange/addressbook/beans/profile/UserProfileWebRequestController.java
web/login/login_start_sharing_addressbook.xhtml

index 0bc3169b941dcea8e20dd68bba04f22103444f5f..28e41b1461af9966ea79420e8b54796971d1ac5b 100644 (file)
@@ -131,4 +131,25 @@ public class UserProfileWebRequestBean implements UserProfileWebRequestControlle
                // Ask other method
                return this.isProfileLinkVisible();
        }
+
+       @Override
+       public boolean isProfileLinkVisibleByUser (final User user) {
+               // Is it correctly set?
+               if (null == user) {
+                       // Throw NPE
+                       throw new NullPointerException("user is null");
+               } else if (user.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userId is null");
+               } else if (user.getUserId() < 1) {
+                       // Invalid user id set
+                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId()));
+               }
+
+               // Set user here
+               this.setUser(user);
+
+               // Ask other method
+               return this.isProfileLinkVisible();
+       }
 }
index 12e04ebdecb912344057d2a84b90fc9df9220ddd..dd7a3ac5c62d1590f3f9c75ff62ca73de1f7ece5 100644 (file)
@@ -42,6 +42,15 @@ public interface UserProfileWebRequestController extends Serializable {
         */
        boolean isProfileLinkVisibleById (final Long userId);
 
+       /**
+        * Checks if given user's profile is visible
+        * <p>
+        * @param user User instance to check
+        * <p>
+        * @return Whether the user's profile is visible
+        */
+       boolean isProfileLinkVisibleByUser (final User user);
+
        /**
         * Getter for user instance
         * <p>
index ac7c368aceefc45592f7803136f5f0159703378f..f86110d8833c5b990145c8f697b36ee45e199d69 100644 (file)
@@ -24,7 +24,6 @@
                                        <h:outputText id="userNotLoggedIn" class="notice" value="#{msg.USER_NOT_LOGGED_IN}" rendered="#{not loginController.isUserLoggedIn()}" />
 
                                        <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookController.allUsersNotSharing()}" rendered="#{loginController.isUserLoggedIn() and not empty addressbookController.addressbook and not loginController.isInvisible()}">
-                                               <c:set value="#{user}" target="#{profileController}" property="user" />
 
                                                <h:column>
                                                        <f:facet name="header">#{msg.USER_ID}</f:facet>
@@ -38,7 +37,7 @@
 
                                                <h:column>
                                                        <f:facet name="header">#{msg.LOGIN_START_SHARING_TITLE}</f:facet>
-                                                       <h:form acceptcharset="utf-8" id="startSharing" rendered="#{profileController.isProfileLinkVisible()}">
+                                                       <h:form acceptcharset="utf-8" id="startSharing" rendered="#{profileController.isProfileLinkVisibleByUser(user)}">
                                                                <h:commandButton class="submit" id="submit" value="#{msg.LOGIN_START_SHARING_BUTTON}" action="#{shareController.startSharing(user, addressbookController.addressbook)}" title="#{msg.LOGIN_START_SHARING_BUTTON_TITLE}" />
                                                        </h:form>
                                                </h:column>