Package com.webmethods.caf.faces.bean
Class SimpleFileExportBean
java.lang.Object
com.webmethods.caf.faces.bean.SimpleFileExportBean
- All Implemented Interfaces:
IFileExportBean
,IFileExportBeanEx
This is a simple implementation of IFileExportBeanEx that is java bean compatible.
If created as a bean then exportFileName, exportContentType and either binaryData or
textData properties must be set.
For textData, exportCharactersEncoding should be set as well.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
The data to be exported asbyte []
protected String
Character encoding for export of file content.protected int
The length of data.protected String
The content type, seesetExportContentType(String)
.protected String
Name of the file to be exported.protected boolean
boolean
for force download, seesetDownloadForced(boolean)
.protected boolean
boolean
that denotes that the content is binary.protected String
The data to be exported asString
Fields inherited from interface com.webmethods.caf.faces.bean.IFileExportBean
UNKNOWN_CONTENT_LENGTH
-
Constructor Summary
ConstructorsConstructorDescriptionBean empty constructorSimpleFileExportBean
(String fileName, String contentType, int contentLength, boolean forceDownload, byte[] binaryData) Constructor.SimpleFileExportBean
(String fileName, String contentType, int contentLength, boolean forceDownload, String textData) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Returns the binary data.Returns character encoding for this export file content (valid only when isExportBinary() == false)int
Return the length of the content that is to be exported.Gets the content type of the response being sent to the client.Return the file name for the exported dataReturns the text data.boolean
Return true to send the response headers that will force the user to choose what to do with the file (Open vs.boolean
Return true if the export will be sending binary data to the response, false if the export will be sending text.void
setBinaryData
(byte[] binaryData) Sets the binary data for export.void
setDownloadForced
(boolean forceDownload) Sets force download to send the response headers that will force the user to choose what to do with the file (Open vs.void
setExportCharacterEncoding
(String encoding) Sets character encoding for this export file content (valid only when isExportBinary() == false)void
setExportContentType
(String contentType) Sets the content type of the response being sent to the client.void
setExportFileName
(String fileName) Return the file name for the exported data.void
setTextData
(String textData) Sets the text data for export.void
writeExportBytes
(OutputStream outStream) Invoked to allow the bean to write binary data to the output stream.void
writeExportText
(PrintWriter writer) Invoked to allow the bean to write the export text to the output writer.
-
Field Details
-
forceDownload
protected boolean forceDownloadboolean
for force download, seesetDownloadForced(boolean)
. -
fileName
Name of the file to be exported. -
contentType
The content type, seesetExportContentType(String)
. -
contentLength
protected int contentLengthThe length of data. -
isBinary
protected boolean isBinaryboolean
that denotes that the content is binary. -
binaryData
protected byte[] binaryDataThe data to be exported asbyte []
-
textData
The data to be exported asString
-
charactersEncoding
Character encoding for export of file content.Default: UTF-8
-
-
Constructor Details
-
SimpleFileExportBean
public SimpleFileExportBean()Bean empty constructor -
SimpleFileExportBean
public SimpleFileExportBean(String fileName, String contentType, int contentLength, boolean forceDownload, byte[] binaryData) Constructor.- Parameters:
fileName
- name of the file to be exportedcontentType
- the content type, seesetExportContentType(String)
contentLength
- the length of dataforceDownload
- force download, seesetDownloadForced(boolean)
binaryData
- the data to be exported asbyte []
-
SimpleFileExportBean
public SimpleFileExportBean(String fileName, String contentType, int contentLength, boolean forceDownload, String textData) Constructor.- Parameters:
fileName
- name of the file to be exportedcontentType
- the content type, seesetExportContentType(String)
contentLength
- the length of dataforceDownload
- force download, seesetDownloadForced(boolean)
textData
- the data to be exported asString
-
-
Method Details
-
isDownloadForced
public boolean isDownloadForced()Description copied from interface:IFileExportBean
Return true to send the response headers that will force the user to choose what to do with the file (Open vs. Save).- Specified by:
isDownloadForced
in interfaceIFileExportBean
- Returns:
- true to force a download
-
setDownloadForced
public void setDownloadForced(boolean forceDownload) Sets force download to send the response headers that will force the user to choose what to do with the file (Open vs. Save).- Parameters:
forceDownload
- The forceDownload to set.
-
getExportFileName
Description copied from interface:IFileExportBean
Return the file name for the exported data- Specified by:
getExportFileName
in interfaceIFileExportBean
- Returns:
- file name for the exported file
-
setExportFileName
Return the file name for the exported data.- Parameters:
fileName
- name for the file
-
getExportContentType
Description copied from interface:IFileExportBean
Gets the content type of the response being sent to the client. The content type may include the type of character encoding used, for example, text/html; charset=ISO-8859-4.- Specified by:
getExportContentType
in interfaceIFileExportBean
- Returns:
- content type of the exported content
-
setExportContentType
Sets the content type of the response being sent to the client.The content type may include the type of character encoding used, for example, text/html; charset=ISO-8859-4.
- Parameters:
contentType
-
-
getExportContentLength
public int getExportContentLength()Description copied from interface:IFileExportBean
Return the length of the content that is to be exported.- Specified by:
getExportContentLength
in interfaceIFileExportBean
- Returns:
- the length of the content or return
IFileExportBean.UNKNOWN_CONTENT_LENGTH
if it is not known
-
isExportBinary
public boolean isExportBinary()Description copied from interface:IFileExportBean
Return true if the export will be sending binary data to the response, false if the export will be sending text.- Specified by:
isExportBinary
in interfaceIFileExportBean
- Returns:
- true for binary export, false for text
-
writeExportText
Description copied from interface:IFileExportBean
Invoked to allow the bean to write the export text to the output writer.- Specified by:
writeExportText
in interfaceIFileExportBean
- Parameters:
writer
- the output writer
-
writeExportBytes
Description copied from interface:IFileExportBean
Invoked to allow the bean to write binary data to the output stream.- Specified by:
writeExportBytes
in interfaceIFileExportBean
- Parameters:
outStream
- the output stream- Throws:
IOException
- thrown if there is an I/O exception during the export
-
getExportCharacterEncoding
Description copied from interface:IFileExportBeanEx
Returns character encoding for this export file content (valid only when isExportBinary() == false)- Specified by:
getExportCharacterEncoding
in interfaceIFileExportBeanEx
- Returns:
- java character encoding name
-
setExportCharacterEncoding
Sets character encoding for this export file content (valid only when isExportBinary() == false)- Parameters:
encoding
- Java character encoding name
-
getBinaryData
public byte[] getBinaryData()Returns the binary data.- Returns:
- binary data, or null if not set.
-
setBinaryData
public void setBinaryData(byte[] binaryData) Sets the binary data for export. Also, forces the data to be exported as binary (character encoding will not apply).- Parameters:
binaryData
- binary data asbyte []
-
getTextData
Returns the text data.- Returns:
- text data, or null if not set.
-
setTextData
Sets the text data for export. Also, forces the data to be exported with character encoding (binary export will not apply).- Parameters:
textData
- text data asString
-