How to implement variable screen messages which require internationalization

From IHE Wiki
Jump to navigation Jump to search

It is possible that screen messages may vary depending upon the context or user permissions - and also need to be internationalized. In some cases this can be accomplished by having two or more tags in the .xhtml file and rendering only the one appropriate to the situation. Here is an example of a page title parameter which changes based on whether the user has MasterModel edit permissions and is also internationalized. The .xhtml code:


<ui:param name="pageNameTitle" value="#{domainManagerBean.lstTitle}"/>

The code in the manager:

   import org.jboss.seam.security.*;


   //************************************* Variable screen messages and labels
   @In private Map <String, String> messages;
   private String lstTitle;
   public String getLstTitle() {return messages.get(lstTitle);}

and in the action method which sets up the screen:

  if (Identity.instance().hasPermission("MasterModel", "edit", null)) {
   	  lstTitle = "gazelle.tf.menu.DomainManagement";
     } else {
   	  lstTitle = "gazelle.tf.menu.DomainBrowsing";
     }

And the prototype for the getLstTitle() method needs to be in the local interface.

It would be possible to set up lstTitle as an @Out and load the internationalized message directly, but this would not work properly if the user chose to change the language while the screen was displayed.