Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

The future of the DisplayTag Library

From the displaytag-devel mailing list:

I am sorry if I am asking a stupid question but is there any activity going on in the project? There are no new releases for almost a year... Neither are there any news on the project page. In our project we have modified the 1.0 version a bit and would like to share these changes with the community.

Fabrizio's response:

See http://displaytag.sourceforge.net now ;)

the website was frozen to the last 1.0 release, also due an extensive refactoring to the build/documentation system (migration to maven 2, splitting of optional modules and examples, ...) but activity on the project never stopped.

1.1 is now near, and I switched the default homepage to the 1.1 documentation. Warning: it's not released yet, but nightly builds are up.

The biggest feature of 1.1 has to be the ability to do external sorting and paging.

If you're looking for Ajax support in the displaytag, look no further than AjaxTags. I haven't been able to get ajax:displayTag working in my projects because I'm using a newer version of Prototype. However, it looks like the next version of AjaxTags supports the latest version of Prototype.

In addition to AjaxTags, you can also use AjaxAnywhere. Here's the code you'll need to do that (after adding AjaxAnywhere to your project):

<aa:zone name="userTable">

<display:table name="users" class="list" requestURI="" id="userList" export="true" 
    excludedParams="*" pagesize="5" sort="list">
    <display:column property="id" sort="true" href="editUser.html"
        paramId="id" paramProperty="id" titleKey="user.id"/>
    <display:column property="firstName" sort="true" titleKey="user.firstName"/>
    <display:column property="lastName" sort="true" titleKey="user.lastName"/>
    <display:column titleKey="user.birthday" sort="true" sortProperty="birthday">
        <fmt:formatDate value="${userList.birthday}" pattern="${datePattern}"/>
    </display:column>
</display:table>

</aa:zone>

<script type="text/javascript">
    ajaxAnywhere.getZonesToReaload = function() { return "userTable" }
    ajaxAnywhere.onAfterResponseProcessing = function() { replaceLinks() }
    function replaceLinks() {
        // replace all the links in <thead> with onclick's that call AjaxAnywhere
        var sortLinks = $('userList').getElementsByTagName('thead')[0]
                                     .getElementsByTagName('a');
        ajaxifyLinks(sortLinks);
        if (document.getElementsByClassName('pagelinks').length > 0) {
            var pagelinks = document.getElementsByClassName('pagelinks')[0]
                                    .getElementsByTagName('a');
            ajaxifyLinks(pagelinks);
        }
    }
    function ajaxifyLinks(links) {
        for (i=0; i < links.length; i++) {
            links[i].onclick = function() {
                ajaxAnywhere.getAJAX(this.href); 
                return false;
            }
        }
    }
    replaceLinks();
</script>

Libraries used in above code: AjaxAnywhere 1.0.2, DisplayTag 1.0 and Prototype 1.4.0_pre4. You can also see a demo online or download the code.

Posted in Java at Dec 29 2005, 10:46:56 AM MST 26 Comments
Comments:

Hi Matt, when was the last time you checked your demo? Tried in both IE6/Win and Firefox1.06/Win and it looks horrible. Paging does not work at all, edit form is shown but with a whole bunch of names instead of one. After canceling, the grid is not being refreshed properly.

Posted by Michael Jouravlev on January 04, 2006 at 11:33 AM MST #

Which demo Michael? I have several.

Posted by Matt Raible on January 04, 2006 at 12:03 PM MST #

Sorry - I read the comment before I read the post you were commenting on. You meant this demo. It looks fine to me on Firefox 1.5 on Windows 2000. I wasn't able to sort at first, but after editing a couple of users (I wasn't able to see the whole bunch of names problem), I was able to sort fine. This happens everyone once in a while - for some reason bad data causes Ajax to fail. I never said this was for production use. ;-)

Posted by Matt Raible on January 04, 2006 at 12:06 PM MST #

Hmm, it looks much better on a second attempt, though somewhat unstable. Messages about dropped Ajax handler or something... In-grid editing is not avaialble until I open and then cloe add/edit form. Still, much better that when I tried it first time :)

Posted by Michael Jouravlev on January 04, 2006 at 06:57 PM MST #

Hi Matt, your ajaxanywhere solution for DisplayTag works even better than ajaxtags. Because I am using sitemesh and I guess ajaxtags includes the HTML that was decorated by sitemesh and gets that HTML back into the page which causes duplicate page decorations in the page. But according to the ajaxanywhere homepage it generates an XML containing only the "updated" HTML. Finally my question is: How can we make your ajaxanywhere solution for DisplayTag more generic. My problem is I may have multiple displaytag tables inside a form and how can we make this javascript for multiple displaytag tables in the same document. Thanks in advance.

Posted by Burak Nona on January 08, 2006 at 05:08 PM MST #

Burak - actually, I had to exclude /ajax* in my decorators.xml for SiteMesh and AjaxAnywhere to play nicely together. Here's my decorators.xml:

<decorators defaultdir="/decorators">
    <excludes>
        <pattern>/ajax*</pattern>
    </excludes>
    <decorator name="default" page="default.jsp">
        <pattern>/*</pattern>
    </decorator>
</decorators>

To make the JavaScript more generic - you should be able to add parameters to the functions. Also, if you don't know which zone will be updated on the client (for instance, there's more than one zone), you'll need to set the zone on the server side using something like the following:

    if (AAUtils.isAjaxRequest(request)){
        AAUtils.addZones(request, "countriesList");
    }

Hope this helps.

Posted by Matt Raible on January 25, 2006 at 01:45 PM MST #

Hello all! First of all my compliments to you builders of the displaytag, especially 1.1. It's absolutely great and exactly what I need for the project I'm working on now. The external paging/sorting is of course what I'm talking about. There is only one problem: I can't get it working...:) I don't know if this is the right place for this question, but I couldn't find a forum or something so here I go: I work with Spring and Spring MVC. I implemented the PaginationList and put my list in the model for showing wih the displaytag. Now it's only a testlist but I think it should work. The error: I need to specify the 'size' in the tag, but I have done that. Heard of this error before already? Any idea what this could be? If you need to see the code, let me know where to put it or send it. I can't wait to hear what I'm doing wrong. Greetings, Ronald. p.s. did I already say I think displaytag rocks? ;)

Posted by Ronald Pieterse on February 09, 2006 at 02:44 PM MST #

There are forums for DisplayTag at SourceForge. http://sourceforge.net/forum/?group_id=73068 That might be the correct place to ask for assistance.

Posted by Kurt Martinsen on February 14, 2006 at 08:23 AM MST #

I was wondering if one can use DWR with the display tag. I have a search page that contains the criteria and results. When the search button is clicked, via a DWR call a search result would be returned which would populate the results table. If the result set is large, paging would come into the picture. I am facing the chicken or egg problem here. How can I display results in the table for say X rows via DWR and have display tag manage the pagination? Any tips guys.

Posted by Kalichar on May 23, 2006 at 06:03 PM MDT #

When I have multiple items in a single field of one row of a table then, how can the sorting be achieved using the display tag properties. I used decorator class for linking each of the multiple itmes to refer to differnet urls. Here, sorting is not working and gives ObjectLookUpException , unable to sort at RowSorter.compare in RowSorter.java

Posted by Rajesh on December 12, 2006 at 03:10 AM MST #

Deployed equnox-ajax, using mysql v5.0.17 database (not default postgres)
I got the following popup error when i submitted from edituser page (http://localhost:8080/equinox-ajax/editUser.html)
http://localhost:8080 org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException:Batch update returned unexpected row count from update: 0 actual rowcount:0 excepted:1
I couldnt add the user.
how this can be resolved.

Posted by gunny on December 18, 2006 at 09:11 PM MST #

for those like me who don't use Proptotype but jquery, this will do the trick :
var sortLinks = $('thead > tr > th > a');
var pagelinks =$('.pagelinks > a');

Posted by Vincent on January 18, 2007 at 09:49 AM MST #

Ronald Pieterse Try this In your server side bean set a REQUEST attribute containing the table count, in this case using the name [resultSize] request.setAttribute("resultSize", [count integer]); in the jsp set a varable with the value of the request attribute name; in this case I used [resultSize] <s:set name="resultSize" value="resultSize" scope="request"/> finally set the display tag attribute size="resultSize" <display:table name="itemRegistrations" class="list" requestURI="" id="itemRegistrationList" export="true" pagesize="20" sort="external" partialList="true" size="resultSize"> hope this helps - cheers!!!

Posted by irieb on January 21, 2007 at 12:52 PM MST #

Hi Matt? I am little new to Appfuse and Equinox. I have tried using AjaxAnywhere in to one of JSP pages in an Appfuse project thatcontained a single display tag. I need to apply ajax behaviour on the page, when I click the TH link. I am getting a javascript ALERT saying that - "AjaxANywhere error : Content-type not in text/xml: [text/html;charset=utf-8]" Can anyone help mein this context. pls Guide me the steps. Your help is appriciated very much. regards sanath

Posted by Sanath on March 16, 2007 at 04:47 AM MDT #

Hi Matt? I am little new to Appfuse and Equinox. I have tried using AjaxAnywhere in to one of JSP pages in an Appfuse project thatcontained a single display tag. I need to apply ajax behaviour on the page, when I click the TH link. I am getting a javascript ALERT saying that - "AjaxANywhere error : Content-type not in text/xml: [text/html;charset=utf-8]" Can anyone help mein this context. pls Guide me the steps. Your help is appriciated very much. regards sanath

Posted by Sanath on March 16, 2007 at 04:51 AM MDT #

I'm using sitemesh and dojo in my project. In order to improve performence of dojo I apply ajax behaviour to retrieve data from server and response to client as json oject, and fill it into div. But I have a problem with sitemesh: this data along with decorate page is filled in the div area. How do I fill data into div area only, not data and decorate page? How to using sitemesh and ajax at the same time?

Posted by Rose on May 16, 2007 at 01:50 AM MDT #

Hi All,

I have some problem with my code plz help me...........

<display:table name="requestScope.RegionList" requestURI="preRegion.do" pagesize="4" class=bodytextWithHeadingColor2>
    <td class="bodytext">
        <div align="left">
            <display:column property="regionCode" title="RegionCode" width="30%"
                            class="secondMainColor"></display:column>
        </div>
    </td>
    <td class="bodytext txtwrap">
        <div align="left">
            <display:column property="regionName" width="45%" class="secondMainColor"></display:column>
        </div>
    </td>
    <td class="bodytext txtwrap">
        <div align="left">
            <display:column property="placeName" class="secondMainColor" width="50%"></display:column>
        </div>
    </td>
    <td class="bodytext txtwrap">
        <div align="left">
            <display:column property="zoneName" class="secondMainColor" width="30%"></display:column>
        </div>
    </td>
    <td class="bodytext">
        <display:column class="thirdMainColor">
            <html:radio property="radRegionID" value="<%=region.getRegionID()%>"/>
        </display:column>
    </td>
</display:table>

This is my code for splitting the rows but in that i have some problem if i edit any row by the help of radio button, the first row is edited exctaly row was not edited.plz help me how can i edit the exact row........

Posted by Nagaraju on July 19, 2007 at 12:29 AM MDT #

Well, I know this is an old post but I thought maybe someone is reading it and can give me some advice.

Using this solution, I can now see that ajax is used when switching between pages. My problem is, when a new page is shown, the paging.banner.some_items_found (I'm using the default one) is for some reason corrupt and looks like this:

5Â 862 items found, displaying 5Â 851 to 5Â 862.[First/Prev] 191, 192, 193, 194, 195, 196 [Next/Last]

Any ideas why? It's a small problem but I don't know what's causing it.

//Vince

Posted by Vincent2 on May 05, 2008 at 09:13 AM MDT #

<%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://ajaxanywhere.sourceforge.net/" prefix="aa" %> <head> <script type="text/javascript" src="js/aa.js"></script> </head> <s:div id="listFilers" > <aa:zone name="filerTable"> <s:form id="filerform" method="POST"> <s:set name="filerlist" value="filerList" scope="request"/> <display:table name="filerlist" uid="filerlist" export="false" sort="list" pagesize="10" requestURI="/Dashboard/ViewFilerTable.action"> <display:column> <s:checkbox name="selectedItems" theme="simple" fieldValue="%{#attr.filerlist.id}" ></s:checkbox></display:column> <display:column property ="name" title="Name" escapeXml="true" sortable="true"></display:column> </display:table> </s:form> </aa:zone> </s:div> <script type="text/javascript"> ajaxAnywhere.getZonesToReaload = function() { return "filerTable" } ajaxAnywhere.onAfterResponseProcessing = function() { replaceLinks() } function replaceLinks() { // replace all the links in <thead> with onclick's that call AjaxAnywhere var sortLinks = $('filerlist').getElementsByTagName('thead')[0] .getElementsByTagName('a'); ajaxifyLinks(sortLinks); if (document.getElementsByClassName('pagelinks').length > 0) { var pagelinks = document.getElementsByClassName('pagelinks')[0] .getElementsByTagName('a'); document.write(pagelinks); ajaxifyLinks(pagelinks); } } function ajaxifyLinks(links) { for (i=0; i < links.length; i++) { links[i].onclick = function() { ajaxAnywhere.getAJAX(this.href); return false; } } } replaceLinks(); </script>

Posted by Dhaval on June 25, 2008 at 03:06 PM MDT #

I cant get this to work with Struts2 Let me know if any ideas... <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://ajaxanywhere.sourceforge.net/" prefix="aa" %> <s:div id="listFilers" > <aa:zone name="filerTable"> <s:form id="filerform" method="POST"> <s:set name="filerlist" value="filerList" scope="request"/> <display:table name="filerlist" uid="filerlist" export="false" sort="list" pagesize="10" requestURI="/Dashboard/ViewFilerTable.action"> <display:column property ="name" title="Name" escapeXml="true" sortable="true"></display:column> </display:table> </s:form> </aa:zone> </s:div>

Posted by Dhaval on June 25, 2008 at 03:09 PM MDT #

I cant get this to work with Struts2 Let me know if any ideas... <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://ajaxanywhere.sourceforge.net/" prefix="aa" %> <s:div id="listFilers" > <aa:zone name="filerTable"> <s:form id="filerform" method="POST"> <s:set name="filerlist" value="filerList" scope="request"/> <display:table name="filerlist" uid="filerlist" export="false" sort="list" pagesize="10" requestURI="/Dashboard/ViewFilerTable.action"> <display:column property ="name" title="Name" escapeXml="true" sortable="true"></display:column> </display:table> </s:form> </aa:zone> </s:div>

Posted by Dhaval on June 25, 2008 at 03:10 PM MDT #

Hey has anyone got the ajaxAnywhere working when you are refreshing the div inside a tabbed panel. Some sample code would help

Posted by dynamicd on August 01, 2008 at 01:03 PM MDT #

. I have tried using AjaxAnywhere in to one of JSP pages in an Appfuse project thatcontained a single display tag. I need to apply ajax behaviour on the page, when I click the TH link. I am getting a javascript ALERT saying that - "AjaxANywhere error : Content-type not in text/xml: [text/html;charset=ISO-8859-15]" Can anyone help mein this context!!!

Posted by fer on September 16, 2008 at 08:49 AM MDT #

Is there a way to add href to column title only instead of relying on

<display:column title="${hard_coded_href_from_controller}" />

It would be great if there was

<display:column-title>
column title link</display:column-title>

With tableDecorator there is no way to get title name.

Posted by sj2004 on November 16, 2008 at 11:40 AM MST #

y did u ask?

Posted by 196.12.61.89 on June 11, 2009 at 07:07 AM MDT #

very nice

Posted by 196.12.232.146 on January 21, 2010 at 09:15 AM MST #

Post a Comment:
  • HTML Syntax: Allowed