Question

When you enable "export" from Displaytag, the tag code gives you links with special magic parameters that the tag recognizes as indicators that the table contents should be exported (as CSV, Excel, whatever). Well I'm interested in detecting the media type so that (for example) I can exclude columns that make no sense in an export (embedded action buttons, for one thing, or checkboxes for row selection).

I suppose I could write a table decorator and use that to stick the media type on the request, but it'd be nice to avoid that if the tag already does it. The documentation is not clear on the subject; I guess I can start digging through the source code too.

Was it helpful?

Solution

No idea since I don't use Displaytag, but for further debugging, it may be good to know that you could just display all of those attributes by plain printing ${pageScope} and ${requestScope} or by looping over them as if it's a Map using JSTL c:forEach.

<c:forEach items="${requestScope}" var="entry">
    ${entry.key} = ${entry.value}<br>
</c:forEach>

That may nail down the Displaytag attribute of interest.

OTHER TIPS

Use TableTagParameters.PARAMETER_EXPORTTYPE HTTP request parameter.

ActionBeanContext context; // in your action bean class ...

String exportTypeStr = context.getRequest().getParamter(TableTagParameters.PARAMETER_EXPORTTYPE);
if (String.valueOf(MediaTypeEnum.EXCEL.getCode().equals (exportTypeStr)) {
    /// user selected export to Excel format ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top