# @jpf:message-resources Annotation

You can use the @jpf:message-resources annotation at the page flow class level to specify a message bundle. Using message resources allows you to internationalize your web applications by not hard-coding labels in your JSP pages. For example, an ErrorMessages.properties resource file could contain messages to display when form validation errors occur.

## Syntax

@jpf:message-resources

resources = "<property-resources>"

[ key = "<bundle-key-name>" ]

## Attributes

resources

Required. A resource that contains message properties, such as an Errors.properties file that you create separately and place in a subfolder under the page flow's /WEB-INF/classes folder. For example:

@jpf:message-resources resources="validation.ErrorMessages"

The page flow runtime will look for the messages in a subfolder of the web project's /WEB-INF folder, either:

- /WEB-INF/classes/validation/ErrorMessages.properties
- Or in a JAR file in /WEB-INF/lib

key

Optional. You can specify the name of the ServletContext attribute in which to store the Bundle read from the <property-resources>. In most cases you can omit this attribute and accept the default of org.apache.struts.Globals.MESSAGE_KEY, which works with the <netui:error> and <netui:errors> JSP tags provided by WebLogic Workshop.

## Remarks

The following rules apply to this annotation's use:

- The message property resource cannot reside in the WEB-INF/... directory of another web project. The *.properties file must reside in a /WEB-INF/classes/<folder>/ directory, or in a JAR in /WEB-INF/lib (in a JAR), for this web project.

- For a sample page flow that demonstrates form validation and the use of the message properties, see the following page flow. Also see the <netui:error> tag used in this sample page flow's JSP files.

<WEBLOGIC_HOME>\samples\workshop\SamplesApp\WebApp\validation\Controller.jpf

- For sample message properties files, see:

<WEBLOGIC_HOME>\samples\workshop\SamplesApp\WebApp\WEB-INF\classes\validation\basic\Messages.properties

and:

<WEBLOGIC_HOME>\samples\workshop\SamplesApp\WebApp\WEB-INF\classes\validation\validator\Messages.properties

Related Topics

@jpf:catch Annotation

@jpf:controller Annotation

@jpf:exception-handler Annotation

@jpf:forward Annotation

@jpf:validation-error-forward Annotation

Getting Started with Page Flows