Home

 

Modifying application resources

The wizard created an empty ApplicationResources.properties file in the rad75strutsweb.resources package, and we have to update it with the texts and messages for our application.

While developing Struts applications, you usually find it helpful to have this file open, because you typically add messages to it as you go along writing your code. Again, this properties file is meant to externalize messages and, more importantly, support i18n (internationalization) for Web site language support. Example | 5-1 shows a completed ApplicationResources.properties file.

Example 15-1 ApplicationResources.properties

# Optional header and footer for <errors/> tag.
#errors.header=<ul>
#errors.footer=</ul>
errors.prefix=<li>
errors.suffix=</li>

form.ssn=SSN
form.accountId=Account Id
form.balance=Balance
form.amount=Amount

form.accountDetails.transactionId=Transaction ID
form.accountDetails.transactionType=Transaction Type
form.accountDetails.transactionTime=Transaction Date-Time
form.accountDetails.transactionAmount=Transaction Amount

form.transaction.amount=Amount

errors.required={0} is a required Field
error.ssn=Verify that the customer ssn entered is correct.
error.amount=Verify that the amount entered is valid.
error.timeout=Your session has timed out. Please login again.
errors.systemError=The system is currently unavailable. Please try again later.

Initially this file only contains an optional header and footer for errors. At this point you can open the file and add two lines:

form.ssn=SSN
errors.required={0} is a required field.

We use this message to validate-using the Struts Validation Framework-the logon form in logon.jsp to ensure that the user enters a value for the customer (SSN).

ibm.com/redbooks