com.acesoft.aceoffix
Class FileRequest

java.lang.Object
  extended by com.acesoft.aceoffix.FileRequest

public class FileRequest
extends java.lang.Object

FileRequest class is used to receive and save the document submitted by AceoffixCtrl.

FileRequest class is used to receive and save the document submitted by AceoffixCtrl. The FileRequest object must be created and used in the server page specified by AceoffixCtrl.setSaveFilePage.

Version:
3.0
Author:
Acesoft Corporation

Field Summary
 java.lang.String fileExtName
           
 java.lang.String fileName
           
 int fileSize
           
 
Constructor Summary
FileRequest(HttpServletRequest request, HttpServletResponse response)
          Initializes a new instance of the FileRequest class.
 
Method Summary
 void close()
          Returns a success message to AceoffixCtrl.
 java.lang.String getDocumentText()
          Gets the plain text of the document without format.
 byte[] getFileBytes()
          Returns an array of the bytes in the file submitted by AceoffixCtrl.
 java.lang.String getFileExtName()
          Gets the file name extension of the file.
 java.lang.String getFileName()
          Gets the file name of the file submitted by AceoffixCtrl.
 int getFileSize()
          Gets the size of the file, in bytes.
 java.io.FileInputStream getFileStream()
          Returns an FileInputStream object which contains the file content submitted by AceoffixCtrl.
 java.lang.String getFormField(java.lang.String name)
          Gets the value with the specified name in the form fields of the page with AceoffixCtrl.
 boolean saveToFile(java.lang.String filePath)
          Saves the contents of the document to a disk file.
 void showPage(int width, int height)
          Prompt a custom dialog box to show the saving result.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileName

public java.lang.String fileName

fileExtName

public java.lang.String fileExtName

fileSize

public int fileSize
Constructor Detail

FileRequest

public FileRequest(HttpServletRequest request,
                   HttpServletResponse response)
            throws java.lang.Exception,
                   java.io.IOException
Initializes a new instance of the FileRequest class.

Throws:
java.lang.Exception
java.io.IOException
Method Detail

getFileName

public java.lang.String getFileName()
Gets the file name of the file submitted by AceoffixCtrl. Typically, it's the file name which is opened. The file name contains the file name extension, but not including the directory path.

If the document which is going to be opened is a binary stream outputted by server page, the file name will be "aceoffix" with the correct file name extension.


getFileExtName

public java.lang.String getFileExtName()
Gets the file name extension of the file.


getFileSize

public int getFileSize()
Gets the size of the file, in bytes. The file length, in bytes.


close

public void close()
           throws java.io.IOException,
                  java.lang.Exception
Returns a success message to AceoffixCtrl.

If the code for saving document executes successfully, you should call this method to return a success message to AceoffixCtrl. Typically, the close method should be called at the end of code in SaveDataPage.

Throws:
java.io.IOException
java.lang.Exception

saveToFile

public boolean saveToFile(java.lang.String filePath)
                   throws ServletException,
                          java.io.IOException,
                          java.lang.Exception
Saves the contents of the document to a disk file.

Saves the document to disk with a new location and file name. If you want to save the document to database, please call the getFileBytes or getFileStream method.

The following code example demonstrates how to save the document that are uploaded by AceoffixCtrl to the specified folder on the Web server's local disk. In order to display all the possible exception messages when you debug your code, do not use try...catch statements in SaveFilePage. When an exception is thrown, AceoffixCtrl will show the exception dialog box.

 FileRequest freq = new FileRequest(request, response);
 freq.saveToFile(request.getSession().getServletContext().getRealPath("jsp/doc/") + "\\" + freq.getFileName());
 freq.close();
 

Parameters:
filePath - The fully qualified path of the file to which you want to save the document.
Throws:
ServletException
java.io.IOException
java.lang.Exception

showPage

public void showPage(int width,
                     int height)
              throws java.io.IOException
Prompt a custom dialog box to show the saving result.

After save document, if you want to prompt a custom dialog box to show the saving result, you can call this method. The message page shown in the dialog box is the current SaveFilePage. By default, the SaveFilePage will display nothing. You can add friendly messages in the SaveFilePage.

Parameters:
width - The width of custom dialog, in pixels.
height - The height of custom dialog, in pixels.
Throws:
java.io.IOException

getFileBytes

public byte[] getFileBytes()
                    throws ServletException,
                           java.io.IOException,
                           java.lang.Exception
Returns an array of the bytes in the file submitted by AceoffixCtrl.

If you want to save the file to the data field of a database, you should call this method. If you want to save the file to disk, you only need to call saveToFile.

Throws:
ServletException
java.io.IOException
java.lang.Exception

getFileStream

public java.io.FileInputStream getFileStream()
                                      throws ServletException,
                                             java.io.IOException,
                                             java.lang.Exception
Returns an FileInputStream object which contains the file content submitted by AceoffixCtrl.

Throws:
ServletException
java.io.IOException
java.lang.Exception

getDocumentText

public java.lang.String getDocumentText()
                                 throws java.io.IOException,
                                        java.lang.Exception
Gets the plain text of the document without format.

Get the text-only content and save it to database. So we can have the full-text search function in Word documents. This property only applies to Word currently.

Throws:
java.io.IOException
java.lang.Exception

getFormField

public java.lang.String getFormField(java.lang.String name)
                              throws java.io.IOException,
                                     java.lang.Exception
Gets the value with the specified name in the form fields of the page with AceoffixCtrl.

When AceoffixCtrl is saving document, you can call this method to get the values of form fields posted from the page with AceoffixCtrl. To be able to capture the value, the form field must have a name attribute.

This form field does not support the form collection with the same name. This form field only supports the HTML INPUT tags currently.

Parameters:
name - The name of form field in the page.
Throws:
java.io.IOException
java.lang.Exception