prefix_locale.properties
error01=The specified value is too short.
Optionally, you can include inserts in the message. Inserts are represented by an integer in braces and will be replaced with a value you specify when you display the error message. Error messages can contain several inserts per message, numbered such as {0}, {1}, and {2}.
error02=The specified value is shorter than five characters: {0}
<h:inputText id="inputComponent"
styleClass="inputText"
value="#{errorMessageTest.inputString}"
binding="#{errorMessageTest.inputString_Ref}">
</h:inputText>
<h:message id="message1"
styleClass="message"
for="inputComponent">
</h:message>
handler errorMessageTest type JSFHandler
{view = "errorMessageTest.jsp",
msgResource = "resourceBundle"}
In this case, the resource
bundle is named resourceBundle_en_US.properties and
so the msgResource property is set to resourceBundle.SysLib.setError(inputString, "",
"This is the text of the error message.");
SysLib.setError(inputString, "error02", inputString);
This
example assumes a resource bundle with a message definition similar
to this example:error02=The specified value is shorter than five characters: {0}
errorMessageString string =
sysLib.getMessage("error03", [inputString, "five"]);
SysLib.setError(inputString, "", errorMessageString);
This
example assumes an error message in the resource bundle with two inserts,
as in this example:error03=The string {0} is too short.
It must be at least {1} characters long.
SysLib.setErrorForComponentId("form1:inputComponent",
"error01", inputString);
This example assumes an input
component on the page with the ID inputComponent and
a display error component associated with it. It also assumes a message
in the resource bundle with a key error01, similar
to the previous examples.SysLib.setError("The string is too short.");
handler errorMessageTest type JSFHandler
{view = "errorMessageTest2.jsp",
msgResource = "resourceBundle"}
inputString string;
function validateString()
if (StrLib.characterLen(inputString) < 5)
SysLib.setError(inputString, "error02", inputString);
end
end
end
This example assumes that the inputString variable
is bound to an input component on the associated web page which is
associated with an error message component, as explained above. Also,
it assumes a resource bundle named resourceBundle_locale.properties,
where locale is the locale code of the language
you are using. The example uses a message in that resource bundle
file similar to the following:error02=The specified value is shorter than five characters: {0}
JSF can also set the values of error message components as part of user input validation.