]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Moved allShares() to proper bean
authorRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 08:53:55 +0000 (10:53 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 08:53:55 +0000 (10:53 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java
src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java
src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java
web/login/login_shared_addressbooks.xhtml

index bfa9288cf21a6f33cc586a5918e818d11c7c0f25..c5e0566ac8ba4e1bf6f517abbfa45c2acb8fe873 100644 (file)
@@ -41,7 +41,6 @@ import org.mxchange.addressbook.model.addressbook.Addressbook;
 import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
 import org.mxchange.addressbook.model.addressbook.UserAddressbook;
 import org.mxchange.addressbook.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook;
 import org.mxchange.addressbook.model.addressbook.status.AddressbokStatus;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.model.user.User;
@@ -101,11 +100,6 @@ public class AddressbookWebBean implements AddressbookWebController {
        @Inject
        private UserLoginWebController loginController;
 
-       /**
-        * A list of all user's shared (with others) address books
-        */
-       private List<ShareableAddressbook> sharedAddressbooks;
-
        /**
         * A list of all user's address books
         */
@@ -257,17 +251,6 @@ public class AddressbookWebBean implements AddressbookWebController {
                return this.allEntries(addressbook).size();
        }
 
-       @Override
-       public List<ShareableAddressbook> allShares () {
-               // Is the user logged in?
-               if (!this.loginController.isUserLoggedIn()) {
-                       // Not logged in
-                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
-               }
-
-               return Collections.unmodifiableList(this.sharedAddressbooks);
-       }
-
        @Override
        public List<User> allUsersNotSharing () {
                // Is the user logged in?
index 97995957b3d63e3700634261e178e6858b214c26..96d294120f22991da8acb5ed14be712cd794eb8b 100644 (file)
@@ -22,7 +22,6 @@ import java.util.List;
 import org.mxchange.addressbook.events.addressbook.AddressbookLoadedEvent;
 import org.mxchange.addressbook.model.addressbook.Addressbook;
 import org.mxchange.addressbook.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.model.user.User;
 
@@ -89,13 +88,6 @@ public interface AddressbookWebController extends Serializable {
         */
        List<AddressbookEntry> allEntries (final Addressbook addressbook);
 
-       /**
-        * Returns a list of all address books the user is sharing with others.
-        * <p>
-        * @return List of all shared address books
-        */
-       List<ShareableAddressbook> allShares ();
-
        /**
         * Size of all entries in given address book
         * <p>
index 1c34a583ce229690e5a501017313086c31a6fc5f..cecf1234bbc2c12a681b07553b2ad10328f693fa 100644 (file)
@@ -17,6 +17,8 @@
 package org.mxchange.addressbook.beans.shares;
 
 import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.List;
 import java.util.Objects;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.view.facelets.FaceletException;
@@ -57,6 +59,16 @@ public class SharesWebBean implements SharesWebController {
        @Inject
        private UserLoginWebController loginController;
 
+       /**
+        * Share instance
+        */
+       private ShareableAddressbook share;
+
+       /**
+        * A list of all user's shared (with others) address books
+        */
+       private List<ShareableAddressbook> sharedAddressbooks;
+
        /**
         * Remote bean for sharing address books
         */
@@ -156,9 +168,10 @@ public class SharesWebBean implements SharesWebController {
 
                try {
                        // Init sharing
-                       ShareableAddressbook share = this.shareBean.startSharing(user, addressbook);
+                       ShareableAddressbook shared = this.shareBean.startSharing(user, addressbook);
 
                        // TODO Set it here
+                       this.setShare(shared);
                } catch (final UserAlreadySharingAddressbookException ex) {
                        // Throw again
                        throw new FaceletException(ex);
@@ -167,4 +180,25 @@ public class SharesWebBean implements SharesWebController {
                // TODO Unfinished
                return null;
        }
+
+       @Override
+       public List<ShareableAddressbook> allShares () {
+               // Is the user logged in?
+               if (!this.loginController.isUserLoggedIn()) {
+                       // Not logged in
+                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
+               }
+
+               return Collections.unmodifiableList(this.sharedAddressbooks);
+       }
+
+       @Override
+       public ShareableAddressbook getShare () {
+               return this.share;
+       }
+
+       @Override
+       public void setShare (final ShareableAddressbook share) {
+               this.share = share;
+       }
 }
index bc70057bb305ead5af84983ce89251c21b432d84..4a7baae4496a57c383a410dfa888ff2085971e5d 100644 (file)
@@ -17,7 +17,9 @@
 package org.mxchange.addressbook.beans.shares;
 
 import java.io.Serializable;
+import java.util.List;
 import org.mxchange.addressbook.model.addressbook.Addressbook;
+import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook;
 import org.mxchange.jusercore.model.user.User;
 
 /**
@@ -48,6 +50,20 @@ public interface SharesWebController extends Serializable {
         */
        void setShareeUserId (final Long shareeUserId);
 
+       /**
+        * Getter for share instance
+        * <p>
+        * @return Share instance
+        */
+       ShareableAddressbook getShare ();
+
+       /**
+        * Setter for share instance
+        * <p>
+        * @param share Share instance
+        */
+       void setShare (final ShareableAddressbook share);
+
        /**
         * Checks whether the sharee's user id is set
         * <p>
@@ -71,4 +87,11 @@ public interface SharesWebController extends Serializable {
         * @return Redirect target
         */
        String startSharing (final User user, final Addressbook addressbook);
+
+       /**
+        * Returns a list of all address books the user is sharing with others.
+        * <p>
+        * @return List of all shared address books
+        */
+       List<ShareableAddressbook> allShares ();
 }
index cb56073df0e76ec8285d7ff228c83a4361b38eed..599ad54f1df3d2454ff65c0f2c90ff09b77e82ae 100644 (file)
@@ -19,7 +19,7 @@
                                        #{msg.LOGIN_TABLE_HEADER_SHARED_ADDRESSBOOKS}
                                </div>
 
-                               <h:dataTable id="sharedAddressbooks" var="shares" value="#{addressbookController.allShares()}" headerClass="table_data_column" summary="#{msg.TABLE_SUMMARY_LOGIN_SHARED_ADDRESSBOOKS}" rendered="#{shareController.isSharingAddressbooks()}">
+                               <h:dataTable id="sharedAddressbooks" var="shares" value="#{shareController.allShares()}" headerClass="table_data_column" summary="#{msg.TABLE_SUMMARY_LOGIN_SHARED_ADDRESSBOOKS}" rendered="#{shareController.isSharingAddressbooks()}">
                                </h:dataTable>
 
                                <h:outputText class="notice" value="#{msg.LOGIN_USER_HAS_NOT_SHARED_ADDRESSBOOKS}" rendered="#{shareController.isSharingAddressbooks() == false}" />