Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6477315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:56:01+00:00 2026-05-25T06:56:01+00:00

I am trying to conditionally build a custom list using <ui:repeat> . On every

  • 0

I am trying to conditionally build a custom list using <ui:repeat>. On every occurrence of -1 as item-value in list, I need to add a line break.

I tried to use <c:if> inside <ui:repeat> for that, but it does not seem to work. It always evaluates false.

<ul>      
    <ui:repeat value="#{topics.list}" var="topicId" >
        <li>#{topicId}</li>
        <c:if test="#{topicId eq -1}">  <br/>  </c:if>
    </ui:repeat>
</ul>

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:56:02+00:00Added an answer on May 25, 2026 at 6:56 am

    Not with JSTL tags, no. They run during view build time, not during view render time. You can visualize it as follows: when JSF builds the view, JSTL tags run from top to bottom first and the result is a pure JSF component tree. Then when JSF renders the view, JSF components run from top to bottom and the result is a bunch of HTML. So, JSTL and JSF don’t run in sync as you’d expect from the coding. At the moment your <c:if> JSTL tag tag runs, the #{topicId} variable which is set by <ui:repeat> JSF component isn’t available in the scope.

    Instead of using <c:if>, you need to specify the condition in the rendered attribute of the JSF component of interest. As you’ve actually none, you could wrap it in a <ui:fragment>.

    <ul>      
        <ui:repeat value="#{topics.list}" var="topicId" >
            <li>#{topicId}</li>
            <ui:fragment rendered="#{topicId eq -1}"><br/></ui:fragment>
        </ui:repeat>
    </ul>
    

    Alternatives are <h:panelGroup>

    <h:panelGroup rendered="#{topicId eq -1}"><br/></h:panelGroup>
    

    or in your specific case <h:outputText escape="false">

    <h:outputText value="&lt;br/&gt;" escape="false" rendered="#{topicId eq -1}" />
    

    as both also emits nothing else to the HTML output when no client side attributes are specified.

    See also:

    • JSTL in JSF2 Facelets… makes sense?

    Unrelated to the concrete problem, that’s the wrong place for a <br/>. It would be ignored by any webbrowser respecting the HTML specification. Don’t you mean it to be inside the <li>? Or better, give it a class and let CSS give it a margin-bottom.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to to add a post-build macro that would conditionally copy some files
I am using Oracle 11g client, with ODP.NET. I am trying to add conditional
I'm trying to set image source conditionaly using the following line: source={data.muted ? '/assets/audioMuted.gif'
I'm trying build a conditions array to be using in a prepared statement: Cars.find(:all,
I'm trying to build a rake utility that will update my database every so
I'm trying to build a website. I have it displaying correctly in every browser
I am using R to plot trying to conditionally change parts of an array
I am using Twig to conditionally display a piece of HTML (or trying to,
I'm trying to create an conditional Rewrite Rule using an .htaccess file and Apache.
I'm trying to build up a proper routing scheme for my products section in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.