Implementing DisplayTag in Java

Download Jars

View Page

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.javahunter.displaytag.EmployeeMaster"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="el" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="css/displaytag.css" rel="stylesheet"/>
        <link rel="stylesheet" href="css/screen.css" type="text/css">  
        <link rel="stylesheet" href="css/site.css" type="text/css"> 
        <title>JavaHunter - DisplayTag</title>
    </head>
    <body>
        <%
            List<EmployeeMaster> employeeMasters = new ArrayList<EmployeeMaster>();
            employeeMasters.add(new EmployeeMaster(1, "taher", "java", "9999999999"));
            employeeMasters.add(new EmployeeMaster(2, "vipul", "dotnet", "9999999999"));
            employeeMasters.add(new EmployeeMaster(3, "japan", "java", "9999999999"));
            employeeMasters.add(new EmployeeMaster(4, "dixit", "testing", "9999999999"));
            employeeMasters.add(new EmployeeMaster(5, "rest", "hr", "9999999999"));
            employeeMasters.add(new EmployeeMaster(6, "best", "acc", "9999999999"));
            employeeMasters.add(new EmployeeMaster(7, "nest", "support", "9999999999"));
            employeeMasters.add(new EmployeeMaster(8, "karan", "dotnet", "9999999999"));
            employeeMasters.add(new EmployeeMaster(9, "guest", "testing", "9999999999"));
            employeeMasters.add(new EmployeeMaster(10, "nishith", "java", "9999999999"));
            request.setAttribute("tlist", employeeMasters);
        %>                    
        <b><i>Download Employee Details:</i></b>
        <display:table uid="data" sort="list" export="true" pagesize="3" keepStatus="true"
                       name="requestScope.tlist">
            <display:caption title="Employee Details" media="html excel pdf">Employee Details</display:caption>
            <display:column property="empId" title="Employee ID" sortable="true" media="html pdf"/>
            <display:column property="empName" title="Employee Name"/>
            <display:column property="address" title="Address"/>
            <display:column property="phoneNo" title="Contact No."/>            
            <display:setProperty name="export.pdf.filename" value="EMPDetails.pdf"/>
        </display:table>
    </body>
</html>

displaytag.properties

basic.empty.showtable=false
basic.show.header=true

# page | list
sort.amount=page

export.amount=list
export.decorated=true

paging.banner.group_size=8
paging.banner.placement=top


css.tr.even=even
css.tr.odd=odd
css.th.sorted=sorted
css.th.ascending=order1
css.th.descending=order2
css.table=
css.th.sortable=sortable

# factory classes for extensions
factory.requestHelper=org.displaytag.util.DefaultRequestHelperFactory

# factory class for decorators
factory.decorator=org.displaytag.decorator.DefaultDecoratorFactory

# locale provider (Jstl provider by default)
locale.provider=org.displaytag.localization.I18nJstlAdapter

# locale.resolver (nothing by default, simply use locale from request)
#locale.resolver=

export.types=csv excel xml pdf rtf

export.csv.class=org.displaytag.export.CsvView
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView
export.xml.class=org.displaytag.export.XmlView
export.rtf.class=org.displaytag.export.DefaultRtfExportView
export.pdf.class=org.displaytag.export.DefaultPdfExportView

export.csv=true
export.csv.label=<span class="export csv">CSV </span>
export.csv.include_header=false
export.csv.filename=export.csv

export.excel=true
export.excel.label=<span class="export excel">Excel </span>
export.excel.include_header=true
export.excel.filename=export.xls

export.xml=true
export.xml.label=<span class="export xml">XML </span>
export.xml.filename=export.xml

export.pdf=true
export.pdf.label=<span class="export pdf">PDF </span>
export.pdf.include_header=true
export.pdf.filename=export.pdf

export.rtf=true
export.rtf.label=<span class="export rtf">RTF </span>
export.rtf.include_header=true
export.rtf.filename=export.doc

# messages

basic.msg.empty_list=Nothing found to display.
basic.msg.empty_list_row=<tr class="empty"><td colspan="{0}">Nothing found to display.</td></tr>
error.msg.invalid_page=invalid page

export.banner=<div class="exportlinks">Export options: {0}</div>
export.banner.sepchar= |

paging.banner.item_name=item
paging.banner.items_name=items

paging.banner.no_items_found=<span class="pagebanner" style="text-align:center;">No {0} found.</span>
paging.banner.one_item_found=<span class="pagebanner" style="text-align:center;">One {0} found.</span>
paging.banner.all_items_found=<span class="pagebanner" style="text-align:center;">{0} {1} found, displaying all {2}.</span>
paging.banner.some_items_found=<span class="pagebanner" style="text-align:center;">{0} {1} found, displaying {2} to {3}.</span>

paging.banner.full=<span class="pagelinks" style="text-align: right;">[<a href="{1}">First</a>/<a href="{2}">Prev</a>] {0} [<a href="{3}">Next</a>/<a href="{4}">Last</a>]</span>
paging.banner.first=<span class="pagelinks" style="text-align: right;">[First/Prev] {0} [<a href="{3}">Next</a>/<a href="{4}">Last</a>]</span>
paging.banner.last=<span class="pagelinks" style="text-align: right;">[<a href="{1}">First</a>/<a href="{2}">Prev</a>] {0} [Next/Last]</span>
paging.banner.onepage=<span class="pagelinks" style="text-align: right;">{0}</span>

paging.banner.page.selected=<strong>{0}</strong>
paging.banner.page.link=<a href="{1}" title="Go to page {0}">{0}</a>
paging.banner.page.separator=, \

# external sort and pagination
pagination.sort.param=sort
pagination.sortdirection.param=dir
pagination.pagenumber.param=page
pagination.searchid.param=searchid
pagination.sort.asc.value=asc
pagination.sort.desc.value=desc
pagination.sort.skippagenumber=true

# unused
save.excel.banner=<a href="{0}" rel="external">save ({1} bytes)</a>
save.excel.filename=export.xls
Advertisements
This entry was posted in displaytag, JSP and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s