How to change the required message in JSF without overwriting the asterisk?

Siu Lung Leung Source

I have a JSF form that looks like this:

Original form

When the user enables email notification, the email address becomes a required field as shown in the screenshot. I want to change the "Value is required" message such that it says "Value is required when email notification is enabled". After extensive Googling, the only solution is to use the requiredMessage attribute in the inputText. This is the result:

Form with requiredMessage

I just want the message on top to change. I don't want the asterisk to be replaced by the message. Is there a way to accomplish that?

This the is original code.

<n:dynamicPanelElement id="EmailIdContact">
    <a4j:outputPanel id="EmailLabelBlock" layout="block">
        <h:outputText value="#{text.EmailId}#{global.LabelEnd}" styleClass="FormLabel"  rendered="#{(not security.backEndAvailable) && (not newBankUserController.newUsersEmailAddressMandatory && newBankUserController.optOutEmail)}"/>
        <h:outputText value="#{text.EmailId}#{global.LabelEnd}#{global.Required}" styleClass="FormLabel"  rendered="#{(not security.backEndAvailable) && (newBankUserController.newUsersEmailAddressMandatory || not newBankUserController.optOutEmail)}"/>
    <n:inputText size="30" maxlength="128" id="EmailIdContactInput" value="#{}" required="#{newBankUserController.newUsersEmailAddressMandatory || not newBankUserController.optOutEmail}" styleClass="FormValue" disabled="false" onfocus="selectFieldText(this);"  rendered="#{not security.backEndAvailable}" >
        <f:attribute name="fieldRef" value="#{text.EmailId}"/>
        <f:validator validatorId="NcrEmailValidator" />
    <h:message for="EmailIdContactInput" showDetail="false" showSummary="true" styleClass="FormError"  rendered="#{not security.backEndAvailable}"/>                                                    

Any help is greatly appreciated!



comments powered by Disqus