title: Declare and use variable in JSF2 xhtml page
body: <p>I am using <code>&lt;s:set var="buttonText" value="getText('person.button.add')"/&gt;</code> in JSTL to use buttonText variable to set text. </p>
  
  <p><strong>Someone tell me how to accomplish this in JSF EL please?</strong></p>
  
  <p>Question asked here <a href="https://stackoverflow.com/questions/13591618/if-else-condition-in-jsf-form-need-to-know-right-approach/13595477#comment18649867_13595477">IF-ELSE condition in JSF form. Need to know right approach</a> but told to ask as a separate question.</p>
  
  <p><strong>EDITED:</strong></p>
  
  <p>I already added a link above for detail but here is again.</p>
  
  <p>I am using JSTL like in struts2 project</p>
  
  <pre><code> &lt;s:if test="person==null || person.id==null || person.id==''"&gt;
                  &lt;s:set var="buttonText" value="getText('person.button.add')"/&gt;
              &lt;/s:if&gt;
              &lt;s:else&gt;
                  &lt;s:set var="buttonText" value="getText('person.button.edit')"/&gt;
              &lt;/s:else&gt;
  </code></pre>
  
  <p>I want to use same approach in JSF2 but with Expression Language. I am saving value in a variable called <code>buttonText</code> and accessing it below somewhere like <code>#{buttonText}</code>. I need solution to how to write variable in <code>EL</code> and use it. Hope its clear.</p>
  
  <p>I need solution to <code>&lt;s:set var="buttonText" value="getText('person.button.add')"/&gt;</code> line of code only.</p>
  
  <p>Thanks</p>