Need to implement Datatable Server Side processing using JSP Taglib

Need to implement Datatable Server Side processing using JSP Taglib

jewel2jewel2 Posts: 3Questions: 1Answers: 0

Hi,

First A huge thank to the developers for this amazing script. I have implemented this table in our struts2 project with Tomcat Server. We are using datatable Jsp taglib to implement the list table. Everything is working fine except server side processing as the serverside tag is missing from taglib. Our list rows already exceeds 10 million. So it is mandatory to implement server side processing. Could anybody help me to implement. Just to let you know our project is not maven enabled and we dont want to use maven.

Example project:
JSP

<%@ include file="/taglibs.jsp"%>
<%@ taglib prefix="datatables" uri="http://github.com/tduchateau/DataTables-taglib" %>

<head>

      <link href="/Struts2Configuration/css/jqueryDatatable/demo_table_jui.css" rel="stylesheet" /> 
      <link href="/Struts2Configuration/css/jqueryDatatable/zahir.css" rel="stylesheet" />
      <link href="${ctx}/css/bootstrap.css" rel="stylesheet" /> 

</head>
<body>
<div id="containers">
<div class="formWrappers">

Datatable with JSP Taglib
                    </div>
        <div id="demo_jui">

                            <datatables:table data="${datatablejsptaglib}" sort="true" htmlTableId="menuTable" dataObjectId="row" paginationType= "full_numbers" processing="true"  style="">

                                    <datatables:column title="Menu Id" property="menId" headerStyle="width: 5%; background:#EEEEEE; color:gray"/>
                                    <datatables:column title="Menu Parent" property="menParent" sortable="true" headerStyle="width: 10%; background:#EEEEEE; color:gray" style=""/>
                                    <datatables:column title="Menu Name" property="menName" headerStyle="width: 10%; background:#EEEEEE; color:gray"/>
                                    <datatables:column title="Menu Title" property="menTitle" sortable="true" headerStyle="width: 15%; background:#EEEEEE; color:gray"/>
                                    <datatables:column title="Menu Description" property="menDesc" sortable="true" headerStyle="width: 10%; background:#EEEEEE; color:gray"/>
                                    <datatables:column title="Action Url" property ="menLoc" sortable="true" headerStyle="width: 10%; background:#EEEEEE; color:gray"/>
                                    <c:url var="editURL" value="/editMenuLoginAction.action">
                                            <c:param name="menId">${row.menId}</c:param>
                                            <c:param name="pageAction">update</c:param>
                                    </c:url>

                                     <datatables:column  title="Edit" headerStyle="width: 10%; background:#EEEEEE; color:gray">
                                      <a href='<c:out value="${editURL}"/>'>Update
                                     </datatables:column>

                            </datatables:table>
                    </div>
            </div>

</body>

Action Class:

public class LoginAction extends BaseAction implements ModelDriven{

    private static final long serialVersionUID = 6173596192512987718L;

    private final Log log = LogFactory.getLog(LoginAction.class);
    private LoginFacade loginFacade = null;
    LoginVo loginVo = new LoginVo();

    List<LoginVo> datatablejsptaglib = new ArrayList<LoginVo>();


    @Override
    public Object getModel() {
            return loginVo;
    }


    public void setDatatablejsptaglib(List<LoginVo> datatablejsptaglib) {
            this.datatablejsptaglib = datatablejsptaglib;
    }

    //Launching Datatable list using taglib
    public String menuJsptaglib() throws Exception{
            datatablejsptaglib = loginFacade.menuLists(loginVo);
            return (Constant.MENU_LISTS.toString());

    }                 

}

Dao:

public List menuLists(LoginVo loginVo) throws Exception;

DAOHibernate

public List menuLists(LoginVo loginVo) throws Exception{

            List<LoginVo> menuListing = new ArrayList<LoginVo>();

            final String sqlQuery = "SELECT ID, PARENT_NAME, NAME, TITLE, DESCRIPTION, LOCATION, ACTION FROM MENU_ITEM WHERE PARENT_NAME IS NOT NULL";
            System.out.println(" line 4 " + sqlQuery);

            List results = (List) getHibernateTemplate().execute(
                            new HibernateCallback() {
                                    public Object doInHibernate(Session session)
                                                    throws HibernateException {
                                            SQLQuery sq = session.createSQLQuery(sqlQuery);
                                            sq.addScalar("ID", Hibernate.STRING);
                                            sq.addScalar("PARENT_NAME", Hibernate.STRING);
                                            sq.addScalar("NAME", Hibernate.STRING);
                                            sq.addScalar("TITLE", Hibernate.STRING);
                                            sq.addScalar("DESCRIPTION", Hibernate.STRING);
                                            sq.addScalar("LOCATION", Hibernate.STRING);
                                            sq.addScalar("ACTION", Hibernate.STRING);
                                            return sq.list();
                                    }
                            });
            try {
                    if (results.size() > 0) {
                            System.out.println(" line 5 " + results.size());
                            Iterator itr = results.iterator();
                            while (itr.hasNext()) {
                                    loginVo = new LoginVo();
                                    Object[] row = (Object[]) itr.next();

                                    loginVo.setMenId((String) row[0]);
                                    loginVo.setMenParent((String) row[1]);
                                    loginVo.setMenName((String) row[2]);
                                    loginVo.setMenTitle((String) row[3]);
                                    loginVo.setMenDesc((String) row[4]);
                                    loginVo.setMenLoc((String) row[5]);
                                    loginVo.setMenAction((String) row[6]);
                                    menuListing.add(loginVo);

                            }

                    }
            } catch (Exception e) {
                    log.error("FunctonVos error:" + e.getMessage());
            }

            return menuListing;

    }


    }

Answers

This discussion has been closed.