2009/02/15

DisplayTag 1.2 Form Submission Problem

Prior to 1.2, all the links generated by displaytag are Http Get only, which prevented it from being integrated into many web applications. Including ours. Those links includes paging/sorting and exporting links.

I had to solve the problem by using a customized TableTag along with custom javascript code. The solution was applied around the 1st week of December.

DisplayTag 1.2, released Dec. 27, 2008, solves the form submission problem. Now The paging/sorting links can actually be Http Post instead of Get. Woot!

However, they must have forgot the export link - it's still get only... Another custom patch...

Well one day I'll have to contribute it back to the open source project. Too busy recently.

5 comments:

manu said...

A new java/J2EE website develope by me please check it out
www.fabgabs.com and join the new social networking sensation with maps and videos

Bhanwar said...

Hi,

I am also facing the same challenge to change the links generated by display tag to Http POST, especially in case of exports, Please let me know any updates(patch) on the following or is there any solution available to solve this problem..

Bhanwar Gupta

J2EE Blogger said...

Hi Bhanwar

Here is what we did to make the export link 'post' aware:

1. In org.displaytag.render.HtmlTableWriter.java, in side method private void writeExportLinks(), change it to:


// Figure out what formats they want to export, make up a little string
Href exportHref = (Href) this.baseHref.clone();

if (this.tableModel.getForm() != null)
{
exportHref = new PostHref(exportHref, tableModel.getForm());
}
...


2. Add the following line to org.displaytag.tags.TableTag.java, just before the closing tag of the method protected void initHref(RequestHelper requestHelper):

baseHref.addParameter(TableTagParameters.PARAMETER_EXPORTING, "");
baseHref.addParameter(this.paramEncoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE), "");


3. You'll also need to disable a few unit tests related to these changes, I didn't bother fix them.

Let me know how this works for you! Cheers.

Bhanwar said...

Hi,

I made the JAR without validating the Unit Tests, but my display table is giving _jspx_th_display_005ftable_005f0 AS NULL in the below mentioned line.

int _jspx_eval_display_005ftable_005f0 = _jspx_th_display_005ftable_005f0.doStartTag();



org.displaytag.tags.TableTag _jspx_th_display_005ftable_005f0 = (org.displaytag.tags.TableTag) _005fjspx_005ftagPool_005fdisplay_005ftable_005fsort_005fsize_005frequestURI_005fpartialList_005fpagesize_005fname_005fid_005fexport_005fdecorator_005fclass_005fcellspacing_005fcellpadding.get(org.displaytag.tags.TableTag.class);


Please suggest how to go about it...

Bhanwar Gupta

Steve Smith said...

Great and Useful Article.

Online Java Training

Online Java Training from India

Online Java Training

Online Java Training From India

Java Training Institutes in Chennai

Java Training in Chennai

Well well... why another J2EE blog? I benefited from other people's technical blogs, and guess what, it's a good idea to contribute some of my works too. Hope it's helpful and useful, to all of your folks.