Re: How to dynamically bind css class to tr (worepetition)
David LeBer <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
On 1-Aug-06, at 12:27 PM, Tony Hoffman wrote:
> I've been looking over the lists and documentation but I can't find
> an answer to what I think is a simple question.
>
> I am in the process of converting a website from simple html to
> css. The chief problem I am having is setting the background color
> in WORepetition table rows. Previously, I created a
> WOGenericContainer inside the WORepetition and bound the element
> "TR" to the attribute "bgcolor" where the binding was set to a
> method that returned a string (background color) based on the value
> of an object. This worked swimmingly.
>
> Now, however, I would like to have the WOGenericContainer set the
> background color based on my css stylesheet. I don't know if I
> should (or how to) have the elementName / attribute / binding
> settings work to insert a class tag on a table row, or if I should
> reconfigure the Java code to somehow return a background string by
> referring to my stylesheet.
>
> Does anyone have any advice on setting the background color of a
> WORepetition based on an external CSS stylesheet?
You are on the right track Tony, though there are multiple ways of
achieving this.
Here is one:
If you WORepetition wraps a tr then make the tr dynamic (turn it into
a WOGenericContainer) then give it an "id" attribute and bind that to
a method that returns the name of the css selector for the coloured
background or null (if the method returns null, the "id" will not be
included in when the WOGenericContainer is rendered).
ie:
.html:
<table><webobject name="GenericContainer1"><td>Cell</td><td>Cell</
td><td>Cell</td></webobject></table>
.wod:
GenericContainer1: WOGenericContainer {
elementName = "tr";
id = rowColourId;
}
.java:
public String rowColourId() {
String result = null;
if (colourRowCondition()) { // whatever condition should trigger a
coloured row background.
result = "rowColour"
}
return result;
}
.css:
#rowColour {
background-color: #eee;
}
--
;david
--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://www.codeferous.com
blog: http://david.codeferous.com
--
Toronto Area Cocoa / WebObjects developers group:
http://www.tacow.org
_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
smime.p7s
(application/pkcs7-signature, 2.3 KB) - not displayed