title: How to read messages and pass parameters to message.properties file in JSF 2.0
body: <p>Suppose i have a messages.properties file like </p>
  
  <pre><code>windowTitle=Accessing Form Elements with JavaScript
  namePrompt=Name:
  passwordPrompt=Password:
  confirmPasswordPrompt=Confirm Password:
  </code></pre>
  
  <p>I have a entry for this in my faces-config.xml like this</p>
  
  <pre><code>&lt;faces-config version="2.0"
      xmlns="http://java.sun.com/xml/ns/javaee" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"&gt;
  
      &lt;application&gt;
          &lt;resource-bundle&gt;
              &lt;base-name&gt;pk.mazars.basitMahmood.messages&lt;/base-name&gt;
              &lt;var&gt;msgs&lt;/var&gt;
          &lt;/resource-bundle&gt;
      &lt;/application&gt;
  
  &lt;/faces-config&gt;
  </code></pre>
  
  <p>On my xhtml page i can access it like this</p>
  
  <pre><code>&lt;h:panelGrid columns="2" columnClasses="evenColumns, oddColumns"&gt;
      #{msgs.namePrompt}
      &lt;h:inputText/&gt;
      #{msgs.passwordPrompt}
      &lt;h:inputSecret id="password"/&gt;
      #{msgs.confirmPasswordPrompt}
      &lt;h:inputSecret id="passwordConfirm"/&gt;
  &lt;/h:panelGrid&gt;
  </code></pre>
  
  <p>But how can i read this file from Java. Like, suppose i have to print a message like this, or prompt the user like <strong>Name must be entered</strong></p>
  
  <pre><code>System.out.println(msgs.namePrompt + "must be entered")
  </code></pre>
  
  <p>How can i read the msgs.namePrompt value from my java code.</p>
  
  <p>Also suppose i have a entry in my message file like this</p>
  
  <pre><code>sure=Are you sure, you want to delete the &lt;Field&gt;?
  remove=Are you sure you want to remove the&lt;Field&gt; and &lt;Field&gt;?
  close=Are you sure you want to mark the &lt;Field&gt; as Closed?
  created=&lt;Field&gt; is successfully created
  updated=&lt;Field&gt; is successfully updated
  </code></pre>
  
  <p>Is there any technique that i can pass parameter to my messages.properties file. Like i want to do something like this in my java code</p>
  
  <pre><code>System.out.println(msgs.sure("Name"));   //&lt;Field&gt; is replace with Name
  System.out.println(msgs.remove("Age", "Gender"));  //  First Field replace by Age, and second is replace by Gender
  </code></pre>
  
  <p>Thank you.</p>