- added more fields, such as address book user (=owner), when it has been created
- added event observer method for when an address book has been loaded and forward that data to the bean
- added some (untested) output of the address book data
Signed-off-by:Roland Häder <roland@mxchange.org>
<Node id="login/login_edit_user_data.xhtml" x="1150" y="150" zoom="true"/>
<Node id="user/lost_passwd.xhtml" x="900" y="300" zoom="true"/>
<Node id="*" x="650" y="150" zoom="true"/>
- <Node id="terms.xhtml" x="150" y="600" zoom="true"/>
<Node id="login/login_own_addressbooks.xhtml" x="400" y="150" zoom="true"/>
+ <Node id="terms.xhtml" x="150" y="600" zoom="true"/>
<Node id="user/register_done.xhtml" x="1150" y="300" zoom="true"/>
<Node id="bye.xhtml" x="650" y="300" zoom="true"/>
<Node id="login/login_shared_addressbooks.xhtml" x="1150" y="450" zoom="true"/>
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.mxchange.addressbook.beans.login.UserLoginWebController;
+import org.mxchange.addressbook.events.AddressbookLoadedEvent;
import org.mxchange.addressbook.exceptions.AddressbookNameAlreadyUsedException;
import org.mxchange.addressbook.model.addressbook.Addressbook;
import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
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.model.user.User;
/**
* A user bean (controller)
*/
private Long addressbookId;
-
/**
* Name of the address book
*/
private String addressbookName;
+ /**
+ * When this address book has been created
+ */
+ private Calendar addressbookCreated;
+
+ /**
+ * Who owns this address book
+ */
+ private User addressbookUser;
/**
* Login controller
*/
private List<ShareableAddressbook> sharedAddressbooks;
- /////////////////////// Properties /////////////////////
/**
* A list of all user's address books
*/
// Not logged in
throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
}
-
+
return Collections.unmodifiableList(this.sharedAddressbooks);
}
+ @Override
+ public Calendar getAddressbookCreated () {
+ return this.addressbookCreated;
+ }
+
+ @Override
+ public void setAddressbookCreated (final Calendar addressbookCreated) {
+ this.addressbookCreated = addressbookCreated;
+ }
+
@Override
public Long getAddressbookId () {
return this.addressbookId;
this.addressbookName = addressbookName;
}
+ @Override
+ public User getAddressbookUser () {
+ return this.addressbookUser;
+ }
+
+ @Override
+ public void setAddressbookUser (final User addressbookUser) {
+ this.addressbookUser = addressbookUser;
+ }
+
@Override
public boolean hasCreatedAddressbooks () {
// Is the user logged in?
// Return status
return isFound;
}
+
+ @Override
+ public void afterAddressbookLoaded (final @Observes AddressbookLoadedEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null");
+ } else if (event.getAddressbook() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addressbook is null");
+ } else if (event.getAddressbook().getAddressbookId() == null) {
+ // And again a NPE
+ throw new NullPointerException("event.addressbook.addressbookId is null");
+ } else if (event.getAddressbook().getAddressbookId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException("Address book instance " + event.getAddressbook() + " has invalid id number: " + event.getAddressbook().getAddressbookId());
+ } else if (event.getAddressbook().getAddressbookUser() == null) {
+ // One more NPE ...
+ throw new NullPointerException("event.addressbook.addressbookUser is null");
+ }
+
+ // Get address book instance
+ Addressbook addressbook = event.getAddressbook();
+
+ // Set address book data
+ this.setAddressbookId(addressbook.getAddressbookId());
+ this.setAddressbookName(addressbook.getAddressbookName());
+ this.setAddressbookUser(addressbook.getAddressbookUser());
+ this.setAddressbookCreated(addressbook.getAddressbookCreated());
+ }
}
package org.mxchange.addressbook.beans.addressbook;
import java.io.Serializable;
+import java.util.Calendar;
import java.util.List;
+import org.mxchange.addressbook.events.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.model.user.User;
/**
* An interface for user beans
* @param addressbookId Address book id number
*/
void setAddressbookId (final Long addressbookId);
+
+ /**
+ * Getter for address book user (owner)
+ * <p>
+ * @return Address book user (owner)
+ */
+ User getAddressbookUser ();
+
+ /**
+ * Setter for address book user (owner)
+ * <p>
+ * @param addressbookUser Address book user (owner)
+ */
+ void setAddressbookUser (final User addressbookUser);
+
+ /**
+ * Getter for when the address book has been created
+ * <p>
+ * @return When the address book has been created
+ */
+ Calendar getAddressbookCreated ();
+
+ /**
+ * Setter for when the address book has been created
+ * <p>
+ * @param addressbookCreated When the address book has been created
+ */
+ void setAddressbookCreated (final Calendar addressbookCreated);
+
+ /**
+ * This method is called when an address book has been successfully loaded
+ * from JPA.
+ * <p>
+ * @param event Event with address book instance
+ */
+ public void afterAddressbookLoaded (final AddressbookLoadedEvent event);
}
PARAMETER_USER_ID_INVALID=Der angeklickte Link ist nicht mehr g\u00fcltig: Den Benutzer mit der Id-Nummer existiert nicht (mehr).
PARAMETER_USER_ID_NOT_FOUND=Benutzeraccount mit der Id-Nummer nicht gefunden.
TABLE_HEADER_ERROR_HANDLING_USER_ID=Fehler beim Verarbeiten der Benutzernummer:
+TABLE_HEADER_SHOW_ADDRESSBOOK=Adressbuchdaten:
+LINK_LOGIN_START_SHARING_ADDRESSBOOK=Mit jemandem dieses Adressbuch teilen
+LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE=Dieses Adresssbuch k\u00f6nnen Sie mit einem anderen Benutzer teilen. Dadurch kann er Ihre Kontakte sehen.
PARAMETER_USER_ID_INVALID=The clicked link is no longer valid: The user with provided id number does not exist (anymore).
PARAMETER_USER_ID_NOT_FOUND=User account with given id number not found.
TABLE_HEADER_ERROR_HANDLING_USER_ID=Error while handling user id:
+TABLE_HEADER_SHOW_ADDRESSBOOK=Address book data:
+LINK_LOGIN_START_SHARING_ADDRESSBOOK=Start sharing this address book with another user
+LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE=You can start sharing this address book with anther user. Then he cann see your contacts.
</ui:define>
<ui:define name="content">
- <h:panelGrid headerClass="table_header" footerClass="table_footer" class="table" columns="3">
- ID: #{addressbookController.addressbookId}
- </h:panelGrid>
+ <div class="table_big">
+ <div class="table_header">
+ #{msg.TABLE_HEADER_SHOW_ADDRESSBOOK}
+ </div>
+
+ <div class="para">
+ <h:panelGrid headerClass="table_header" footerClass="table_footer" class="table" columns="3">
+ <h:column>
+ <f:facet name="header">#{msg.ADDRESSBOOK_ID}</f:facet>
+ <h:outputText id="addressbookId" value="#{addressbookController.addressbookId}" />
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">#{msg.ADDRESSBOOK_NAME}</f:facet>
+ <h:outputText id="addressbookName" value="#{addressbookController.addressbookName}" />
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">#{msg.ADDRESSBOOK_OWNER}</f:facet>
+ <h:link id="addressbookUser" outcome="user_profile" value="#{addressbookController.addressbookUser.userName}" />
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">#{msg.ADDRESSBOOK_CREATED}</f:facet>
+ <h:outputFormat id="addressbookCreated" value="#{addressbook.addressbookCreated.time}" title="#{msg.ADDRESSBOOK_CREATED_TITLE}">
+ <f:convertDateTime for="addressbookCreated" type="both" timeStyle="short" dateStyle="medium" />
+ </h:outputFormat>
+ </h:column>
+ </h:panelGrid>
+ </div>
+
+ <div class="table_footer">
+ <ui:fragment rendered="#{addressbookController.isOwnAddressbook()}">
+ <h:link id="startSharing" outcome="login_start_sharing_addressbook" value="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOK}" title="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE}" />
+ </ui:fragment>
+ <ui:fragment rendered="#{addressbookController.isOtherAddressbook()}">
+ Bla bla
+ </ui:fragment>
+ </div>
+ </div>
</ui:define>
</ui:composition>
</html>