Search code examples
jsfif-statementjsf-2jstluirepeat

Use ui:repeat variable in c:if statement


I am trying to use a c:if statement inside a ui:repeat tag. However U cannot get the value of course.days while inside the if tag. It just always evaluates to empty.

    <div id="schedule_wrapper">
        <ui:repeat value="#{schedule.courses}" var="course">                
            <div class="course">
                <b>#{course.shortTitle}</b> : #{course.subjectCode} #{course.courseNumber}-#{course.section}<br /> 
                #{course.roomCode} #{course.buildingName} <br />
                <c:if test="${not empty course.days}">
                    #{course.days} : #{course.startTime} - #{course.endTime}
                </c:if>                                         
            </div>
        </ui:repeat>
    </div>

Any ideas how I can use the course.days variable inside the if statement?
Or an alternate way to achieve the same thing...
All of the other course.xxxxx value as pulling their values in.


Solution

  • Try to use inside your using a rendered to check your condition. rendered="#{not empty course.days}" or #{course.days > 0} if days is a Integer

    <div id="schedule_wrapper">
        <ui:repeat value="#{schedule.courses}" var="course">                
            <div class="course">
                <b>#{course.shortTitle}</b> : #{course.subjectCode} #{course.courseNumber}-#{course.section}<br /> 
                #{course.roomCode} #{course.buildingName} <br />
                **<ui:fragment rendered="#{not empty course.days}">
                    #{course.days} : #{course.startTime} - #{course.endTime}
                </ui:fragment>**                                        
            </div>
        </ui:repeat>
    </div>