letsbedecent
asked on
display tag
Hello,
I want to understand why an export filter is needed for a display tag to function properly !! How does display tag export the content of a table to pdf or excel and during this process why does it need to have a filter (export filter) ??
when we are trying to export does the request go back to server and get the information again ??
Thank you.
I want to understand why an export filter is needed for a display tag to function properly !! How does display tag export the content of a table to pdf or excel and during this process why does it need to have a filter (export filter) ??
when we are trying to export does the request go back to server and get the information again ??
Thank you.
Ah, I've just found this displaytag.sourceforge.net which I assume is what you are talking about as it has both dispay tags and an export filter.
In answer to your question, the filter disallows the response to be flushed, This means that you can reset the content-type (mime-type) of any binary content like pdf/xls files even though you may have already written to the response. This applies to any non-html format data and to binary data.
It doesn't go and get the data again, all it does it prevent the response buffer from being flushed, so that the display tag can work in more situations than it would be able to do otherwise.
In answer to your question, the filter disallows the response to be flushed, This means that you can reset the content-type (mime-type) of any binary content like pdf/xls files even though you may have already written to the response. This applies to any non-html format data and to binary data.
It doesn't go and get the data again, all it does it prevent the response buffer from being flushed, so that the display tag can work in more situations than it would be able to do otherwise.
Other causes of the buffer being flushed:
The method out.flush() has been called.
A file has been included, e.g. <jsp:include page="header.jsp" flush="true"/>
You have filled the buffer up, e.g. the jsp has outputted more characters than the page buffer can hold.
Also, be aware that simply writing to the output using out.println() or <%=blah%> will commit the response whcih means that trying to change a response property like the content-type would throw an exception.
Any of these would cause the display tag to fail unless you use the export filter.
The method out.flush() has been called.
A file has been included, e.g. <jsp:include page="header.jsp" flush="true"/>
You have filled the buffer up, e.g. the jsp has outputted more characters than the page buffer can hold.
Also, be aware that simply writing to the output using out.println() or <%=blah%> will commit the response whcih means that trying to change a response property like the content-type would throw an exception.
Any of these would cause the display tag to fail unless you use the export filter.
ASKER
so, if the response buffer is not flushed how can the data be displayed on the page ??
because only once the data is displayed on page will the user want to export it to a pdf or xls format... by clicking on one of the options right !!
because only once the data is displayed on page will the user want to export it to a pdf or xls format... by clicking on one of the options right !!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>How are you generating the other files(pdf, xls)?
Well, i am not doing anything except using the tag... i got a sample code. In that there is simply an option for export (to 4 standard types, Comma seperated list, pdf, xls, xml) at the bottom of the table,
You simply click on them and the file-download dialog opens up asking you if you want to save it or open it !!!!!
I just am not able to understand how the display tag does all of this !!
Well, i am not doing anything except using the tag... i got a sample code. In that there is simply an option for export (to 4 standard types, Comma seperated list, pdf, xls, xml) at the bottom of the table,
You simply click on them and the file-download dialog opens up asking you if you want to save it or open it !!!!!
I just am not able to understand how the display tag does all of this !!
I'm guessing (as I've not seent the code) that all it does is allow to to change the response header even if the response has been commited.
If you look at the HTML underneath the export buttons, I think it would say somehting like
/download.jsp?type=pdf
/download.jsp?type=csv
And the content type will be taken from the parameter (or somewhere else in the name). Also. it may set the atttachment header so that the save file box automatically pops up.
If you look at the HTML underneath the export buttons, I think it would say somehting like
/download.jsp?type=pdf
/download.jsp?type=csv
And the content type will be taken from the parameter (or somewhere else in the name). Also. it may set the atttachment header so that the save file box automatically pops up.
As you saw earlier with the question about:
response.setHeader("Conten t-Disposit ion","atta chment; filename=\"" + attachmentVO.getFileName() + "\"");
response.setHeader("Conten
The only thing I can guess at is that you are using a filter to add the mime-type of the downloaded document. In Java you would use XSL-FO and HSSF(POI) to create pdfs and xls files on the fly, so maybe this is what is being done, or else somehting a little more involved like Actuate.
>>when we are trying to export does the request go back to server and get the information again ??
No idea unless you can provide some code, like what display tag and what filter