Title: RE: [displaytag-user] Relaing Display tag Formating.

You will need to create a subclass of the TableDecorator
and override the startRow() method:

    //This keeps a reference to the previous row object so we can compare the
    //current row's sector to the previous row
    private Object prevRowObject = null;

    //Adds a header row if we are beginning a new sector
    public String startRow() {
        ItemEntity last;
        ItemEntity curr = (ItemEntity)this.getCurrentRowObject();
        String header = "";

          //Cast the previous item to correct type
        if (null == prevRowObject) {
            last = new ItemEntity();
        } else {
            last = (ItemEntity)prevRowObject;
        }

          // Compare the current sector to the previous sector
        // If they are different then insert a header row
        if (!last.getSector().equals(curr.getSector())) {
                header = "<tr><td colspan=\"10\" class=\"sectorhead\">City Name: " + curr.getSector() + "</td></tr>";
            }
        }
       
        //Save the current object for the next iteration
        prevRowObject = this.getCurrentRowObject();
       
        return header;
    }

Then you can add the decorator attribute to the <display:table> tag to tell
it to use your decorator.

Hope that helps you

Ed!

-----Original Message-----
From: SREEKANT Rajan [mailto:[EMAIL PROTECTED]]
Sent: 26 February 2004 06:13
To: [EMAIL PROTECTED]
Subject: [displaytag-user] Relaing Display tag Formating.


Hi all

I need a help from you
I gone through your documents and displaytag functionality
I found that I can use the pagination, multi formatting(excel, xml ) and all other good option
But I was struck up in a formatting...

I need to format my page as follows

EmpID  Name  Design    Salary      etc....

City Name : WC
1     XXX    XXXX      3999$     ......
2     XXX    XXXX      4838$    .......
City Name: MC
4      CCCC   CCCCC     3434$    .......
5      FFFF    ffff      2212$   .......
6      mmmm    ffff      2212$   .......

here group by City as sub heading  and the data needs to come below the City Group.
Is there is any direct way to do as above.

I don't want a format which group city as a column of main title of the Table as below.
City  EmpID  Name  Design    Salary      etc....
WC     ......


MC    ........


Please help me to resolve the issue, expecting an im reply.




R.Sreekant

Reply via email to