Search code examples
strutsjsp-tagsdisplaytag

how to work with rows in struts using display tag....?


In jsp I'm using Display tag to print a table.

I want to display multiple properties in a single row.

Suppose I want to show some information about the particular content of that row.

ex

row1
title:-How to display an image in html ?
started by:-mohit on:-21.10.11

row2
title:-How to display an image in html ?
started by:-mohit on:-21.10.11

row3
title:-How to display an image in html ?
started by:-mohit on:-21.10.11

row4
title:-How to display an image in html ?
started by:-mohit on:-21.10.11

Please help me guy's I have to submit my project after 4 to 5 days.


Solution

  • It is recommended to set the values (to be displayed in displayTag) in the Action class.
    It would be even better if you can create a bean class (holding title, startedBy etc. as a properties).

    Then retrieve the data from the database and for each row creates an object of your bean class (by setting the values in the properties) and store this object in an ArrayList. When you finished retrieving the data, set this ArrayList as an attribute in either request or session scope.

    Suppose you have set the attribute with the name "tableData" in session scope.
    Then, in your Jsp you can provide

    <display:table id="data" name="sessionScope.tableData">
    <display:column> <bean:write name="data" property="title" /> </display:column>
    </display:table>

    I hope this will help you to understand the scenario.