Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to assemble column content in jstl without all these when-tests?

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two HTML columns A and R where I need to display some combination of units (U), dollars (D) and occurrences (O). Column R must mimic the combination selected by A, but using its own data.

The rules are basically that I will display whatever is non-zero, or if everything is zero, I will display units (U) and dollars (D).

So, here is what I have for deciding what to put in column A:


so that the possible values for mode are:
0 -> units and dollars
1 -> units
3 -> dollars
4 -> units and dollars
5 -> occurrences
6 -> units and occurrences
8 -> dollars and occurrences
9 -> units, dollars, occurrences

Is there a better way to pick from these outcomes than doing something like this:

What is a better alternative? This also doesn't handle delimiting ${u1} from ${d1} and so on, so in reality it would be even more complex than shown here.
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like something that would be better handled in the controller.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic