com.acesoft.aceoffix.wordreader
Class WordDocument

java.lang.Object
  extended by com.acesoft.aceoffix.wordreader.WordDocument

public class WordDocument
extends java.lang.Object

Representing a Word document, WordDocument class is used to read the data from the Word document submitted by AceoffixCtrl.

WordDocument is an important class. WordDocument object contains the data submitted by AceoffixCtrl. Typically, WordDocument class is used to read the data that users input into the Word document.

The com.acesoft.aceoffix.wordreader.WordDocument object can only be created in the page specified by AceoffixCtrl.SaveDataPage.

Version:
5.0
Author:
Acesoft Corporation

Constructor Summary
WordDocument(HttpServletRequest request, HttpServletResponse response)
          Initializes a new instance of WordDocument class.
 
Method Summary
 void close()
          Closes the WordDocument and returns a success message for saving.
 java.util.ArrayList<DataRegion> getDataRegions()
          Gets the DataRegion collection in the current Word document.
 java.lang.String getFormField(java.lang.String name)
          Gets the value of the Form field specified in the page with AceoffixCtrl.
 DataRegion openDataRegion(java.lang.String dataRegionName)
          Opens the specified DataRegion and returns the DataRegion object.
 void setCustomSaveResult(java.lang.String value)
          Sets the custom saving result defined by developer.
 void showPage(int width, int height)
          Pops up a custom dialog box in browser to show the saving result in HTML format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordDocument

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

The com.acesoft.aceoffix.wordreader.WordDocument object can only be created in the page specified by AceoffixCtrl.SaveDataPage.

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

setCustomSaveResult

public void setCustomSaveResult(java.lang.String value)
Sets the custom saving result defined by developer.

The following example shows how to use the CustomSaveResult property.

 WordDocument wd = new WordDocument(request, response);
 String strCompanyName = wd.openDataRegion("CompanyName").getValue();
 String strProductName = wd.openDataRegion("ProductName").getValue();
 
 //Save the data to the database.
 
 wd.setCustomSaveResult("My custom result");
 wd.close();
 

Then, custom saving result can be got from the CustomSaveResult property of AceoffixCtrl with JavaScript.

 <script language="javascript" type="text/javascript">
     function SaveDocument() {
         document.getElementById("AceoffixCtrl1").SaveDocument();
         alert(document.getElementById("AceoffixCtrl1").CustomSaveResult);//You can determine the next code logic according to the value of CustomSaveResult.
     }
 </script>
 


getDataRegions

public java.util.ArrayList<DataRegion> getDataRegions()
                                               throws java.io.IOException,
                                                      java.lang.Exception
Gets the DataRegion collection in the current Word document.

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

openDataRegion

public DataRegion openDataRegion(java.lang.String dataRegionName)
                          throws java.io.IOException,
                                 java.lang.Exception
Opens the specified DataRegion and returns the DataRegion object.

If the specified DataRegion exists, this method will return the DataRegion object.

The following code example shows how to call the OpenDataRegion method topic to get the value of the specified DataRegion.

 WordDocument wd = new WordDocument(request, response);
 String strCompanyName = wd.openDataRegion("CompanyName").getValue();
 String strProductName = wd.openDataRegion("ProductName").getValue();
 
 //Save the data to your database.
 
 wd.close(); //Required
 

Parameters:
dataRegionName - The name of DataRegion.
Returns:
Returns a DataRegion object.
Throws:
java.io.IOException
java.lang.Exception

close

public void close()
           throws java.io.IOException
Closes the WordDocument and returns a success message for saving.

If the code for saving data executes successfully, you should call this method to close the WordDocument object.

Throws:
java.io.IOException
See Also:
WordDocument.openDataRegion() to learn how to close the WordDocument object.

showPage

public void showPage(int width,
                     int height)
              throws java.io.IOException
Pops up a custom dialog box in browser to show the saving result in HTML format.

If you want to pop up a custom dialog box to show the saving result in HTML format, you should call this method. The message page shown in dialog box is the current SaveDataPage. By default, the SaveDataPage will display nothing. You can add friendly prompts in SaveDataPage.

The following example shows how to use the ShowPage method to display a custom saving error to user.

 WordDocument wd = new WordDocument(request, response);
 String strCompanyName = wd.openDataRegion("CompanyName").getValue();
 if(!strCompanyName.equals("")){
                //Save the data to database.
 }
 else{
                out.println("Failed to save. Company name cannot be empty."); // This is a simple error message, you can add friendly message to the current page.
                wd.showPage(380, 200); // If the company name is empty, AceoffixCtrl will pop up a dialog box to show the custom error page.
 }
 wd.close();
 

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

getFormField

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

When AceoffixCtrl is saving document, you can call this method to get the values of the Form fields specified in the page with AceoffixCtrl.

Note: To capture the value of the Form field, the Form field must contain a name attribute.

The Form field can be Input Box, Drop-down Box, Radio, Check Box, TextArea, Hidden Field etc..

Following example shows how to use GetFormField method to get the value of the Form field posted from the page with AceoffixCtrl.

 WordDocument wd = new WordDocument(request, response);
 String strSubject = wd.getFormField("EditSubject"); 
 //Save the obtained data to database
 String strCompanyName = wd.openDataRegion("CompanyName").getValue();
 wd.close();
 

Parameters:
name - The name of the Form field.
Returns:
Returns the value of the Form field.
Throws:
java.io.IOException
java.lang.Exception