Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p><em>Why does the case 2 not work properly?</em></p> <pre><code> &lt;!-- 2. VALUE IS "!!!" AND NOT "loginname !!!" --&gt; &lt;c:set var="deleteConfirmationMessage2"&gt; &lt;h:outputText value="#{user.loginname}" /&gt;!!! &lt;/c:set&gt; </code></pre> </blockquote> <p>That's because taghandlers and UI components doesn't run at the same time. JSTL tags are taghandlers and they run during building the view (when the XHTML file is converted to JSF component tree). JSF <code>&lt;h:xxx&gt;</code> tags are UI components and they run during rendering the view (when the JSF component tree is converted/rendered to HTML code). See also <a href="https://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense">JSTL in JSF2 Facelets... makes sense?</a></p> <p>So, when the <code>&lt;c:set&gt;</code> runs, the <code>&lt;h:outputText&gt;</code> hasn't run at all.</p> <p>But in <em>this particular</em> construct you actually don't need the <code>&lt;h:outputText&gt;</code> at all. Apart from setting it as <code>value</code> of <code>&lt;c:set&gt;</code>, you could also just inline the EL expression raw in the template text (note that this works when using JSF with Facelets, not when using JSF with JSP; given the fact that you're using PrimeFaces, you're definitely using Facelets as PrimeFaces doesn't have a JSP taglib at all).</p> <pre><code> &lt;c:set var="deleteConfirmationMessage2"&gt; #{user.loginname}!!! &lt;/c:set&gt; </code></pre> <p>or perhaps you weren't aware that you can mix EL and plain strings in an attribute like</p> <pre><code> &lt;c:set var="deleteConfirmationMessage2" value="#{user.loginname}!!!" /&gt; </code></pre> <p>or </p> <pre><code>&lt;p:confirmDialog message="#{user.loginname}!!!"&gt; </code></pre> <p>Depending on the concrete functional requirement, which isn't exactly clear from the question, a different alternative may be to use the <a href="http://showcase.omnifaces.org/components/cache" rel="nofollow noreferrer"><code>&lt;o:cache&gt;</code></a> component of <a href="http://omnifaces.org" rel="nofollow noreferrer">OmniFaces</a>. This may be more useful if you intend to cache the value for a broader scope than just the page/request scope like as in your <code>&lt;c:set&gt;</code> examples.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload