ilog.views.sdm.servlet
Class IlvSDMServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by ilog.views.sdm.servlet.IlvSDMServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
IlvDiagrammerServlet

public class IlvSDMServlet
extends javax.servlet.http.HttpServlet

This class implements a servlet that wraps an SDM view. It is a concrete subclass of HttpServlet. You can use this class directly to view an XML data file styled with a style sheet using SDM facilities.

If you want to provide additional behavior (in particular a different allocation of views to sessions), you must subclass IlvSDMServletSupport and override createServletSupport() to create an instance of your subclass.

This basic implementation works in two modes:

  1. In monosession mode, only one SDM engine is created for all the sessions connected to this servlet. This mode is appropriate if the SDM engine always displays the same static data.
  2. In multisession mode, a new SDM engine is created for each new session connected to this servlet. You can use this mode if the user is allowed to load a new data file or a different style sheet, or if editing capabilities are provided.

The servlet accepts the following configuration parameters:

The servlet also accepts the parameters xml and css in the request URL to load a new XML file or a new CSS file.

Since:
JViews 4.0
See Also:
Serialized Form

Constructor Summary
IlvSDMServlet()
          Creates an SDM servlet.
 
Method Summary
 void addServerActionListener(ServerActionListener listener)
          Adds the specified listener to receive events when an action is requested from the client.
protected  IlvSDMServletSupport createServletSupport()
          Deprecated. Beginning with ILOG JViews 7.5 use createServletSupport(ServletContext) instead.
protected  IlvSDMServletSupport createServletSupport(javax.servlet.ServletContext context)
          Creates the supporting object to which this servlet delegates most of its methods.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Responds to the servlet request.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Responds to the servlet request.
 String getDataURL()
          Returns the URL of the directory where the data files (such as icon files, style sheets, and XML files) are located.
 String getDefaultStyleSheet()
          Returns the default style sheet file.
 String getDefaultXmlFile()
          Returns the default XML data file.
 float getJPEGQuality()
          Returns the quality of the produced JPEG file.
 IlvSDMServletSupport getServletSupport()
          Returns the supporting object to which this servlet delegates most of its methods.
 void init(javax.servlet.ServletConfig config)
          Initializes the servlet.
 boolean isMultiSession()
          Returns true if the servlet is in multisession mode.
 boolean isVerbose()
          Returns true if the servlet is in verbose mode.
protected  void prepareSession(javax.servlet.http.HttpServletRequest request)
          Prepares a session for the client.
 void removeServerActionListener(ServerActionListener listener)
          Removes the specified listener so that it no longer receives events generated from the client.
 void setDataURL(String url)
          Sets the URL of the directory where the data files (such as icon files, style sheets, and XML files) are located.
 void setDefaultStyleSheet(String styleSheet)
          Sets the default style sheet file.
 void setDefaultXmlFile(String xmlFile)
          Sets the default XML data file.
 void setJPEGQuality(float quality)
          Sets the quality of the produced JPEG file.
 void setMultiSession(boolean multiSession)
          Sets whether the servlet is in multisession mode.
 void setStyleSheet(javax.servlet.http.HttpServletRequest request, String styleSheet)
          Sets the style sheet of the SDM engine.
 void setVerbose(boolean value)
          Turns the verbose mode on and off.
 void setXmlFile(javax.servlet.http.HttpServletRequest request, String xmlFile)
          Loads an XML data file in the SDM engine.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvSDMServlet

public IlvSDMServlet()
Creates an SDM servlet.

Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the servlet. This method simply reads the "multiSession", "styleSheet", "xmlFile", and "dataURL" parameters.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - The object holding the configuration information for the servlet.
Throws:
javax.servlet.ServletException

createServletSupport

protected IlvSDMServletSupport createServletSupport()
Deprecated. Beginning with ILOG JViews 7.5 use createServletSupport(ServletContext) instead.

Creates the supporting object to which this servlet delegates most of its methods.

This default implementation returns a new instance of IlvSDMServletSupport.

To add functionalities to the servlet, you can override this method and return an instance of your own subclass of IlvSDMServletSupport.


createServletSupport

protected IlvSDMServletSupport createServletSupport(javax.servlet.ServletContext context)
Creates the supporting object to which this servlet delegates most of its methods.

This default implementation returns a new instance of IlvSDMServletSupport.

To add functionalities to the servlet, you can override this method and return an instance of your own subclass of IlvSDMServletSupport.

Parameters:
context - The servlet context.
Since:
JViews 7.5

getServletSupport

public IlvSDMServletSupport getServletSupport()
Returns the supporting object to which this servlet delegates most of its methods.


setMultiSession

public void setMultiSession(boolean multiSession)
Sets whether the servlet is in multisession mode. In multisession mode (that is, if the multiSession parameter is true), a new SDM view will be created for each different session connected to this servlet. Otherwise, only one SDM view is created, and it is shared by all sessions.

Parameters:
multiSession - true for multisession mode, and false for monosession mode.

isMultiSession

public boolean isMultiSession()
Returns true if the servlet is in multisession mode.

See Also:
setMultiSession(boolean)

setDefaultStyleSheet

public void setDefaultStyleSheet(String styleSheet)
Sets the default style sheet file. This method does not actually change the style sheet of any SDM engine. It is meant to be called from the init(javax.servlet.ServletConfig) method of the servlet to initialize the default style sheet used to initialize the SDM engine when a new client connects to the servlet.

Parameters:
styleSheet - The new default style sheet file.

getDefaultStyleSheet

public String getDefaultStyleSheet()
Returns the default style sheet file.


setDefaultXmlFile

public void setDefaultXmlFile(String xmlFile)
Sets the default XML data file. This method does not actually change the XML data file displayed by any SDM engine. It is meant to be called from the init(javax.servlet.ServletConfig) method of the servlet to initialize the default XML file used to initialize the SDM engine when a new client connects to the servlet.

Parameters:
xmlFile - The new default XML data file.

getDefaultXmlFile

public String getDefaultXmlFile()
Returns the default XML data file.


setDataURL

public void setDataURL(String url)
Sets the URL of the directory where the data files (such as icon files, style sheets, and XML files) are located.

Parameters:
url - The URL.

getDataURL

public String getDataURL()
Returns the URL of the directory where the data files (such as icon files, style sheets, and XML files) are located.


setStyleSheet

public void setStyleSheet(javax.servlet.http.HttpServletRequest request,
                          String styleSheet)
Sets the style sheet of the SDM engine. This method actually changes the style sheet file of the SDM engine associated with the request.

Parameters:
request - The request being processed.
styleSheet - The style sheet file or URL.

setXmlFile

public void setXmlFile(javax.servlet.http.HttpServletRequest request,
                       String xmlFile)
Loads an XML data file in the SDM engine. This method actually changes the XML data file of the SDM engine associated with the request.

Parameters:
request - The request being processed.
xmlFile - The name or URL of the XML file containing the data.

addServerActionListener

public final void addServerActionListener(ServerActionListener listener)
Adds the specified listener to receive events when an action is requested from the client. An action is generated from the client side when the ilog.views.thinclient.IlvView.performAction method is called. This method queries the server for a new image, but additional parameters are sent in the image request so that an action such as adding, removing, or selecting objects can be performed before the image is generated. An action is defined by a name and a list of parameters. To implement the action on the client side, you will implement the ServerActionListener interface and check the action name and parameters in the event.

Parameters:
listener - The listener.
See Also:
removeServerActionListener(ilog.views.servlet.ServerActionListener)

removeServerActionListener

public final void removeServerActionListener(ServerActionListener listener)
Removes the specified listener so that it no longer receives events generated from the client.

Parameters:
listener - The listener.
See Also:
addServerActionListener(ilog.views.servlet.ServerActionListener)

setVerbose

public final void setVerbose(boolean value)
Turns the verbose mode on and off.

Parameters:
value - true to turn the verbose mode to on.
See Also:
isVerbose()

isVerbose

public final boolean isVerbose()
Returns true if the servlet is in verbose mode.

See Also:
setVerbose(boolean)

setJPEGQuality

public final void setJPEGQuality(float quality)
Sets the quality of the produced JPEG file.

Parameters:
quality - Can be in the [0,1] range: 0 for bad quality and high compression, and 1 for high quality and poor compression. The default value is 0.75.
See Also:
getJPEGQuality()

getJPEGQuality

public final float getJPEGQuality()
Returns the quality of the produced JPEG file. The default value is 0.75.

See Also:
setJPEGQuality(float)

prepareSession

protected void prepareSession(javax.servlet.http.HttpServletRequest request)
Prepares a session for the client. This method is called at every request before any other method to allow the user to prepare a session for its servlet. The actual implementation is empty, but if your servlet needs to create a session you can override the method to do it.

Parameters:
request - The current request.

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws IOException,
                  javax.servlet.ServletException
Responds to the servlet request. This method calls the prepareSession(javax.servlet.http.HttpServletRequest) method, and then the IlvSDMServletSupport.handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method of the support object returned by getServletSupport(). You do not usually need to override this method. To add a new type of request, you must subclass IlvSDMServletSupport and override the method IlvSDMServletSupport.handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The current HTTP request.
response - The HTTP response.
Throws:
IOException
javax.servlet.ServletException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws IOException,
                   javax.servlet.ServletException
Responds to the servlet request. The default implementation simply calls doGet.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - The current HTTP request.
response - The HTTP response.
Throws:
IOException
javax.servlet.ServletException
See Also:
doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.