Christofer Jennings said:
> Am I doing this right?

No!  :^)

> I have SpringMVC set up to use JSPs in WEB-INF/views/...
> The links for displaytag sorting end up like this: http://server/
> domain/WEB-INF/views/table.jsp?...
> Of course that doesn't work because WEB-INF is blocked. So I'm making
> a new RequestHelperFactory, RequestHelper, and Href to make the links
> be more like http://server/domain/tableController?...
>
> Is there some simpler way? Like a setting for the default Href or
> something?

It all depends on what you're doing. The simplest stand-alone table
requires only the requestURI parameter, with the Spring controller URL
(that is the mapped controller name; the Spring standard is .htm, although
a lot of people use .do per Struts; I use .do here, although that's not
what I'm actually using) in it:

<display:table ... requestURI="/myPage.do">
   ...
</display:table>

The more complicated scenario is when you're embedding the table within a
form (this is very common with Spring MVC and SimpleFormController and the
like) and need to preserve sorts and paging across form requests.  Here's
how I handle this:

Within my controller I have a getTableViewParameters() method.  This looks
for all request parameters that start with "d-" (there's probably a better
way to find displaytag sorting and paging params, but this works for us!)
and stores them in a Map<String, String> object.  I then put this object
into the model I return with the view:

   Map<String, String> displayParams = getTableViewParameters(request);

   if (displayParams.size() > 0)
   {
      model.put("tableview", displayParams);
   }

   return new ModelAndView("viewName", "model", model);

Then in the view page, I have a little block that takes these parameters
and sticks them onto the Spring request URL:

<c:url value="/myPage.do" var="formUrl">
    <c:forEach items="${model.tableview}" var="viewparam">
        <c:param name="${viewparam.key}" value="${viewparam.value}"/>
    </c:forEach>
</c:url>

What this does is takes the Spring request URL and appends all of your
tableview parameters to it.  That means that you've now got a URL that
will submit a form with the paging and sorting parameters preserved:

<form name="doStuff" method="post" action="${formUrl}">...

-- 
Rick Herrick
[EMAIL PROTECTED]

I haven't got time for inner peace.

"No reasonable definition of reality could be expected to permit
this."--Albert Einstein, Boris Podolsky and Nathan Rosen in 1935


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to