Menu

Different style classes for rows

2008-05-27
2012-10-09
  • haritha gavva

    haritha gavva - 2008-05-27

    Hi All,

    I'm using display tags in my jsp to display a table.Using display tags all i could do is use diffrent background colors for even n odd rows.
    But what I need is,depending on a condition i've to change the background color of each row.Is this possible using display tags.If so, pls let me know.
    Thanks in advance

     
    • haritha gavva

      haritha gavva - 2008-05-30

      Thanks for replying Ed!

      one thing which i still dont understand is when is this addRowClass method to be called.
      As I've gone through the API, it was given that 'call back this method to add a class to a row'.

      I've written a Decorator class and overrode addRowClass(). Unlike other methods like startRow() and fishRow() which are called by default by the display tags, this addRowClass() is never called by default.This is what I observed by using sys out's.
      If it is to be called explicitly, then please let me know.

      Anymore insight into this matter would be greatly appreciated.

      Thanks in advance.

       
      • Ed Webb

        Ed Webb - 2008-05-30

        I've not used this myself. I would have thought the method got called when displaytag was creating the tr element. Are you using the version of DisplayTag that has this method? Check it's actually overriding the method in the superclass. You may have to trace through the source to see what's going on.

        Ed!

         
        • haritha gavva

          haritha gavva - 2008-06-01

          I'm using displaytag1.1.jar Ed. It has this method.
          I'm still trying to know where is it getting called. If by any chance u get any more info in this matter please let me know.

          Thanks in advance!

           
    • Ed Webb

      Ed Webb - 2008-05-27

      You need to create a TableDecorator for the table and override the addRowClass() or addRowId() method to give the <tr> element a class or id attribute that you can then style using CSS.

      See:

      http://displaytag.sourceforge.net/11/displaytag/apidocs/org/displaytag/decorator/TableDecorator.html

      and

      http://displaytag.sourceforge.net/11/tut_decorators.html

      Ed!

       

Log in to post a comment.