//* 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 />)
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));
}
<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()}" />