• 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

setting HTML format for only one item in a JSP/EL list

 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose my EL contains a list such as
502/340; 502/350; 502/353

I can display this in my JSP using code such as




But instead of having them all formatted identically, I want to bold the first one, so the output looks more like


502/340; 502/350; 502/353

How can specify that I want the bold only for the first one?

And while I'm thinking, how can I get it to put the semicolon ";" only between the values, not after each one? And of course, if there is only one entry in the list, I want it bold with no following semicolon.
Thanks

 
Marshal
Posts: 25677
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The c:forEach element has a "varStatus" attribute which allows you to specify a variable which tells you about the status of the loop. One of the things it tells you is whether it's the first time through the loop. So (from memory) something like this:

I think the varStatus variable can also tell you if it's the last time through the loop, if that works better for getting the semicolons right. And if my memory wasn't perfect (it happens occasionally) then track down the documentation.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The varStatus attribute allows you to create a construct that will give you information such as the loop index et al. You can use this to determine if you are on the first iteration or not and add the appropriate CSS to bold the item when appropriate.
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, are you going to make a habit of this? (Posting seconds ahead of me.)










 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though, I'd use CSS rather than the <b> tag. And likely the ? operator rather than <c:choose>.
 
Paul Clapham
Marshal
Posts: 25677
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Paul, are you going to make a habit of this? (Posting seconds ahead of me.)



You might want to check out the webcam you just installed in your computer...
 
Pat Farrell
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to you both. That works great.
I'm actually using <strong> so the CSS folks can have their way with it.
 
Paul Clapham
Marshal
Posts: 25677
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Though, I'd use CSS rather than the <b> tag. And likely the ? operator rather than <c:choose>.



I probably would too if I wasn't typing as fast as possible.
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:You might want to check out the webcam you just installed in your computer...


I just duct-taped the lens.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic