| | | | Browse by category |
Question
How to implement a gantt chart thin-client sample with custom server action ?
Answer
The attached example demonstrates the bare essentials of thin-client (DHTML) support for Gantt charts.
To run the application:
1. Extract the attached .zip file to JViews_Home\tools\tomcat\webapps,
2. Make sure the jviews.jar and gantt.jar files are in the \WEB-INF\lib folder,
3. Launch Tomcat, and
4. Open http://localhost:8080/gantt/index.html
in Internet Explorer or a similar browser.
The server side
The entire source code is kept in one file, GanttChartServlet.java
(see the folder ...\WEB-INF\classes), so that the entire server-side implementation can be seen in one go.
The GanttChartServlet
class implements the IlvGanttServlet
class and defines the obligatory createServletSupport
method. This method creates an instance of the IlvGanttServletSupport
class. The getChart
method of this class creates a Gantt chart based on a simple data model, defined in the SimpleProjectDataModel
class.
The data model creates two activites with a constraint in between.
In order to demonstrate how the chart can react to a signal from the client side, an IlvLabel
object has been added to the Gantt sheet. When a client views the application and clicks on the activity or constraint graphics in the Gantt sheet, the server side changes the label to reflect the class type of the graphic clicked on. The name of the action is MY_ACTION
, and the interaction is coded by adding a server action to the servlet support class with the addServerAction
method.
The client side
The index.html
file uses JavaScript to create a simple IlvGanttView
object. The IlvInteractor
instance 'MyInteractor', enabling interaction with the server side, is then created. Each time the mouse is clicked, a MY_ACTION
signal is sent to the server.
Finally, a simple zoom in the interactor with a tooltip is created inside an IlvToolBar
object.
All the .js files and images necessary to implement JavaScript support for the Gantt servlet are contained in the ..\script folder.