From: Roland Haeder Date: Fri, 16 Oct 2015 08:53:55 +0000 (+0200) Subject: Moved allShares() to proper bean X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=34654c8de41131dc7b69c37bd313a08557d51da5;p=jfinancials-war.git Moved allShares() to proper bean Signed-off-by:Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java index bfa9288c..c5e0566a 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java @@ -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 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 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 allUsersNotSharing () { // Is the user logged in? diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java index 97995957..96d29412 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java @@ -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 allEntries (final Addressbook addressbook); - /** - * Returns a list of all address books the user is sharing with others. - *

- * @return List of all shared address books - */ - List allShares (); - /** * Size of all entries in given address book *

diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java index 1c34a583..cecf1234 100644 --- a/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java @@ -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 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 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; + } } diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java index bc70057b..4a7baae4 100644 --- a/src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java @@ -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 + *

+ * @return Share instance + */ + ShareableAddressbook getShare (); + + /** + * Setter for share instance + *

+ * @param share Share instance + */ + void setShare (final ShareableAddressbook share); + /** * Checks whether the sharee's user id is set *

@@ -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. + *

+ * @return List of all shared address books + */ + List allShares (); } diff --git a/web/login/login_shared_addressbooks.xhtml b/web/login/login_shared_addressbooks.xhtml index cb56073d..599ad54f 100644 --- a/web/login/login_shared_addressbooks.xhtml +++ b/web/login/login_shared_addressbooks.xhtml @@ -19,7 +19,7 @@ #{msg.LOGIN_TABLE_HEADER_SHARED_ADDRESSBOOKS} - +