-1

I have list of object in my action class as below.

private ArrayList<Employee> emp_list;
public ArrayList<Employee> getEmp_list() {
    return emp_list;
}
public void setEmp_list(ArrayList<Employee> emp_list) {
    this.emp_list = emp_list;
}

Bean Class : (it has getter and setters)

private String name;
private String designation;
private String project;

Now on jsp page I want display this list data to be displayed as table on pop-up on same page on button or href click(showing size of list).

<body>

    <div class="container">
        <h2>Modal Example</h2>
        <!-- Trigger the modal with a button -->
        <table>
            <s:iterator value="emp_list">
                <tr>
                    <td><s:property value="name" /></td>
                    <td>
                        <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Display Details</button>
                    </td>
                </tr>
            </s:iterator>
        </table>

        <!-- Modal -->
        <div class="modal fade" id="myModal" role="dialog">
            <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Employee Details</h4>
                    </div>
                    <div class="modal-body">
                        <table>
                            <tr>
                                <td>Name</td>
                                <td><s:property value="name" />
                                </td>
                            </tr>
                            <tr>
                                <td>Designation</td>
                                <td><s:property value="designation" />
                                </td>
                            </tr>
                            <tr>
                                <td>Project</td>
                                <td><s:property value="project" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>

            </div>
        </div>

    </div>

</body>

Please help me out I've stucked here.

Dnyaneshwar
  • 101
  • 16

1 Answers1

0

You need to use the <s:iterator> tag in your jsp here you can find an example with struts2 iterator usage with a table.

For the pop-up part, you can use any Html/JS combo (if using bootstrap you can use a modal) and just show or hide your code as needed

nsawaya
  • 622
  • 5
  • 8
  • can you please give some sample using bootstrap – Dnyaneshwar Mar 12 '16 at 02:34
  • Well, use the same modal example link (the modal one I linked) and just replace it with the table content you need from the other links, the modal is always there in your jsp, it's just not showing until you show it with JS. – nsawaya Mar 13 '16 at 06:24