i18n n Stuff - learn-struts-fast/struts-tutorials GitHub Wiki

Add this to the top of your RpsAction:

@ExceptionMapping(exception="java.lang.NullPointerException", result = "error")

Welcome to Day IV!!!

Let's start today with a little review quiz.

Take 15 minutes to go through the quiz. That's like 70 seconds a question. So no thinking!

We will take up the quiz at about 9:45? 9:50?

Today Agenda

Here's what we're up to today:

  • Quiz
  • i18n demo
  • resource bundle lectures
  • THE CD APPLICATION LAB!!!

i18n and ApplicationResources demo

Today's main topic is i18n.

To take an annotation based approach to Struts, these two init params must be added to the web.xml file.

Example web.xml with i18n and devMode params

<init-param>
   <param-name>struts.custom.i18n.resources</param-name>
   <param-value>ApplicationResources</param-value>
</init-param>  
        
<init-param>
   <param-name>struts.devMode</param-name>
   <param-value>true</param-value>
</init-param>

I'd like you to add the following files to the root of the resources folder of the Roshambo app:

In the com.mcnz.struts package, under the resources folder, add the following two files:

In the RpsAction.properties add the line:

action.greeting=Thank you for coming to the Rock Paper Scissors Page.

Then, in the rps.jsp page put a variety of tags to invoke each action:

<s:textfield key="action.greeting" />
<s:text name="action.greeting" /><br/>

<s:text name="package.greeting" /><br/>
<s:text name="global.greeting" /><br/><br/>

Change the language

You can change the language to French with the following link. Add this code to the bottom of the page:

<s:url action="display"  var="displayFrenchPageLink">
  <s:param name="request_locale">fr</s:param>
</s:url>

Error Pages

Would it be too much to ask to add this error page to our application?

⚠️ **GitHub.com Fallback** ⚠️