Hi list

 

My name is Guenther and I work in a project of a Telco Company in Austria. Our team uses the display-tag extensively and we would like to thank you for your cool project which saved us a lot of time.

Recently we got a little CR from our business guys who wanted the displaytag-tables to remember pagenumber, sorting … Therefore I patched two methods of your org.displaytag.util.DefaultRequestHelper:

 

<code>

 

    public String getParameter(String key)

    {

        // actually simply return the parameter, this behaviour could be changed

        return this.request.getParameter(key);

    }

 

    public Integer getIntParameter(String key)

    {

        String value = this.request.getParameter(key);

            .

            .

            .

 

</code>

 

became

 

<code>

 

    public String getParameter(String key)

    {

            HttpSession session = this.request.getSession();

            String value = this.request.getParameter(key);

                       

            boolean parameterCachingEnabled = true;

                       

            if (parameterCachingEnabled) {

                        // check if cache already exists

                        HashMap cache = (HashMap) session.getAttribute(CACHE_KEY);

                        if (cache == null) {

                                    cache = new HashMap();

                                    session.setAttribute(CACHE_KEY, cache);

                        }

                       

                        if (value == null) {

                                    // let's get the parameter from the cache

                                    value = (String) cache.get(key);

                                   

                        } else {

                                    // let's put the parameter in the cache

                                    cache.put(key, value);

                        }

            }

            return value;

    }

 

    public Integer getIntParameter(String key)

    {

        String value = getParameter(key);

            .

            .

            .

 

</code>

 

 

We would be very glad if you want to add this to displaytag. It’s on you how to pass the parameterCachingEnabled flag to the method. We always needed the cache and wanted to modify as little as possible (for copy and paste upgrade reasons if you don’t want to add these changes to future releases).

 

Cheers,

 

Guenther

 

Reply via email to