• Post Reply Bookmark Topic Watch Topic
  • New Topic

font-color property from css  RSS feed

 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a JSP for which the font-color needs to be fetched from database. Is it possible to do the same. If yes how ?

TIA,
Ankit Chandrawat
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no font-color CSS property, so I assume you are talking about color, which controls the text color of elements.

CSS on a JSP page is just template, just like any HTML or script. So yes, you can treat it like any other part of the page.

So if the controller gets your color value from the database (or anywhere else) is can place it as a scoped variable in request scope and then you can use the EL on the page.

For example, if you create a scoped variable named myTextColor that contains the value #336699, you can use it in a CSS rule:which will end up as:on the browser.
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe relevant, maybe not. A potentially better design would be to store a css style name in the database rather than explicitly a "color"

That way you could define MORE than a font color change to distinguish things if you so wish
And you could make the style name more meaningful than values like "#BBAADD"

It depends on your use case of course.

Pro: can utilise the full power of css
con: have to predefine the styles. Whereas with the "color" method you can add new colors at will.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd go a step further and complete abstract it, but that's just me.
 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for enlightening me with better design approach and resolution. I really appreciate it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!