views:

404

answers:

2

i have to create a table, whose structure is like this

|--------------------------------|  
|col1|col2|      col3       |col4|  
|    |    | col3.1 | col3.2 |    |  
|----|----|--------|--------|----|  
|----|----|--------|--------|----|  

Is it possible to create such structure using display tag?

A: 

Try using this code. You can use rowspan and colspan.

      <table style="width: 70%; height: 325px;">
                <tr>
                    <td rowspan="2">
                        Col1</td>
                    <td rowspan="2">
                        Col2</td>
                    <td colspan="2">
                        Col3</td>
                    <td rowspan="2">
                        Col4</td>
                </tr>
                <tr>
                    <td class="style1">
                        Col3.1</td>
                    <td class="style1">
                        Col3.2</td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
<!-- You can keep adding this to create new rows. -->
                  <tr>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>

            </table>
TheMachineCharmer
OMG, i know i can create this table, but i have to use displaytag.
Rakesh Juyal
This question was about displaytag.
laura
+1  A: 

Check out the decorator examples (http://displaytag.sourceforge.net/1.2/tut%5Fdecorators.html), that is your best bet.

Another way to do it is to add the content of the cell manually, like so:

<display:column titleKey="something" media="html">

       <c:out_of_property_here>

</display:column>

If I remember correctly, if my table was defined like:

<display:table name="test" requestURI="some_uri"
    defaultsort="0" id="test" export="true" excludedParams="*" >

you would access the current element using test, so if the object you are displaying has a property id with a getter getId, you would access the current object in the list by writing test.id.

But I would try using a decorator first (you can add decorators per-column iirc), the second option is very messy.

laura
at present i am using the later soltion, [ using c:out inside display:column ], but i guess i should check out that decorator too.
Rakesh Juyal