Control strings for field validation messages and HTML formatting strings are externalized in the properties file. By using these properties files you can localize a Click application for your particular language and dialect.
Messages are looked up in a particular order enabling taylor specific messages, for your controls, individual pages or across your entire application. The order in which localized messages are resolved is:
Message lookups are first resolved to the Page classes message
bundle if it exists. For example a Login
page
may define the message properties:
/com/mycorp/page/Login.properties
If you want to tailor messages for a particular page this is where to place them.
Next message lookups are resolved to the global pages message bundle if it exists.
/click-page.properties
If you want messages to be used across your entire application this is where to place them.
Next message lookups are resolved to the Control classes
message bundle if it exists. For example a
CustomTextField
control may define the
message properties:
/com/mycorp/control/CustomTextField.properties
A custom control's messages can be placed here (or the global control scope covered next) and overridden by one of the above options.
Finally message lookups are resolved to the global application control message bundle if the message has not already been found. The global control properties file is:
/click-control.properties
Control messages can be placed here and overridden by one of the above options.
To customize the click-control.properties
simply
add this file to your classpath and tailor the specific values.
Note when customizing the message properties you must include all the properties, not just the ones you want to override.
# Click Control messages
field-maxlength-error={0} must be no longer than {1} characters
field-minlength-error={0} must be at least {1} characters
field-required-error=You must enter a value for {0}
file-required-error=You must enter a filename for {0}
label-required-prefix=
label-required-suffix=<span class="required">*</span>
label-not-required-prefix=
label-not-required-suffix=
not-checked-error=You must select {0}
number-maxvalue-error={0} must not be larger than {1}
number-minvalue-error={0} must not be smaller than {1}
select-error=You must select a value for {0}
table-first-label=First
table-first-title=Go to first page
table-previous-label=Prev
table-previous-title=Go to previous page
table-next-label=Next
table-next-title=Go to next page
table-last-label=Last
table-last-title=Go to last page
table-goto-title=Go to page
table-page-banner=<span class="pagebanner">{0} items found, displaying {1} to {2}.</span>
table-page-banner-nolinks=
<span class="pagebanner-nolinks">{0} items found, displaying {1} to {2}.</span>
table-page-links=<span class="pagelinks">[{0}/{1}] {2} [{3}/{4}]</span>
table-page-links-nobanner=<span class="pagelinks-nobanner">[{0}/{1}] {2} [{3}/{4}]</span>
table-no-rows-found=No records found.
table-inline-first-image=/click/paging-first.gif
table-inline-first-disabled-image=/click/paging-first-disabled.gif
table-inline-previous-image=/click/paging-prev.gif
table-inline-previous-disabled-image=/click/paging-prev-disabled.gif
table-inline-next-image=/click/paging-next.gif
table-inline-next-disabled-image=/click/paging-next-disabled.gif
table-inline-last-image=/click/paging-last.gif
table-inline-last-disabled-image=/click/paging-last-disabled.gif
table-inline-page-links=Page {0} {1} {2} {3} {4}
# Message displayed when a error occurs when the application is in "production" mode
production-error-message=
<div id='errorReport' class='errorReport'>The application encountered an unexpected error.
</div>
Controls support a hierarchy of resource bundles for displaying validation error messages and display messages. These localized messages can be accessed through the AbstractControl methods:
setErrorMessage(String) - this method is defined on the Field class
setErrorMessage(String, Object) - this method is defined on the Field class
These methods use the Locale
of the request to
lookup the string resource bundle, and use MessageFormat
for any string formatting.