• Post Reply Bookmark Topic Watch Topic
  • New Topic

small problem with JSTL x tags

 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following JSP code:


The variable selected_vnr is set from an Object in the request and contains a number that exists in the nr attribute of one of the rows (this is guaranteed, if not the database is corrupt).
I want the select to show the correct row as selected (obviously), but this isn't happening.
The code for the x:if isn't for some reason working properly (the variable IS set to the correct value, I tested that explicitly).
Apart from that everything appears as expected.

Question: what am I doing wrong, missing, or otherwise not seeing
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should of course be


but that makes no difference in the code not working (but at least it'll compile).
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Took me a day of experimenting and searching (mostly in vain, I guess noone has a need to do conditionals in an x:forEach based on a scoped variable???) I found the solution.



When not including the first c:choose an exception will be thrown if the scoped variable 'con' doesn't exist (I guess x:if doesn't like to compare with empty values).

Check the '.[' in '=".[@nr=$pageScope:selvnr]', anything else will cause the check to either always fail or not even compile.

x:if doesn't work with bean properties, therefore it's impossible to use the scoped variable 'con' (which is a bean) directly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!