beautypg.com

Creating the message.properties file, Creating views using myfaces tag libraries – HP Integrity NonStop H-Series User Manual

Page 449

background image

To create the

MessageFactory.java

file in the

com.hp.empinfo.web

package, complete

the following steps:

1.

Create the

MessageFactory.java

file under the

com.hp.empinfo.web

package, as

explained in the

Creating the Controller for EmpInfo

section in the

Getting Started with

Spring

chapter.

2.

Modify the

MessageFactory.java

file to include the method for receiving messages from

the message bundle.

After modification, the

MessageFactory.java

file must appear as shown:

package com.hp.empinfo.web;

import java.util.*;

import javax.faces.context.FacesContext;

public class MessageFactory {
ResourceBundle bundle;
Locale locale;

public MessageFactory() {
locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
bundle = ResourceBundle.getBundle("com.hp.empinfo.web.message",
locale);
}

public String getMessage(String key) {
return bundle.getString(key);
}
}

Creating the

message.properties

File

The

message.properties

file contains the message strings that are displayed in the views

depending on the logic implemented in the Bean class (

EmpBean.java

).

To create the

message.properties

file in the

com.hp.empinfo.web

package, complete the

following steps:

1.

Create the

message.properties

file in the

com.hp.empinfo.web

package as explained

in the

Creating the

jdbc.properties

File

section in the

Getting Started with Spring

chapter.

2.

Modify the

message.properties

file to include the required message strings.

After modification, the

message.properties

file must appear as shown:

# Registration Page

errorFirstName=Employee First Name can not be less than 2 characters.
errorLastName=Employee Last Name can not be less than 2 characters.
errorEmail=Invalid Email Address.
errorAge=Age cannot exceed 100.
already_registered_msg=Employee already exists.
doesnot_exists_msg=Employee doesnot exists.
deleted_successfully_msg=Employee deleted
incorrect_field_value2_msg=Please give proper field value Retrieve/Delete.

# Message.properties file of JSF
javax.faces.component.UIInput.REQUIRED=Cannot be blank

Creating views using MyFaces tag libraries

To create views using the MyFaces tag libraries involves the following tasks:

1.

Creating Pages folder

2.

Creating JSPs

Example of Integrating MyFaces into Spring

449

This manual is related to the following products: