snipt

Ctrl+h for KB shortcuts

Java

adicionar mensagem no faces

1
2
3
4
5
 public static void addMensagemErro(String mensagem, FacesMessage.Severity severity) {
        FacesMessage msg = new FacesMessage(mensagem);
        msg.setSeverity(severity);
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
https://snipt.net/embed/c0a67841f3254b065475b9fe1cb274a5/
https://snipt.net/raw/c0a67841f3254b065475b9fe1cb274a5/
c0a67841f3254b065475b9fe1cb274a5
java
Java
5
2016-09-20T15:57:47
True
False
False
/api/public/snipt/9984/
adicionar-mensagem-no-faces
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">addMensagemErro</span><span class="o">(</span><span class="n">String</span> <span class="n">mensagem</span><span class="o">,</span> <span class="n">FacesMessage</span><span class="o">.</span><span class="na">Severity</span> <span class="n">severity</span><span class="o">)</span> <span class="o">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">FacesMessage</span> <span class="n">msg</span> <span class="o">=</span> <span class="k">new</span> <span class="n">FacesMessage</span><span class="o">(</span><span class="n">mensagem</span><span class="o">);</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">msg</span><span class="o">.</span><span class="na">setSeverity</span><span class="o">(</span><span class="n">severity</span><span class="o">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">FacesContext</span><span class="o">.</span><span class="na">getCurrentInstance</span><span class="o">().</span><span class="na">addMessage</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="n">msg</span><span class="o">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="o">}</span> </span></pre></div> </td></tr></table>
faces, java, jsf, mensagem
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.