Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Tag handlers like <code>&lt;c:forEach&gt;</code> runs during building the view, not during rendering the view. UI components like <code>&lt;h:dataTable&gt;</code> runs during rendering the view, not during building the view. So, at the moment the <code>&lt;c:forEach&gt;</code> runs, the <code>&lt;h:dataTable&gt;</code> isn't running and thus its <code>var="rubro"</code> is never available in the EL scope and thus <code>#{rubro}</code> inside <code>&lt;c:forEach&gt;</code> <em>always</em> evaluates as <code>null</code>.</p> <p>So, the <code>&lt;c:forEach&gt;</code> is completely out of the question for this particular functional requirement. Your best bet is using the <code>&lt;ui:repeat&gt;</code>. This does however not support anything like the <code>begin</code> and <code>end</code> attribute of the <code>&lt;c:forEach&gt;</code>. You could however create a <a href="https://stackoverflow.com/questions/7079978/how-to-create-a-custom-el-function/7080174#7080174">custom EL function</a> which creates a dummy array of the given size and then feed it to <code>&lt;ui:repeat value&gt;</code>.</p> <p>E.g.</p> <pre><code>&lt;ui:repeat value="#{my:createArray(robro.nivel)}"&gt; &lt;h:outputText value="__*" /&gt; &lt;/ui:repeat&gt; </code></pre> <p>with</p> <pre><code>public static Object[] createArray(int size) { return new Object[size]; } </code></pre> <p>The JSF utility library <a href="http://omnifaces.org" rel="nofollow noreferrer">OmniFaces</a> has an <code>of:createArray()</code> function for exactly this purpose, see also <a href="http://showcase.omnifaces.org/functions/Arrays" rel="nofollow noreferrer">the <code>of:createArray()</code> showcase example</a>.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense">JSTL in JSF2 Facelets... makes sense?</a></li> <li><a href="https://stackoverflow.com/questions/7079978/how-to-create-a-custom-el-function/7080174#7080174">How to create a custom EL function to invoke a static method?</a></li> </ul>
 

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