com.acesoft.aceoffix.wordreader
Class WordDocumentPHP

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

public class WordDocumentPHP
extends java.lang.Object

Representing a Word document, WordDocumentPHP class is used to read the data from the Word document submitted by AceoffixCtrl with PHP code.

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

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

Version:
5.0
Author:
Acesoft Corporation

Constructor Summary
WordDocumentPHP()
          Initializes a new instance of WordDocumentPHP class.
 
Method Summary
 java.lang.String 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.
 void load(java.lang.String Input)
          Load the request stream with PHP code.
 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

WordDocumentPHP

public WordDocumentPHP()
Initializes a new instance of WordDocumentPHP class.

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

Method Detail

load

public void load(java.lang.String Input)
          throws java.lang.Exception,
                 java.io.IOException
Load the request stream with PHP code.

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

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.

 $ip = GetHostByName($_SERVER['SERVER_NAME']);
 require_once("http://".$ip.":8080/JavaBridge/java/Java.inc");
 $wd = new Java("com.acesoft.aceoffix.wordreader.WordDocumentPHP");
 $wd->load(file_get_contents("php://input"));
 $strCompanyName = wd->openDataRegion("CompanyName")->getValue();
 $strProductName = wd->openDataRegion("ProductName")->getValue();
 //Save the data to database.
 
 $wd->setCustomSaveResult("My custom result");
 echo $wd->close(); //Required
 

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.

 $ip = GetHostByName($_SERVER['SERVER_NAME']);
 require_once("http://".$ip.":8080/JavaBridge/java/Java.inc");
 $wd = new Java("com.acesoft.aceoffix.wordreader.WordDocumentPHP");
 $wd->load(file_get_contents("php://input"));
 $strCompanyName = wd->openDataRegion("CompanyName")->getValue();
 $strProductName = wd->openDataRegion("ProductName")->getValue();
 //Save the data to database.
 
 echo $wd->close(); //Required
 

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

close

public java.lang.String 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:
WordDocumentPHP.openDataRegion() to learn how to close the WordDocumentPHP 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.

 $ip = GetHostByName($_SERVER['SERVER_NAME']);
 require_once("http://".$ip.":8080/JavaBridge/java/Java.inc");
 $wd = new Java("com.acesoft.aceoffix.wordreader.WordDocumentPHP");
 $wd->load(file_get_contents("php://input"));
 $name = $wd->openDataRegion("CompanyName")->getValue();
 if(strcasecmp("", $name) != 0){
      //Save the data to database.
 }
 else{
      echo "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.
 }
 echo $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.

 $ip = GetHostByName($_SERVER['SERVER_NAME']);
 require_once("http://".$ip.":8080/JavaBridge/java/Java.inc");
 $wd = new Java("com.acesoft.aceoffix.wordreader.WordDocumentPHP");
 $wd->load(file_get_contents("php://input"));
 $strSubject = $wd.getFormField("EditSubject"); 
 // After you get the input text, you can save it to the database.
 
 echo $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