]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Some fixes (careful with cherry-picking):
authorRoland Häder <roland@mxchange.org>
Fri, 13 May 2016 15:03:30 +0000 (17:03 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 13 May 2016 19:57:00 +0000 (21:57 +0200)
- 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

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/resendlink/PIzzaResendLinkWebSessionBean.java
src/java/org/mxchange/pizzaapplication/validator/emailaddress/PizzaEmailAddressValidator.java
web/customer/empty_basket.xhtml

index 3c7928fea0e2a6a11e1da6a4ab5a4e7160e53ece..382a6afab1608117c30bf0178097f017e6d6da26 100644 (file)
@@ -58,7 +58,7 @@ public class PIzzaResendLinkWebSessionBean extends BasePizzaController implement
                        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);
index 3d0c9c34eab3a8a2b46d6d2b3e6b31deca365872..8e60cf776ab6eca4451c27725b7b3bb5fe334960 100644 (file)
@@ -72,12 +72,13 @@ public class PizzaEmailAddressValidator extends BaseStringValidator implements V
                //* 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 <f:validatorRegex />)
@@ -92,11 +93,20 @@ public class PizzaEmailAddressValidator extends BaseStringValidator implements V
                        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));
                }
index 0865128c280a22b6f01fdd9496e4c90b365ce356..a27aae9cf58ddeb9e8ec70f2ac89c7bd6eb4bb62 100644 (file)
                                                        <legend title="#{msg.RESEND_CONFIRMATION_LINK_LEGEND_TITLE}">#{msg.RESEND_CONFIRMATION_LINK_LEGEND}</legend>
 
                                                        <div class="table_row">
-                                                               <div class="table_left25">
-                                                                       <h:outputLabel for="emailAddress" value="#{msg.GUEST_RESEND_LINK_ENTER_EMAIL_ADDRESS}" />
+                                                               <div class="table_left">
+                                                                       <h:outputLabel for="resendEmailAddress" value="#{msg.GUEST_RESEND_LINK_ENTER_EMAIL_ADDRESS}" />
                                                                </div>
 
-                                                               <div class="table_right75">
-                                                                       <h:inputText styleClass="input" id="emailAddress" size="20" maxlength="255" value="#{contactController.emailAddress}" required="true" requiredMessage="#{msg.EMAIL_ADDRESS_NOT_ENTERED}">
+                                                               <div class="table_right">
+                                                                       <h:inputText styleClass="input" id="resendEmailAddress" size="20" maxlength="255" value="#{resendController.emailAddress}" required="true" requiredMessage="#{msg.EMAIL_ADDRESS_NOT_ENTERED}">
                                                                                <f:validator validatorId="EmailAddressValidator" />
                                                                        </h:inputText>
                                                                </div>
                                                        </div>
-
-                                                       <div class="table_row">
-                                                               <h:outputText value="#{msg.GUEST_RESEND_CONFIRMATION_LINK_NOTICE}" />
-                                                       </div>
                                                </fieldset>
 
+                                               <div>
+                                                       <h:message for="resendEmailAddress" errorClass="errors" warnClass="warnings" fatalClass="errors" />
+                                               </div>
+
+                                               <div class="table_row">
+                                                       <h:outputText value="#{msg.GUEST_RESEND_CONFIRMATION_LINK_NOTICE}" />
+                                               </div>
+
                                                <div class="table_footer">
                                                        <h:commandButton styleClass="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
                                                        <h:commandButton styleClass="submit" type="submit" id="register" value="#{msg.BUTTON_RESEND_CONFIRMATION_LINK}" action="#{resendController.doResendLink()}" />