From: Roland Häder Date: Fri, 10 Jun 2016 12:55:14 +0000 (+0200) Subject: Rewrites: (please cherry-pick also) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8df86f92bfdf0513194ace9d23670839223633d2;p=jjobs-war.git Rewrites: (please cherry-pick also) - rewrote templateType to baseTemplatePathName which allows more "complex" paths than just simple - imprint, terms and privacy can now make usage of that new variable and don't need to be shown in new browser window Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionBean.java index 899d64f9..473f2db5 100644 --- a/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionBean.java @@ -37,6 +37,7 @@ import org.mxchange.jusercore.container.login.LoginContainer; import org.mxchange.jusercore.container.login.UserLoginContainer; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.login.UserLoginEvent; +import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent; import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.exceptions.UserPasswordMismatchException; @@ -62,18 +63,24 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J /** * Path name for guest base template */ - private static final String GUEST_BASE_TEMPLATE_NAME = "guest/guest"; //NOI18N + private static final String GUEST_BASE_TEMPLATE_NAME = "guest/guest"; /** * Path name for logged-in user base template */ - private static final String USER_BASE_TEMPLATE_NAME = "login/user/user"; //NOI18N + private static final String USER_BASE_TEMPLATE_NAME = "login/user/user"; /** * Serial number */ private static final long serialVersionUID = 47_828_986_719_691_592L; + /** + * Template type for pages that might be displayed in guest area and login + * area. + */ + private String baseTemplatePathName; + /** * Current password */ @@ -85,28 +92,42 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J private User loggedInUser; /** - * User controller + * Remote register session bean */ - @Inject - private JobsUserWebSessionController userController; + private UserLoginSessionBeanRemote loginBean; /** - * Event being fired when user logs in + * Event fired when user has logged in */ @Inject @Any private Event loginEvent; /** - * EJB for user-login + * User controller */ - private UserLoginSessionBeanRemote userLoginBean; + @Inject + private JobsUserWebSessionController userController; /** * Flag whether the user has logged-in, set only from inside */ private boolean userLoggedIn; + /** + * Event fired when user has logged in + */ + @Inject + @Any + private Event userLoginEvent; + + /** + * Event fired when user has logged out + */ + @Inject + @Any + private Event userLogoutEvent; + /** * User's password history */ @@ -126,7 +147,7 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J Context context = new InitialContext(); // Try to lookup - this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/jjobs-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N + this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N // Also find this this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup(""); //NOI18N @@ -188,7 +209,7 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J try { // Call bean - User confirmedUser = this.userLoginBean.validateUserAccountStatus(container); + User confirmedUser = this.loginBean.validateUserAccountStatus(container); // All fine here so set it here this.setLoggedInUser(confirmedUser); @@ -197,10 +218,13 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J this.userPasswordHistory = this.userPasswordHistoryBean.getUserPasswordHistory(confirmedUser); // Set template to "login" - this.setTemplateType("login"); //NOI18N + this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME); //NOI18N // Fire event away. Keep this last before return statement. - this.loginEvent.fire(new UserLoginEvent(confirmedUser)); + this.userLoginEvent.fire(new UserLoginEvent(confirmedUser)); + + // Clear this bean + this.clear(); // All fine return "login"; //NOI18N @@ -215,6 +239,16 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J } } + @Override + public String getBaseTemplatePathName () { + return this.baseTemplatePathName; + } + + @Override + public void setBaseTemplatePathName (final String baseTemplatePathName) { + this.baseTemplatePathName = baseTemplatePathName; + } + @Override public String getCurrentPassword () { return this.currentPassword; @@ -306,15 +340,9 @@ public class JobsUserLoginWebSessionBean extends BaseJobsController implements J @Override public boolean isUserLoggedIn () { - // Trace message - // NOISY-DEBUG System.out.println(MessageFormat.format("JobsUserLoginWebSessionBean:isUserLoggedIn: this.loggedInUser={0},this.templateType={1} - CALLED!", this.getLoggedInUser(), this.getTemplateType())); - // Compare instance this.userLoggedIn = ((this.getLoggedInUser() instanceof User) && (Objects.equals(this.getLoggedInUser().getUserAccountStatus(), UserAccountStatus.CONFIRMED))); - // Trace message - // NOISY-DEBUG System.out.println(MessageFormat.format("JobsUserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn)); - // Return it return this.userLoggedIn; } diff --git a/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionController.java b/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionController.java index 3a131e88..597a1738 100644 --- a/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/login/JobsUserLoginWebSessionController.java @@ -49,18 +49,18 @@ public interface JobsUserLoginWebSessionController extends Serializable { boolean isPasswordInHistory (final String userPassword); /** - * Getter for template type + * Getter for base template type *

* @return Template type */ - String getTemplateType (); + String getBaseTemplatePathName (); /** - * Setter for template type + * Setter for base template type *

- * @param templateType Template type + * @param baseTemplatePathName Template type */ - void setTemplateType (final String templateType); + void setBaseTemplatePathName (final String baseTemplatePathName); /** * Logout for administrator area. If a logged-in user instance exists, it is diff --git a/web/WEB-INF/templates.dist/guest_login_page.xhtml b/web/WEB-INF/templates.dist/guest_login_page.xhtml index f014ab4e..eb4dd328 100644 --- a/web/WEB-INF/templates.dist/guest_login_page.xhtml +++ b/web/WEB-INF/templates.dist/guest_login_page.xhtml @@ -2,12 +2,12 @@ + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:f="http://xmlns.jcp.org/jsf/core" + > - + #{msg.PAGE_TITLE_INDEX_FOO} diff --git a/web/WEB-INF/templates/login/user/user_footer.tpl b/web/WEB-INF/templates/login/user/user_footer.tpl index bafe6e1b..73d6d5e7 100644 --- a/web/WEB-INF/templates/login/user/user_footer.tpl +++ b/web/WEB-INF/templates/login/user/user_footer.tpl @@ -10,17 +10,23 @@ -

+ + + - + + + - + + + diff --git a/web/guest/user/user_list.xhtml b/web/guest/user/user_list.xhtml index 18ffc7a2..ba581916 100644 --- a/web/guest/user/user_list.xhtml +++ b/web/guest/user/user_list.xhtml @@ -6,7 +6,7 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> - + #{msg.PAGE_TITLE_USER_LIST} diff --git a/web/guest/user/user_profile.xhtml b/web/guest/user/user_profile.xhtml index 89a917f5..e57c5865 100644 --- a/web/guest/user/user_profile.xhtml +++ b/web/guest/user/user_profile.xhtml @@ -13,7 +13,7 @@ - + #{msg.PAGE_TITLE_LOGIN_USER_PROFILE} #{msg.PAGE_TITLE_INDEX_USER_PROFILE} diff --git a/web/imprint.xhtml b/web/imprint.xhtml index 5b07b596..5578d959 100644 --- a/web/imprint.xhtml +++ b/web/imprint.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core" > - + #{msg.PAGE_TITLE_INDEX_IMPRINT} diff --git a/web/privacy.xhtml b/web/privacy.xhtml index 52ae8127..6cb3893e 100644 --- a/web/privacy.xhtml +++ b/web/privacy.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core" > - + #{msg.PAGE_TITLE_INDEX_PRIVACY} diff --git a/web/terms.xhtml b/web/terms.xhtml index 69708a0f..1e7acae5 100644 --- a/web/terms.xhtml +++ b/web/terms.xhtml @@ -7,7 +7,7 @@ xmlns:f="http://xmlns.jcp.org/jsf/core" > - + #{msg.PAGE_TITLE_INDEX_TERMS}