0

I am working on employee leave application where the managers gets to see the there sub-ordinate pending leave request, they can choose to either accept or reject the request.

I am trying to achieve this using display tag, I managed to get the details from DB and display it on jsp.

<disp:table name="pendingLeaveRequest" >
        <disp:column  />  /*Sample display column*/
        <disp:column  />
        <disp:column title="Approve">
            <input type="button" class="btn" value="Approve"
                onclick="approveLeave(this,**Like to pass the row ID**)" />
        </disp:column>
        <disp:column title="Reject"> 
        <input type="button" class="btn" value="Reject"
                onclick="rejectLeave(this, **Like to pass the row ID**)" />
        </disp:column>

My problem is getting the exact row details. I went thro' some articles on display tag in stacckoverflow, but I couldn't find a relevant article to my issue. The display tag http://displaytag.sourceforge.net/1.2/displaytag/tlddoc/index.html, reference article is not clear on using uid details to get row details.

My question is, 1) How to get the row Id and pass it? 2) Using row Id how to get the row details? I am a novice when it comes to using display tag. Any help will be highly appreciated.

AKV
  • 183
  • 4
  • 24

1 Answers1

1
<display:table name="pendingLeaveRequest" id="row">
...
<display:column>
   <input type="button" class="btn" value="Approve"
            onclick="approveLeave(this,${row.id})" />
</display:column>

where id as a property of your object.

Alex
  • 11,451
  • 6
  • 37
  • 52
  • Sorry for asking this question, How will "${row.id}" be unique? Based on both uid and id is string?. – AKV Jul 24 '13 at 03:51
  • 1
    @Arun Kumar You can find example here: http://demo.displaytag.org/displaytag-examples-1.2/example-imp-objects.jsp – Alex Jul 24 '13 at 03:55
  • @Arun Kumar "row" will represent object in the list. – Alex Jul 24 '13 at 03:56
  • Thanks for the demo link, I went thro the detail, But when my application inside my onClick function if I try to read the row ID, I am not able to read the value, I am not able to understand how to read the row id value? Could you please explain that part?. – AKV Jul 24 '13 at 04:12
  • @Arun Kumar Example, you have List list, Person has id, firstname, lastname. So, ${row.id} will have access to id of the person in the specific row. You can have any name like id="myobj" and then ${myobj.id}. – Alex Jul 24 '13 at 04:16
  • I have ArrayList<>, so I am using, $(rows.leave_id) where my id="rows". How should I read the value in my onClick function? I am trying to print and see my row ID? – AKV Jul 24 '13 at 04:32