First create a "message.properties
" file in Resources/Files/. Example:
##############
# Test message.properties
##############
label.age=Enter your age:
validate.error.reqired.age=Sorry, but you have to give away the secret of your age ...
Next, connect the resource with your XPage or Custom Control:
<xp:this.resources>
<xp:bundle src="/messages.properties" var="appMsg" />
....
</xp:this.resources>
Note: The "var" defines the name you want to use in your XPages or Custom Controls to reference the message map.
Now you can use the message map with server-side JavaScript (#{javascript:appMsg.getString('...')}
) or with EL (#{appMsg['...']}
).
Example usage:
...
<!-- to show the error message: -->
<xp:messages />
<!-- use with ssjs: -->
<xp:text value="#{javascript:appMsg.getString('label.age')}" escape="false" />
<!-- use with EL: -->
<xe:djNumberSpinner value="#{myDoc.age}" maxLength="2" javaType="int">
<xp:this.validators>
<xp:validateRequired message="#{appMsg['validate.error.reqired.age']}" />
</xp:this.validators>
</xe:djNumberSpinner>
...