Title: RE: [displaytag-user] adding custom static rows into a table / accessing table data directly per row without automatically generated table tags


-----Original Message-----
From: Sprang, Henning (Firma CS) [mailto:[EMAIL PROTECTED]]
Sent: 29 March 2004 11:31
To: [EMAIL PROTECTED]
Subject: [displaytag-user] adding custom static rows into a table /
accessing table data directly per row without automatically generated
table tags

[snip]

> 1.) I want to add a custom, non-data table row in a displaytag table
> between the
> header row and the first real data row. In my special case, i have a table with
> search results from
> a database, and the row between the header an the first data row should show
> text input
> fields to enter the user's search request with search criteria for each data
> column.

I believe you can do this with a TableDecorator. If you override the startRow() method and use a class variable you can check if this is the first row in the table:

public MyDecorator extends TableDecorator {
       
        boolean doneFirst = false;

        public String startRow() {
                if (!doneFirst) {
                        doneFirst = true;
                        return "<tr>[type the rest of your inserted row here]</tr>";
                }
        }
}

> 2.) In the table's data rows i want to add special contents in the data fields,
>     not just simple td tags with css-classes and some text content, but i want
>     to add things like select boxes, for example, because i want the user to
> select
>     some or more of the table entries to do something with the data.
>
>     This might be best realized if i could access the table data directly with
>     something like a "fieldata" tag which inserts only the data into the jsp
> while layout
>     and everything would be to be implemented in the jsp.

You can add any text or html tags to the <td> cells by placing it inside the <display:column> tag's body:

<display:table name="result">
        <display:column title="Last Name">
                <input type="checkbox" value="${result.rowId}" />${result.lastName}
        </display:column>
</display:table>

or you could use:

<display:column property="lastName" title="Last Name" />

and then in the TableDecorator write:

public String getLastName() {
        MyBean row = (MyBean)this.getCurrentRowObject();
        return "<input type=\"checkbox\" value=\"" + row.getRowId() +"\" />" + row.getLastName();
}

Is this the sort of thing you were looking for?

Mr. Raible also has this demo for editable tables:
http://www.mail-archive.com/displaytag-user%40lists.sourceforge.net/msg00963.html

Ed!

Reply via email to