pagination for displaytag with colorbox in Spring framework

Posted by Hitesh Solanki on Stack Overflow See other posts from Stack Overflow or by Hitesh Solanki
Published on 2010-05-13T12:52:03Z Indexed on 2010/05/13 12:54 UTC
Read the original article Hit count: 612

Filed under:

Hi..... I want to display the pop up for user selection using colorbox. I have put link on manageblacklist.jsp named 'select'. when I click on 'select' link ,colorbox is displayed. all user is displayed but pagination is not worked. I have used display tag for pagination. Without using colorbox, pagination is worked fine. I have used spring framework.

The code of manageblacklist.jsp is given below:

<%@ page contentType="text/html" pageEncoding="UTF-8" import="java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ page import="com.sufalam.mailserver.bean.User"%>
<%@ page import="javax.servlet.http.HttpSession" %>



<%
            String pageSize = (String) request.getAttribute("pageSize");
            System.out.println("page size:" + pageSize);
            HttpSession session1 = request.getSession();


            List<User> userList = (List<User>) session1.getAttribute("userList");


            Iterator iterator = userList.iterator();
            String user = (String) request.getAttribute("user");
            System.out.println("user in the jsp :" + user);

%>

<html>
    <head>

        <script type="text/javascript" src="js/jquery142.js"></script>
        <script type="text/javascript" src="js/jquery.colorbox.js"></script>
        <link rel="stylesheet" href="style/colorbox.css" type="text/css">
        <script type="text/javascript">
            $(document).ready(function(){
                //Examples of how to assign the ColorBox event to elements
                $(".example5").colorbox();

                //Example of preserving a JavaScript event for inline calls.
               $("#click").click(function(){
                    $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
                    return false;
                });
            });
        </script>
        <script type="text/javascript">

            function changePageSize() {
                var myValue = document.getElementById("combo1").value;
                document.getElementById("selectedPageSize").value=myValue;
                document.whitelistBlacklistForm.submit();
            }
            function selectAll() {

                var selectAll = document.getElementById("checkAll");
                var returnById = document.getElementsByName("check");
                var i;
                var val;

                if (selectAll.checked == true) {
                    val = true;
                }
                else {
                    val = false;
                }
                for (i = 0; i < returnById.length; i++) {
                    returnById[i].checked = val;
                }
            }

            function onload()
            {

                insertNavigation ('insertHereTop', 'insertHereBottom');
            }
            function insertNavigation( topElementID, BottomElementID ) {


                if ( document.getElementById('pagingBanner') ){
                    document.getElementById(topElementID).innerHTML=document.getElementById('pagingBanner').innerHTML;
                    document.getElementById(BottomElementID).innerHTML=document.getElementById('pagingBanner1').innerHTML;
                }
            }
            function confirmDelete()
            {
                if (confirm("Are you sure you want to delete selected records?")) {
                    flag = 1;
                    return true;
                }
                else {
                    return false;
                }
            }

            function loadModels() {

                var flag=true;
                var textValue = document.getElementById('txtuser');
                $.getJSON("ajaxblacklist.htm", // url
                {
                    param :textValue.value
                }, // request params

                function(json) { // callback
                    //  var options = '<table class="displayTable" cellspacing="0"><thead><tr><th align = "center">Blacklisted Sender</th>'+
                    //       '<th align ="center">Delete</th></tr></thead><tbody>';

                    var options = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td style="background:url(images/leftbg.gif) repeat-y; width:8px;"></td>' +
                        '<td class="middlesection"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>' +
                        '<td height="30" class="p10"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="allboder" >' +
                        '<tr><td class="tebelhd"> Blacklisted Sender </td></tr>';
                    for (i in json) {
                        var state = json[i];
                        for(j in state){
                            var op = state[j];

                            if(op.length==undefined){

                                options += '<tr><td class="tdhd"><table width="0%" border="0" cellspacing="0" cellpadding="0"><tr><td width="741">'+
                                    state[j].senderEmail + '</td><td align="center" width="148"><a href="managewhitelistblacklist.htm?sender='+state[j].senderEmail+'&recipient='+
                                    state[j].recipientEmail+'&action=delete"><span> <img src="/MailServerV2/images/delete.gif"/> </span></a></td></tr></table></td></tr>';
                                break;
                            }

                            for(k in op)
                            {
                                if(flag == true) {
                                    flag = false;
                                    options += '<tr><td class="tdhd"><table width="0%" border="0" cellspacing="0" cellpadding="0"><tr>';
                                } else {
                                    flag = true;
                                    options += '<tr><td class="tdhd2"><table width="0%" border="0" cellspacing="0" cellpadding="0"><tr>';
                                }
                                options += '<td width="741">'+ op[k].senderEmail +'</td><td align="center" width="148"><a href="managewhitelistblacklist.htm?sender='+op[k].senderEmail+'&recipient='+op[k].recipientEmail+'&action=delete"><span> <img src="/MailServerV2/images/delete.gif"/> </span></a></td></tr></table></td></tr>';
                            }
                        }
                    }
                    options += '</td></tr></table>';
                    $("div[name^=blacklist]").html(options);

                });
            }
        </script>
    </head>
    <body>
        <table width="" border="0" align="center" cellpadding="0" cellspacing="0" class="maintable">
            <tr>
                <td class="topsection"><table width="100%" border="0" cellspacing="0" cellpadding="0">

                        <tr>
                            <td valign="top" align="center" class="middlesection" ><table width="96%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td >&nbsp;</td>
                                    </tr>
                                    <tr>

                                        <td>
                                            <table width="100%" border="0" cellspacing  ="0" cellpadding="0">
                                                <tr>
                                                    <td> <table width="100%" border="0" cellspacing="0" cellpadding="3">
                                                            <tr>
                                                                <td align="left" valign="middle"><h1>Manage Blacklist</h1></td>
                                                                <td align="right" valign="bottom"><div style="float:right;"><a href="savewhitelistblacklist.htm" class="buttonash"><span>Create Whitelist Blacklist </span></a></div></td>
                                                            </tr>
                                                        </table></td>
                                                </tr>
                                                <tr>
                                                    <td class="bottomboder"><img src="images/ashish.gif" height="1" /></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div id="TabbedPanels1" class="TabbedPanels"/>
                                            <div style="display: block;" class="TabbedPanelsContent"/>
                                            <div align="left" class="tebelhd"> Blacklist Information </div><div class="entry-edit">

                                                <div class="fieldset" id="base_fieldset">
                                                    <div class="hor-scroll_1" align="left">

                                                        <fieldset Class="label1css" style="color:#666666">
                                                            <legend>Fields</legend>
                                                            <table>
                                                                <tr>
                                                                    <td align="right">
                                                                        Recipient Email :
                                                                    </td>


                                                                    <td><input type="text" id="txtuser" name="txtuser"
                                                                               <%
                                                                                           if (user != null) {
                                                                               %>
                                                                               value="<%=user%>"
                                                                               <%
                                                                                                                                                                          } else {
                                                                               %>
                                                                               value=""
                                                                               <%                                                                                            }
                                                                               %>
                                                                               />
                                                                    </td>
                                                                    <td><a href="#" class="buttonash" onclick="loadModels()"><span>Search</span></a></td>
                                                                    <!--  <td><a href="javascript:void(0)" class="buttonash" onclick="window.open('selectuser.htm','selectuser','width=600,height=400,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes');" ><span>Select</span></a></td>-->
                                                                    <td><a href="selectuser.htm" class="example5 buttonash" ><span>Select</span></a> </td>
                                                                      <td align="right"> 

                                                                    </td>

                                                                </tr>
                                                            </table>
                                                        </fieldset>
                                                        <div id="blacklist" name="blacklist"></div>
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
                <!-- InstanceEndEditable -->
                <td style="background:url(images/rightbg.gif) repeat-y; width:8px;"></td>
            </tr>
        </table>
        <%
                    //   session1.removeAttribute("user");
%>
    </body>
</html>

So , please tell me how to work pagination .... Thanks in advanced...

© Stack Overflow or respective owner

Related posts about jQuery