-1

I have a set of data in array list form that I would like to display each food based on the menu category, but I cannot check with the logical operator eq in ELParser, please help me out of this

<ui:repeat var="menu" value="#{eventBean.menuList}">
                <li><ol><h5>#{menu}</h5></ol></li>
                <ui:repeat var="food" value="#{eventBean.projectDetail.foodList}">
                    <li>
                    <ui:fragment ></ui:fragment>
                        <ol><h:outputText rendered="#{food.menu eq menu}">#{food.name}</h:outputText></ol>
                    </li>
                </ui:repeat>
            </ui:repeat>

the menu can be display but the inner loop are not displaying any food. I had tried #{food.menu eq #{menu}} but will get exception on ELParser

EDIT 1:

I just realized that <h:outputText>#{food.name}</h:outputText> are basically cannot display the value, I must do <h:outputText value="#{food.name}"></h:outputText> in order to display value, my mistake.

Now I am searching for if condition to filter

Tiny
  • 27,221
  • 105
  • 339
  • 599
Lance Leroy
  • 399
  • 4
  • 7
  • 17

2 Answers2

1

I had tried JSTL c:if to make condition checking but didn't work out as expected, then I search through stack overflow this link has helped me out by implementing:

<ui:fragment rendered="#{food.menu eq menu}">#{food.name}</ui:fragment>

Community
  • 1
  • 1
Lance Leroy
  • 399
  • 4
  • 7
  • 17
-1

Depending on how complex your filtering needs to be I would go with basic jsf tags or a custom function

For a couple of options only :

<c:if test="#{condition}">do stuff</c:if>

For a limited number of options :

<c:choose>
    <c:when test="#{condition1}">do stuff</c:when>
    <c:when test="#{condition2}">do other stuff</c:when>
    <c:otherwise>do something else</c:otherwise>
</c:choose>

for N Options look at the sollution here where you could use a custom EL function to do anything that a java function can do:

https://stackoverflow.com/a/7080174/2045820

Community
  • 1
  • 1
elfwyn
  • 568
  • 2
  • 11
  • 33
  • 1
    Please carefully read http://stackoverflow.com/q/3342984 why your answer doesn't make sense in the context of this question. As an advice, as long as you can't reliably answer off top of head, please try to reproduce and test the problem described in the question yourself instead of doing shoots in the dark. Otherwise better use the comments section for that. – BalusC Jul 07 '16 at 21:33