I found a solution deep in my magic box ;)
put a value-binding attribute on the outputTexts in your dataTable,
just like this:
<h:outputText value="#{entry.subject}"
binding="#{eventsList.specializedOutputText}" />
in eventsList.specializedOutputText,
create a new Instance of SpecializedOutputText and return this.
class SpecializedOutputText should look like the following:
public class SpecializedOutputText extends HtmlOutputText
{
private static Log log =
LogFactory.getLog(SpecializedOutputText.class);
public void encodeEnd(FacesContext context) throws IOException
{
String username =
CalendarFactoryFinder.getGUIContextFactory().getGUIContext().getUserName();
if(username!=null)
{
UIComponent grandParent = null;
if(getParent()!=null &&
(grandParent=getParent().getParent())!=null
&& grandParent instanceof HtmlDataTable)
{
HtmlDataTable table = (HtmlDataTable) grandParent;
Object data = table.getRowData();
if(data instanceof CalendarEntry)
{
CalendarEntry entry = (CalendarEntry) data;
if(entry.contains(username))
{
this.setStyleClass("subject_Column_Private");
}
else
{
this.setStyleClass("subject_Column");
}
}
}
}
else
{
log.error("Could not retrieve username");
}
super.encodeEnd(context);
}
}
HTH!
regards,
Martin
On 7/29/05, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>*
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
hi, i know this is proably not a solution if richard manages to finish
the component, but is all ropes tear you could allways do it in plain
old javaScript in an onLoad function.
it would probably be the fastest, but if you have time, i would
wait for
the component to do the work for you ;)
greetings jörg
>I will commit it into the tomahawk sources.
>
>Richard Wallace schrieb:
>
>
>>Sounds awesome! Where will you be committing it to? Sandbox or
Tomahawk?
>>
>>Thanks,
>>Rich
>>
>>Broekelmann, Mathias wrote:
>>
>>
>>
>>>I´ve create a special column component which allows you to define
>>>different styles and more for the cells.
>>>It just needs some testing. I think I will have commited it
tomorrow.
>>>
>>>Best Regards,
>>>Mathias
>>>
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Richard Wallace [mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>] Sent:
>>>>Thursday, July 28, 2005 5:42 PM
>>>>To: MyFaces Discussion
>>>>Subject: Re: Variable cell style classes in data table
>>>>
>>>>
>>>>Alright, well my back is sort of up against a wall now. I had
>>>>thought I could figure out an alternative for now but I was
wrong. I
>>>>had thought that wrapping the column data in a div and setting
the
>>>>width and height to fill the cell would allow me to change the
>>>>background color on a per cell basis. And it does, but with a big
>>>>but. Apparently you can't use vertical alignment on block level
>>>>elements. So, rather than the text being centered vertically and
>>>>horizontally as it needs to be, it's up at the top of the cell.
>>>>We've tried several workarounds, none of which seem to work
quite right.
>>>>
>>>>So, I'm back to needing to set table cell style classes based
on the
>>>>content of the cell. I looked at maybe modifying the data
table so
>>>>that the column classes attribute could be a list of EL
statements
>>>>that get interpreted when each cell is rendered, but they are
>>>>interpreted instead when the table itself is created it looks
like,
>>>>so that's out. I'm not sure what could be the best way to do
it now,
>>>>maybe create a new facet type named "style" or "styleClass"
for the
>>>>column component.
>>>>
>>>>This is my first bout at trying to create custom components,
so I'm
>>>>not sure what that would involve, but I'm more than willing to
give
>>>>it a shot if someone could maybe give me some advice.
>>>>
>>>>Thanks,
>>>>Rich
>>>>
>>>>Richard Wallace wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>Jesse Alexander (KBSA 21) wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>I did something similar, but I just needed to render an
>>>>>>
>>>>>>
>>>>image according
>>>>
>>>>
>>>>
>>>>
>>>>>>the content of a field.
>>>>>>
>>>>>>I ended up writing a Lookup-image component. Nothing
complicated.
>>>>>>
>>>>>>hope this helps
>>>>>>Alexander
>>>>>>
>>>>>>PS: I'll be offline for a week! But after august 2nd i can
scetch
>>>>>>up a component that does this trick, if you can wait till then.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>Sounds good. I can probably figure something out until
>>>>>
>>>>>
>>>>then. Thanks
>>>>
>>>>
>>>>
>>>>>a ton.
>>>>>
>>>>>Rich
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>-----Original Message-----
>>>>>>From: Richard Wallace [mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>] Sent:
>>>>>>Monday, July 25, 2005 7:52 PM
>>>>>>To: MyFaces Discussion
>>>>>>Subject: Variable cell style classes in data table
>>>>>>
>>>>>>Hey everyone,
>>>>>>
>>>>>>I've got a report that I'm displaying with <h:dataTable>.
>>>>>>
>>>>>>
>>>>Depending
>>>>
>>>>
>>>>
>>>>>>on the value to be displayed the background color of the
>>>>>>
>>>>>>
>>>>cell should
>>>>
>>>>
>>>>
>>>>>>be a different shade. So for low values, it'd be like a
>>>>>>
>>>>>>
>>>>really light
>>>>
>>>>
>>>>
>>>>>>yellow, for high values it'd be a much darker yellow, etc.
>>>>>>
>>>>>>
>>>>Any ideas
>>>>
>>>>
>>>>
>>>>>>on how I can accomplish this with MyFaces?
>>>>>>
>>>>>>I had sort of hoped that something like the following would
work:
>>>>>>
>>>>>><h:column styleClass="#{reportHandler.styleClass}">
>>>>>>
>>>>>>But, as I found out, styleClass isn't a valid attribute for the
>>>>>><h:column> element.
>>>>>>
>>>>>>Any ideas? Am I stuck rendering this sucker with plain
>>>>>>
>>>>>>
>>>>old JSP and
>>>>
>>>>
>>>>
>>>>>>JSTL?
>>>>>>
>>>>>>Thanks,
>>>>>>Rich
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>
>>
>
>
>
>
>