This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL: using variable within an array-variable

 
Christian Oszczynski
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I'm quite new to the whole jstl things, so please don't be too harsh on me, when I'm maybe posting something self-evident OR something nonsensical.

My problem is as follows:

I've got a forEach loop which looks like this:



this works fine for me when using static values within the array-dimensions, for example like in the following line



what i would like to do now, is to have one of the dimension values set by a variable, something like



Unfortunately this does not work, therefore my question is, whether this possible at all or not. I didn't think that this would be such a big problem, but I have been searching for quite a long time in vain to solve this problem. Or maybe I still don't have understood the syntax of JSTL the right way, then please excuse me for bothering you.

A little hint would be much appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few things:
  • List" is a really bad name for a scoped variable. Firstly, it's too generic. Secondly, scoped variable naming should follow the convention for Java variables, and start with a lowercase character.
  • ${} is not a "fetch" operator. It surrounds the entire EL expression, not just variables whose values are to be referenced. Therefore, they are never nested.

  • In other words:<c:if test="${current.ValueList[myValue][2]>='1.0'}">

    And, this is actually an EL, not a JSTL question.
     
    Christian Oszczynski
    Greenhorn
    Posts: 2
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi bear,

    thank you very much, your solution worked out for me. regarding the "List"-naming, I am aware of that, I removed parts of my original code, so that only the semantic sense of the code remained. That is also why one variable started with an uppercase character, just wanted to post quickly, unfortunately without checking the code, sorry for that and for any further inconvenience.

    greetings
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64188
    83
    IntelliJ IDE Java jQuery Mac Mac OS X
    • 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    No need to apologize. It's just that making your code hard to read (which not following conventions tends to do) may result in getting less help. And getting help is what this place is for!
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic