Does Displaytag display "media type" in a page or query attribute?

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

I suppose I could write a table decorator and use that to insert the media type into the query, but it would be nice to avoid this if the tag is already doing this. The documentation is unclear on this issue; I guess I can start digging into the source code too.

+2


a source to share


2 answers


Don't know as I am not using Displaytag, but for further debugging it might be good to know that you can just display all of these attributes by simply printing ${pageScope}

and ${requestScope}

or iterating over them Map

using JSTL c:forEach

.

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

      



This can flatten the Displaytag attribute of interest.

+1


a source


Use the HTTPTagParameters.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 ...
}

      

0


a source







All Articles