lakhaman
lakhaman

Reputation: 125

how to put link as an additional column in display tag to redirect it to action class of struts2

i am displaying a object detail through display tag. now i want a link in page through which user can delete or edit that particular record so i want a link which has object id as value and pass it to action class. or any other way so that i can delete or edit perticular record thank in advance

Upvotes: 1

Views: 3555

Answers (2)

Muhammad Shahid
Muhammad Shahid

Reputation: 79

<display:table name="sessionScope.searchResults"
    cellpadding="1" uid="sr" pagesize="50" cellspacing="1" size="50"
    defaultorder="ascending" sort="list" style="width:850"
     id="row">
    <display:column media="html"
    title="Delete"
    style="text-align:center">
    <s:url id="deleteUrl" action="deleteLink.action">
    <s:param name="objectId" value="#attr.row.OBJECT_ID" />
    </s:url>
    <s:a href="%{deleteUrl}">
         Delete
    </s:a>
</display:column>

</display:table>

OBJECT_ID is the ID of the current rows object, send the id to your action class load the obect with the id and do what ever you want to do.

You will get a hyper link on Delete image, Clicking on Delete will send you to deleteLink.action

Upvotes: 2

Bhushan Bhangale
Bhushan Bhangale

Reputation: 10987

Take a look at display:column, you can use the href and paramId to pass unique id to the url to delete a particular record.

Upvotes: 1

Related Questions