cancel
Showing results for 
Search instead for 
Did you mean: 

JSP and IF ELSE clause

msvoren
Champ in-the-making
Champ in-the-making
Hi!
I'm trying to filter some data from richList..
Anybody knows how to do that?

After generating richlist I could use IF clause to display a row if conditions meet..
But can't get it right..
e.g.

<% if ( #{r.name} = "NewYork" ) { %>
    ..do something..
<% }%>

What is wrong with this?
4 REPLIES 4

gavinc
Champ in-the-making
Champ in-the-making
You're mixing inline Java code with JSF value binding expressions.

Do stop something rendering in JSF you can use the "rendered" attribute i.e.

rendered="#{r.name == "New York}"

NOTE: The whole expression is inside the { }'s

msvoren
Champ in-the-making
Champ in-the-making
<% if ( rendered="#{r.name == "New York}"  ) { %>
..do something..
<% }%>

You mean like this ?
Can get it to work..
Can you please give me an example?

gavinc
Champ in-the-making
Champ in-the-making
/jsp/wcm/manage-review-task-dialog.jsp has an example of using the rendered attribute within a rich list.

But you're not going to be able to do what you want, firstly you can not mix inline Java and JSF tags and secondly, the "r" variable is only available to the JSF objects the inline Java code will never see this variable.

If you want to hide rows of data you will need to do it in the code that returns the list that the richlist component uses i.e. filter it out so that the rich list never sees it.

msvoren
Champ in-the-making
Champ in-the-making
Thank you for your help gavinc