From afcaa0066c781ab0daca6577a99987db32d7c4a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 13 May 2016 17:03:30 +0200 Subject: [PATCH] Some fixes (careful with cherry-picking): - resenEmailAddress is better, then the same validator can be used to look if the email address is registered - set correct JNDI name for resend-link EJB - ignored some strings for i18n - added message for above email address field - fixed condition check MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../JobsResendLinkWebSessionBean.java | 2 +- .../user/JobsUserWebSessionController.java | 8 -------- .../JobsEmailAddressValidator.java | 14 +++++++++++-- web/guest/user/resend_link.xhtml | 20 +++++++++++-------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java index 56a04143..33a5f591 100644 --- a/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java @@ -58,7 +58,7 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements Context context = new InitialContext(); // Try to lookup - this.emailBean = (ResendLinkSessionBeanRemote) context.lookup(""); //NOI18N + this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/resendLink!org.mxchange.pizzaapplication.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N } catch (final NamingException e) { // Throw again throw new FaceletException(e); diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java index 92d7d348..623e3fa3 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java @@ -115,14 +115,6 @@ public interface JobsUserWebSessionController extends Serializable { */ boolean isContactFound (final Contact contact); - /** - * Observes events being fired when an administrator has added a new - * contact. - *

- * @param event Event being fired - */ - void afterAdminAddedContact (final AdminAddedContactEvent event); - /** * Checks whether a public user account is registered. This means that at * least one user profile has its flag "public user profile" enabled. diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java index 3cfd3158..b3889b59 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/JobsEmailAddressValidator.java @@ -72,12 +72,13 @@ public class JobsEmailAddressValidator extends BaseStringValidator implements Va //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N // The required field - String[] requiredFields = {"emailAddress", "emailAddressRepeat"}; //NOI18N + String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N // Pre-validation (example: not null, not a string, empty string ...) super.preValidate(context, component, value, requiredFields, false); // Get string from object ... ;-) + // @TODO Add IDN support (GNU lib?) Search for emailAddressRepeat String emailAddress = String.valueOf(value); // Checks if the email address matches a regex ("low-level" check, should also be done by ) @@ -92,11 +93,20 @@ public class JobsEmailAddressValidator extends BaseStringValidator implements Va throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message)); } + // Get client id (aka form id) + String clientId = component.getClientId(); + // Is the email address already registered? - if (this.contactBean.isEmailAddressRegistered(emailAddress)) { + if ((!clientId.endsWith("resendEmailAddress")) && (this.contactBean.isEmailAddressRegistered(emailAddress))) { //NOI18N // Generate message String message = MessageFormat.format("Email address {0} is already registered.", emailAddress); //NOI18N + // No, then abort here + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); + } else if ((clientId.endsWith("resendEmailAddress")) && (!this.contactBean.isEmailAddressRegistered(emailAddress))) { //NOI18N + // Generate message + String message = MessageFormat.format("Email address {0} is not registered.", emailAddress); //NOI18N + // No, then abort here throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message)); } diff --git a/web/guest/user/resend_link.xhtml b/web/guest/user/resend_link.xhtml index 3b872258..6d5c6173 100644 --- a/web/guest/user/resend_link.xhtml +++ b/web/guest/user/resend_link.xhtml @@ -27,22 +27,26 @@ #{msg.RESEND_CONFIRMATION_LINK_LEGEND}

-
- +
+
-
- +
+
- -
- -
+
+ +
+ +
+ +
+