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;
@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
*/
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?
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;
*/
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>
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;
@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
*/
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);
// 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;
+ }
}
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;
/**
*/
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>
* @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 ();
}
#{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}" />