Extending ViewsFlash with Java |
Because ViewsFlash is a Java application, it is naturally extensible. Start by compiling the source code provided in the Java source files in the viewsflash/src directory. To activate your class, use the indicated servlet parameter.
Compiling your class
1. You will need the Java 1.5 or later SDK from Sun. To compile the classes, use "javac" from the command line. You must have the appropriate library jar files in the -classpath argument. For example, if you have a file called MyClass.java, use:
/<JDK_HOME>/bin/javac -classpath .../ViewsFlash/WEB-INF/lib/viewsflash.jar myClass.java (replace ... with your application server's webapp directory, where you installed the ViewsFlash application, or simply provide the path to a copy of the viewsflash.jar file)
You also need to include servlet.jar in the classpath. In Unix, use: ...viewsflash.jar:.../servlet.jar. In Windows, use a semicolon instead of a colon. The servlet.jar file is usually in the application server's directories.
To see what libraries you need to include in the classpath, look at the first few lines of the source code we provide and examine the import statements. Below are the most common. Make sure that you use the complete path.
Always:
/ViewsFlash/WEB-INF/lib/viewsflash.jar
servlet.jar
For Oracle libraries:
oracle/ora81/jdbc/lib
oracle/ora81/jdbc/lib/classes12.zip
For ATG Dynamo:
ATG/Dynamo5.1/DAS/LIB/classes.jar
ATG/Dynamo5.1/DPS/LIB/classes.jar
ATG/Dynamo5.1/DSS/LIB/classes.jar
2. After successful compilation, you should see a file myClass.class in the same directory as your .java file. Move this file to the /ViewsFlash/WEB-INF/classes/com/cogix/vwf directory.
Use /servlet/viewsflash?Diagnose=1 to verify what your classpath is.
Activating your class
After compiling your class and moving it, you may need to add another servlet parameter, as specified in the table below. Add the parameter to viewsflash.properties, and restart the application server.
Sample source code for each extensible class is in ViewsFlash/viewsflash/src, under the sample class names listed below. See the class source code for detailed documentation on its use and how to modify it.
Base Class | Servlet parameter with sample Class | Purpose |
---|---|---|
PublishNotifier | publishnotifierextension= com.cogix.vwf.PublishNotifierExtension |
Methods are called when a poll is scheduled, opened, and closed. Used to convey this information to web site publishing systems. |
VoteNotifier | votenotifierextension= com.cogix.vwf.VoteNotifierExtension |
Methods called after a legitimate vote is recorded. Used to record the vote and/or its content in containing applications. |
RequestNotifier | requestnotifierextension= com.cogix.vwf.atgRequestNotifier |
Methods called as soon as request is received. Used to extract authentication information from the environment into a useful place, such as a Request Attribute. |
Validator | Activated with the Custom Action field
in the Question page rather than a servlet parameter. testAction BeforePageComposedGoTo WhenPageReceivedGoTo WeightedScore WriteInRanking WeightedRanking SimpleQuiz NumericScore IssueHttpCommand |
Methods called before vote or survey is tallied. Used to check fields for validity. Also used to calculate additional fields or modify the values of some fields based on others. |
DataBaseConnection | database=OraclePooledDataSource | All database drivers ( Oracle, DB2, etc ) extend this class. |
DatabaseExtension | databaseextension= com.cogix.vwf.OracleDatabaseExtension |
Provides an alternate way of storing responses to all surveys and polls in a single table in the database. |