Row rendering

14 views
Skip to first unread message

ck

unread,
Sep 15, 2008, 5:02:45 PM9/15/08
to JMesa
I'm tying to change the color of a row based on a particular column
property value. i followed the example provided for custom cell
rendering but i'm unable to get the actual value of the property( in
this case registrationId)
HtmlRow col= getRow();
String property= col.getColumn("registrationId").getProperty();

Please help.

Jeff Johnston

unread,
Sep 15, 2008, 9:28:56 PM9/15/08
to jm...@googlegroups.com

Basing my example off of the cell renderer:
http://code.google.com/p/jmesa/wiki/CustomCellRendererTutorial


Here is an example that extends the HtmlRowRenderer.  As you can see you can get the value that you need by using the ItemUtils. You could also cast the item to what your real object is.

public class CustomHtmlRowRenderer extends HtmlRowRendererImpl {
   
    @Override
    public Object render(Object item, int rowcount) {
        HtmlBuilder html = new HtmlBuilder();
        html.tr(1);
        html.id(getCoreContext().getLimit().getId() + "_row" + rowcount);
       
        Object value = ItemUtils.getItemValue(item, "career");
        String valueStr = String.valueOf(value).toLowerCase();
        if (valueStr.contains("soldier")) {
            html.style("background-color:#c0dba7");
        } else {
            html.style(getStyle());
        }
       
        html.styleClass(getStyleClass(rowcount));

        html.append(getRowEvents(item, rowcount));

        html.close();

        return html.toString();

bcg

unread,
Oct 1, 2008, 9:18:42 AM10/1/08
to JMesa
Jeff,

I couldn't find this anywhere in the wiki... I think might make a good
recipe.

Anyhow, thanks for the tip!

Jeff Johnston

unread,
Oct 1, 2008, 9:31:02 AM10/1/08
to jm...@googlegroups.com
I agree...I wrote up an issue ticket as a reminder to write this recipe up!

-Jeff
Reply all
Reply to author
Forward
0 new messages