Question

When using displaytag the URL it's generating for paging and sorting is too long for IE.

Is there a way around this without resorting to external paging and sorting?

Cheers.

Was it helpful?

Solution

Hopefully this will help someone. And if there is another way, then let me know.

The way I have got round this is by excluding all parameters on the display table tag.

<display:table excludedParams="*"> ... </display:table>

Which means the url doesn't fill up with parameters.

Great, but how do you keep a handle on the list of objects that we're using?

I did this by setting an attribute on the context's request. And as I'm using the Stripes framework I did this by using the ActionBeanContext.

public class SchemeActionBeanContext extends ActionBeanContext {
    public void setThings(List<Things> things) {    
        getRequest().getSession().setAttribute("stuff", things);
    }

    public List<Things> getThings() {
        return (List<Things>)getRequest().getSession().getAttribute("stuff");
    }

And then you can set and get them throughout the lifecycle if the page/request.

OTHER TIPS

I was facing a similar issue where url with all the form fields were getting appended to url during pagination and sorting. This was resolved by identifying all the pagination links mentioned below by either the unique title that it forms (Go to page ) and the inner htmls such as 'Next' 'Prev' etc it forms.

The javascript params in the method below are explained here 1) head1/head2 - sorting column names passed. 2) formName - name of the form, 3) masterName - the method called in your controller

I have a logic on an input box named 'strNamesearch' on the basis of which my calling method changes.

Also note, once you do this, don't forget to add excludedParams="*" in display:table tag

Here is the code:

function findAnchorGen(head1,head2,formName,masterName) {
    var formObj = eval("document."+formName);
    var methodName;
    var strSearch = trim(formObj.strNamesearch.value);
    if(strSearch == null || strSearch == '') {
        methodNameP = "fetch"+masterName;
    } else {
        methodNameP = "search"+masterName;
    }
    var anchors = document.links; // your anchor collection   
    var i = anchors.length; 
    while (i--) {
        var a = anchors[i];     
        var aRef = a.href;
        var aTitle = a.title;
        index = aTitle.indexOf("Go to page");
        var inHtml = a.innerHTML;

        if(index >= 0 || inHtml == 'Last' || inHtml == 'Next' || inHtml == 'First' || inHtml == 'Prev' || inHtml == head1 || inHtml == head2) {
            //alert("Ref = " + aRef + " | title = " + aTitle + " | inner html = " + a.innerHTML);
            a.href="#";
            a.onclick = (function(aRef,formName,methodNameP){return function(){fSubmit(aRef,formName,methodNameP);}})(aRef,formName,methodNameP);
        }
    } 
}

function fSubmitGen(aRef,formName,methodNameP) {
    var formObj = eval("document."+formName);
    formObj.action = aRef;
    formObj.method.value = methodNameP;
    formObj.submit();
}

This is a workaround and is working well for us. I hope it works for you too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top