Due to your recommendation to use <t:column> i did not stop looking at
the issue, as this was not available under 1.0.9. and made me
suspicious.
So I upgraded from 1.0.9 to 1.1.0 where t:colum is available.
a.) Issue solved, I can do what I want.
b.) List iteration does not seem to work with methods, only with
attributes so in the following example dateStyle is an Attribute +
getter n setter in the list-element-class and not a method anymore.
<t:column id="xy" styleClass="#{list.dateStyle}">
[...]
<h:outputText value="#{list.date}"/>
</t:column>
c.) The CSS behaviour seems to be predictable, i.e. if you return a
String like "color:red" this works with the attribute "style" and not
with "styleClass", on the otherhand if I use "styleClass" I have to
return "highlightstyle" assumed you have a class defined in your
stylesheet.
.highlightstyle{
color: red;
}
Thats what I want great and thanks
Regards
Christian
CONNER, BRENDAN (SBCSI) wrote:
| If you supply more information about what you want to do, that would
| help.
|
| We're doing dynamic coloring of cells, etc., depending upon the data
| provided, in several places with no problems (certainly without
| having to write other tags). One does need to know which CSS styles
| are available, of course; that's why I have Appendix C of O'Reilly's
| book "HTML & XHTML: The Definitive Guide" bookmarked. ;-)
|
| - Brendan
|
| -----Original Message-----
| From: Christian [mailto:[EMAIL PROTECTED]
| Sent: Wednesday, September 21, 2005 12:32 PM
| To: 'MyFaces Discussion'
| Subject: AW: <dataTable> Howto conditional formating of single cells
| like in Excel?
|
|
| Thanks for your responses.
|
| Unfortunalely the idea below does not work (at least not in my
| context). I did try it with method binding, "style" and "styleClass"
| "<t:", "<h:". I surrender and will work on the other tiers of my app
| now.
|
| The table itself looks great: I am using rowclasses and
| columnclasses. CSS is very powerful and it is not unlikely that your
| idea works in other contexts. - I say this according to my experience
| with CSS and JSF as Newbie - Note: I spent 3 days on CSS and my Tiles
| setup. It now looks in the way I want it to have, at least on Firefox
| ;-), but I experienced the entire CSS-JSF stuff as not entirely
| predictable if you just use some tags provided. I am a control freak,
| so next time I will write a tag myself, and I will deeply check out
| the rendering phase and renderes. This might help me to understand
| how CSS/JSF or CSS/Myfaces really work together.
|
| Regards
| Christian
|
|
|
| Thomas Blattner wrote:
|| Hello,
||
|| maybe you could add a style tag to your outputText and bind the value
|| to a field in your managed bean. Inside their you could then give
|| back a value according your date
||
|| if ( date > shouldbe )
|| return "color:red";
|| else
|| return "color:green";
||
||
||
|| Am Mittwoch, 21. September 2005 18:11 schrieb Christian:
||| Hello everyone,
|||
||| I just tried to do conditional table highlighting in <h:dataTable>
||| or <f:dataTable> for a single cell content, without getting a
||| general approach of how to do it. You might help me.
|||
||| Idea:
||| I want to implement an eyecatcher. Just imagine MS Excel-table
||| cells. In Excel you can define formating rules for cells. Example:
||| If the amout of money is negative, it is to be displayed in red,
||| else it is to be displayed in black. In my app I want to do this
||| with a date field, ie. if the date displayed is lower than the date
||| of today (Usecase: "Something is overdue"), it is to be displayed
||| in red instead of black as usual.
|||
||| Situation:
||| My <dataTable> is bound to a managed bean containing a list of
||| dataBeans, works fine.
|||
||| #
|||
||| Things I tried to do:
|||
||| I tried to do component binding to an HtmlOutputText-Component like
|||
|||| <x:dataTable var="list"
|||| [...]
|||| <h:column>
|||| <h:outputText binding="#{list.dateOutputCompontent}"
|||
||| value="#{list.dateOfReturn}"/>
|||
|||| </h:column>
|||| [...]
|||
||| I also tried to do something like:
|||| FacesContext context = FacesContext.getCurrentInstance();
|||| HtmlOutputText dateOutput = null;
|||| dateOutput =
|||| (HtmlOutputText)context.getViewRoot().findComponent("dueD");
|||| dateOutput.setStyle("color:red");
|||
||| in combination with
|||
|||| <h:column>
|||| <h:outputText id="dueD" value="#{list.dateOfReturn}"/>
|||| </h:column>
|||
||| I put the java-code inside the getter of the date value, which did
||| not work. The table-display-result broke at the rendering of the
||| first date-format.
|||
||| Question:
||| Does anyone have an idea of what to do an where to do.
|||
||| Thanks in advance.
||| Regards
||| Christian