Summary
Tag name:
<tr:validateByteLength>
type:
org.apache.myfaces.trinidad.ByteLength
Validates the byte length of strings when encoded. The "maximumLength" attribute of inputText is similar, but it limits the number of characters that the user can enter. In some circumstances, the server must also limit the number of bytes required to store the string. This is very undesirable from a user interface perspective, since it is difficult for users to understand why they might be able to enter only 2 Japanese characters but 6 English characters! However, in cases where the backend will report this as an error anyway, it is better to report the problem before.
The element allows developers to specify the encoding that should be used to define the byte length. This must be an encoding supported by the Java runtime, if not it will result in an exception and not a validation failure
If the encoding is supported by JVM, and is a encoding that is not supported in the client side, then client side validation is disabled for this instance, while server side validation will continue to take place.
The list of encodings that can be supported at the client side is as given below. Note: All the encodings listed might not be supported by JVM, and there can be other encodings, which the JVM may support, but might not be supported at the client side.
Supported encodings are grouped as UTF-8, CJK encodings and Single byte encodings. Supported client side CJK encodings and Single byte encodings table:
Single Byte Encodings | CJK Encodings |
---|---|
ascii | shift_jis |
iso646-us | ms_kanji |
iso_8859-1:1987 | csshiftjis |
iso-ir-100 | windows-31j |
iso_8859-1 | cswindows31j |
iso-8859-1 | ks_c_5601-1987 |
latin1 | iso-ir-149 |
l1 | ks_c_5601-1989 |
ibm819 | ksc_5601 |
cp819 | korean |
csisolatin1 | csksc56011987 |
iso_8859-2:1987 | euc-kr |
iso-ir-101 | cseuckr |
iso_8859-2 | windows-949 |
iso-8859-2 | gb2312 |
latin2 | csgb2312 |
l2 | chinese |
csisolatin2 | csiso58gb231280 |
iso_8859-3:1988 | hz-gb-2312 |
iso-ir-109 | gbk |
iso_8859-3 | cp936 |
iso-8859-3 | ms936 |
latin3 | windows-936 |
l3 | big5 |
csisolatin3 | csbig5 |
iso_8859-4:1988 | windows-950 |
iso-ir-110 | |
iso_8859-4 | |
iso-8859-4 | |
latin4 | |
l4 | |
csisolatin4 | |
iso_8859-5:1988 | |
iso-ir-144 | |
iso_8859-5 | |
iso-8859-5 | |
cyrillic | |
csisolatincyrillic | |
iso_8859-6:1987 | |
iso-ir-127 | |
iso_8859-6 | |
iso-8859-6 | |
ecma-114 | |
asmo-708 | |
arabic | |
csisolatinarabic | |
iso_8859-7:1987 | |
iso-ir-126 | |
iso_8859-7 | |
iso-8859-7 | |
elot_928 | |
ecma-118 | |
greek | |
greek8 | |
csisolatingreek | |
iso_8859-8:1988 | |
iso-ir-138 | |
iso_8859-8 | |
iso-8859-8 | |
hebrew | |
csisolatinhebrew | |
iso-ir-148 | |
iso_8859-9 | |
iso-8859-9 | |
latin5 | |
l5 | |
csisolatin5 | |
iso-8859-13 | |
iso-8859-15 | |
iso_8859-15 | |
ibm037 | |
cp037 | |
ibm273 | |
cp273 | |
ibm277 | |
ibm278 | |
cp278 | |
278 | |
ibm280 | |
cp280 | |
ibm284 | |
cp284 | |
ibm285 | |
cp285 | |
ibm297 | |
cp297 | |
ibm420 | |
cp420 | |
420 | |
ibm424 | |
cp424 | |
ibm437 | |
cp437 | |
437 | |
cspc8codepage437 | |
ibm500 | |
cp500 | |
ibm775 | |
cp775 | |
ibm850 | |
cp850 | |
850 | |
cspc850multilingual | |
ibm852 | |
cp852 | |
852 | |
cspcp852 | |
ibm855 | |
cp855 | |
855 | |
cspcp855 | |
ibm857 | |
cp857 | |
857 | |
csibm857 | |
ibm860 | |
cp860 | |
860 | |
csibm860 | |
ibm861 | |
cp861 | |
cp-is | |
861 | |
csibm861 | |
ibm862 | |
cp862 | |
862 | |
cspc862latinhebrew | |
ibm863 | |
cp863 | |
863 | |
csibm863 | |
ibm864 | |
cp864 | |
csibm864 | |
ibm865 | |
cp865 | |
865 | |
csibm865 | |
ibm866 | |
cp866 | |
866 | |
csibm866 | |
ibm868 | |
cp868 | |
ibm869 | |
cp869 | |
869 | |
cp-gr | |
csibm869 | |
ibm870 | |
cp870 | |
ibm871 | |
cp871 | |
ibm918 | |
cp918 | |
ibm1026 | |
cp1026 | |
windows-1250 | |
windows-1251 | |
windows-1252 | |
windows-1253 | |
windows-1254 | |
windows-1255 | |
windows-1256 | |
windows-1257 | |
windows-1258 | |
koi8-r | |
cskoi8r |
Example(s):
<tr:inputText value="Four" label="Byte Length validation"> <tr:validateByteLength encoding="ISO-8859-1" maximum="4"/> </tr:inputText>
Attributes
Name | Type | Supports EL? | Description |
---|---|---|---|
encoding | String | Yes | the Java encoding used for the string. |
maximum | int | Yes | maximum number of allowable bytes when the string is encoded |
messageDetailMaximum | String | Yes | Custom error message to be used, for creating detail part of faces message, when conversion fails for input that exceeds the maximum byte length. Parameters:
|