Pass Arguments to the Messages Bundle


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // 1) Modify your message to receive the argument (or multiple arguments… just // increase the argument number)….
  2. AIRTEST=Hey {0}, what is up?
  3.  
  4. //2) Inject the Messages bundle as you probably are already doing…
  5. @In
  6. Map<String, String> messages = null;
  7.  
  8.  
  9. //3) Use java.text.MessageFormat to perform the parse (Note: The Object [] can //receive various datatypes. For more info lookup MessageFormat)...
  10. MessageFormat.format( messages.get( "AIRTEST" ), new Object[] {"Chuck"} )

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.