Search code examples
jsficefaces

Customize validation message of ice:selectInputDate


I am using selectInputDate component on a JSF Icefaces form as below.

<ice:selectInputDate id="toDateId"
                renderMonthAsDropdown="true" renderYearAsDropdown="true"
                value="#{myBackingBean.toRequestDate}" 
                onkeydown="checkDateMaxLen('myform:toDateId', 'Request To Date');searchOnEnterKeyPress(event)"  
                renderAsPopup="true">
                <f:convertDateTime timeZone="#{dateSelectBB.timeZone}"
                    dateStyle="short" />
                <h:outputText value="(mm/dd/yy)" />
            </ice:selectInputDate>

When I enter an invalid date e.g. "sdsdsds" and tab off to another field I get the error as 'myform:toDateId: 'sdsdsds' is an invalid date. '

How do I remove form and field id names from the message and show the error as below?

'sdsdsds' is an invalid date.

Implementation details: JSF 2.0, Icefaces 2.0.4


Solution

  • You need to put in your message bundle (messages.properties) something like this:

    javax.faces.converter.DateTimeConverter.DATE_detail=Invalid date format.
    

    to overwrite the JSF error messages.

    More details you can see here: http://www.mkyong.com/jsf2/customize-validation-error-message-in-jsf-2-0/

    Hope this helps! :)