| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>3.4. Message Properties</title><link rel="stylesheet" href="css/stylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.0"><link rel="home" href="index.html" title="Apache Click"><link rel="up" href="ch03.html" title="Chapter 3. Controls"><link rel="prev" href="ch03s03.html" title="3.3. Control Classes"><link rel="next" href="ch03s05.html" title="3.5. Control HEAD Elements"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.4. Message Properties</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Controls</th><td width="20%" align="right"> <a accesskey="n" href="ch03s05.html">Next</a></td></tr></table><hr></div><div class="sect1" title="3.4. Message Properties"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="control-message-properties"></a>3.4. Message Properties</h2></div></div></div><p>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. |
| </p><div class="sect2" title="3.4.1. Message Resolution"><div class="titlepage"><div><div><h3 class="title"><a name="message-resolution"></a>3.4.1. Message Resolution</h3></div></div></div><p>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: |
| </p><div class="variablelist"><dl><dt><span class="term"><span class="bold"><strong>Page scope messages</strong></span></span></dt><dd><p>Message lookups are first resolved to the Page classes message |
| bundle if it exists. For example a <code class="classname">Login</code> page |
| may define the message properties: |
| </p><div class="literallayout"><p>/com/mycorp/page/Login.properties</p></div><p>If you want to tailor messages for a particular page this is |
| where to place them. |
| </p></dd><dt><span class="term"><span class="bold"><strong>Global page scope messages</strong></span></span></dt><dd><p>Next message lookups are resolved to the global pages message |
| bundle if it exists. |
| </p><div class="literallayout"><p>/click-page.properties</p></div><p>If you want messages to be used across your entire application |
| this is where to place them. |
| </p></dd><dt><span class="term"><span class="bold"><strong>Control scope messages</strong></span></span></dt><dd><p>Next message lookups are resolved to the Control classes |
| message bundle if it exists. For example a |
| <code class="classname">CustomTextField</code> control may define the |
| message properties: |
| </p><div class="literallayout"><p>/com/mycorp/control/CustomTextField.properties</p></div><p>A custom control's messages can be placed here |
| (or the global control scope covered next) and overridden by one of the |
| above options. |
| </p></dd><dt><span class="term"><span class="bold"><strong>Global control scope messages</strong></span></span></dt><dd><p>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: |
| </p><div class="literallayout"><p>/click-control.properties</p></div><p>Control messages can be placed here and overridden by one of |
| the above options. |
| </p></dd></dl></div></div><div class="sect2" title="3.4.2. Control Properties"><div class="titlepage"><div><div><h3 class="title"><a name="control-properties"></a>3.4.2. Control Properties</h3></div></div></div><p>To customize the <code class="filename">click-control.properties</code> simply |
| add this file to your classpath and tailor the specific values. |
| </p><p>Note when customizing the message properties you must include all |
| the properties, not just the ones you want to override. |
| </p><div class="literallayout"><p># Click Control messages<br> |
| field-maxlength-error={0} must be no longer than {1} characters<br> |
| field-minlength-error={0} must be at least {1} characters<br> |
| field-required-error=You must enter a value for {0}<br> |
| <br> |
| file-required-error=You must enter a filename for {0}<br> |
| <br> |
| label-required-prefix=<br> |
| label-required-suffix=<span class="required">*</span><br> |
| label-not-required-prefix=<br> |
| label-not-required-suffix=&nbsp;<br> |
| <br> |
| not-checked-error=You must select {0}<br> |
| <br> |
| number-maxvalue-error={0} must not be larger than {1}<br> |
| number-minvalue-error={0} must not be smaller than {1}<br> |
| <br> |
| select-error=You must select a value for {0}<br> |
| <br> |
| table-first-label=First<br> |
| table-first-title=Go to first page<br> |
| table-previous-label=Prev<br> |
| table-previous-title=Go to previous page<br> |
| table-next-label=Next<br> |
| table-next-title=Go to next page<br> |
| table-last-label=Last<br> |
| table-last-title=Go to last page<br> |
| table-goto-title=Go to page<br> |
| table-page-banner=<span class="pagebanner">{0} items found, displaying {1} to {2}.</span><br> |
| table-page-banner-nolinks=<br> |
| <span class="pagebanner-nolinks">{0} items found, displaying {1} to {2}.</span><br> |
| table-page-links=<span class="pagelinks">[{0}/{1}] {2} [{3}/{4}]</span><br> |
| table-page-links-nobanner=<span class="pagelinks-nobanner">[{0}/{1}] {2} [{3}/{4}]</span><br> |
| table-no-rows-found=No records found.<br> |
| <br> |
| table-inline-first-image=/click/paging-first.gif<br> |
| table-inline-first-disabled-image=/click/paging-first-disabled.gif<br> |
| table-inline-previous-image=/click/paging-prev.gif<br> |
| table-inline-previous-disabled-image=/click/paging-prev-disabled.gif<br> |
| table-inline-next-image=/click/paging-next.gif<br> |
| table-inline-next-disabled-image=/click/paging-next-disabled.gif<br> |
| table-inline-last-image=/click/paging-last.gif<br> |
| table-inline-last-disabled-image=/click/paging-last-disabled.gif<br> |
| table-inline-page-links=Page {0} {1} {2} {3} {4}<br> |
| <br> |
| # Message displayed when a error occurs when the application is in "production" mode<br> |
| production-error-message=<br> |
| <div id='errorReport' class='errorReport'>The application encountered an unexpected error.<br> |
| </div><br> |
| </p></div></div><div class="sect2" title="3.4.3. Accessing Messages"><div class="titlepage"><div><div><h3 class="title"><a name="accessing-messages"></a>3.4.3. Accessing Messages</h3></div></div></div><p>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: |
| </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> |
| <a xmlns:fo="http://www.w3.org/1999/XSL/Format" class="external" href="../../click-api/org/apache/click/control/AbstractControl.html#getMessage(java.lang.String)" target="_blank">getMessage(String)</a> |
| </p></li><li class="listitem"><p> |
| <a xmlns:fo="http://www.w3.org/1999/XSL/Format" class="external" href="../../click-api/org/apache/click/control/AbstractControl.html#getMessage(java.lang.String,%20java.lang.Object...)" target="_blank">getMessage(String, Object...)</a> |
| </p></li><li class="listitem"><p> |
| <a xmlns:fo="http://www.w3.org/1999/XSL/Format" class="external" href="../../click-api/org/apache/click/control/AbstractControl.html#getMessages()" target="_blank">getMessages()</a> |
| </p></li><li class="listitem"><p> |
| <a xmlns:fo="http://www.w3.org/1999/XSL/Format" class="external" href="../../click-api/org/apache/click/control/Field.html#setErrorMessage(java.lang.String)" target="_blank">setErrorMessage(String)</a> |
| - this method is defined on the Field class |
| </p></li><li class="listitem"><p> |
| <a xmlns:fo="http://www.w3.org/1999/XSL/Format" class="external" href="../../click-api/org/apache/click/control/Field.html#setErrorMessage(java.lang.String,%20java.lang.Object)" target="_blank">setErrorMessage(String, Object)</a> |
| - this method is defined on the Field class |
| </p></li></ul></div><p>These methods use the <code class="literal">Locale</code> of the request to |
| lookup the string resource bundle, and use <code class="classname">MessageFormat</code> |
| for any string formatting. |
| </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.3. Control Classes </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.5. Control HEAD Elements</td></tr></table></div></body></html> |