Your First Cup: An Introduction to the Java EE Platform

Creating a Resource Bundle

In this section, we'll create the resource bundle that contains the static text and error messages used by the Facelets pages. The firstcup client supports both English and Spanish locales. Therefore we need to create two properties files, each of which will contain the messages for one of the locales.

ProcedureCreating a Resource Bundle

  1. Right-click firstcup in the Projects pane.

  2. Select New -> Other from the popup menu.

  3. Select the Other category, then Properties File from the New File dialog and click Next.

  4. In the New Properties File dialog, enter WebMessages in the File Name field.

  5. In the Folder field, enter src/java/firstcup/web as the location of the file.

  6. Click Finish.

  7. After NetBeans IDE creates the properties file, enter the following messages or copy them from here to the file:


    Welcome=Hi. My name is Duke. Let us find out who is older -- You or me. 
    DukeIs=Duke is
    YearsOldToday=years old today.
    Instructions=Enter your birthday and click submit.
    YourBD=Your birthday
    Pattern=MM/dd/yyyy
    DateError=Please enter the date in the form MM/dd/yyyy.
    YouAre=You are 
    Year=year
    Years=years
    Older=older than Duke!
    Younger=younger than Duke!
    SameAge= the same age as Duke!
    Submit=Submit
    Back=Back
    AverageAge=The average age difference of all First Cup users is

    These messages will be referenced from the XHTML pages.

  8. Save the file by selecting File -> Save from the menu.

  9. To add the Spanish translations of the messages, copy the properties file WebMessages_es.properties from tut-install/firstcup/example/firstcup/src/java/com/sun/firstcup/web to tut-install/firstcup/myexample/firstcup/src/java/firstcup/web.

    You can create multiple properties files, each with a set of messages for a different locale. By storing localized static text and messages in resource bundles, you don't need to create a separate set of XHTML pages for each locale.