• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

This one _should_ be easy

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I create a panelGrid such that arbitrary table cells are with a certain background color.

Fore example: a 3x3 table where only the center cell is white and the others are black.

Another one: Can I use iframes with JSF? The JSP I am converting to jsf uses html tables to layout the position of iframes. Is there a way to convert this to pure jsf or will i have to use standard html for this?

Thanks.

Seb
[ August 18, 2005: Message edited by: seb petterson ]
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I refuse to believe that noone knows the answer to this, but if its the case it will be a big minus for jsf.
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the panelGrid has two attributes - rowClasses and columnClasses which you can use to specify the syle of your individual cells.

Also, you can use iFrames fine with JSF - just watch out for h:form boundaries - if your iFrame is contained within an enclosing h:form it can screw up the functionality of your enclosing form.
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rick Beaver:
I believe the panelGrid has two attributes - rowClasses and columnClasses which you can use to specify the syle of your individual cells.



How? If you define a style for row x, it will be applied for all cells in row x, if you apply a style for column y it will be applied to all cells in column y. But how do apply a style for cell (x,y)?
[ August 23, 2005: Message edited by: seb petterson ]
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the docs - these are a comma seperated list of classes.

Say you have the following in your CSS:



You can do something like:



Which would mean that your table would have five columns the first one red, second and third blue, fourth green and fifth red.

You can do the same with the rows.

If you need random colours based on cell content then you should encapsulate the style in the component placed in the cell.
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rick Beaver:

... Which would mean that your table would have five columns the first one red, second and third blue, fourth green and fifth red.
.


Thanks. But my question was not how to make a column a certain color, but a cell.

Originally posted by Rick Beaver:

If you need random colours based on cell content then you should encapsulate the style in the component placed in the cell.


Yes this would be nice, unfortunately components like h:outPutText does not respond to background styles (it's a text).
[ August 23, 2005: Message edited by: seb petterson ]
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will this work for you?



You'd probably want to put the colors into css styles. I added them like this to emphasize the colors.

[ August 23, 2005: Message edited by: Mike Minner ]

Why is it that when you edit a post, it unchecks the 'Disable Smilies' box?!?!?!

[ August 23, 2005: Message edited by: Mike Minner ]

AAAAARRRRRGGGGHHHHH!!! Smilies!!!
[ August 23, 2005: Message edited by: Mike Minner ]
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Minner:
Will this work for you?



It most certainly will, thank you so much!

(I know what you mean about the smileys.)
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was thinking about this problem this morning. I don't really agree that it would be a big minus for jsf, but I came up with a few, fairly hacky, ways to do it.

*** Option 1 ***

To highlight the cell at (2,2)

<h anelGrid columns="5" columnClasses="default, col-highlight, default" rowClasses="default, row-highlight, default">

I'm not sure what the css would look like. It would depend on how the styles are printed out. If the 'rowClasses' are placed on the rows and 'colClasses' on the cells, you would do...

.row-highlight td.col-highlight
{
backgroun-color: red;
}

A different variation if they were printed differently.

*** Option 2 ***

Assign the css class in javascript after the table:

document.getElementById("myForm:myTable").className = "something";

Some type of taglib should probably be built to get the id from the jsf system.

*** Option 3 ***

Output a span with verbatim (or something similar) with an id. Get the span id and get the parent cell from that...

function assignClassToParentCell(targetId, cssClass)
{
var targetObj = document.getElementById(targetId);
while(targetObj != null && targetObj.nodeName != "td")
{
targetObj = targetObj.parentNode;
}
if(targetObj != null)
targetObj.className = cssClass;
}

(Note: I have never run the above, so it would need to be tested. Specifically the loop condition 'targetObj != null')
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry. Option 2 would look like...

document.getElementById("myForm:myTable").rows.item(1).cells.item(1).className = "something";

Love that javascript.
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seb petterson:


It most certainly will, thank you so much!

(I know what you mean about the smileys.)



People are always talking about the Smiley's...
 
Honk if you love justice! And honk twice for tiny ads!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic