ilog.views.util.servlet
Class IlvPopupMenuServletSupport

java.lang.Object
  extended by ilog.views.util.servlet.IlvPopupMenuServletSupport
Direct Known Subclasses:
IlvManagerPopupServletSupport

public abstract class IlvPopupMenuServletSupport
extends Object

This abstract class defines a servlet support used handle dynamic popup menu request requests.

Subclasses must override all getters.

Since:
JViews 7.5

Field Summary
static String MENU_SESSION_KEY
          The session key for the current menu handled by this servlet support.
static String REQUEST_TYPE
          The request type of a dynamic popup menu request.
static String SERVLET_ACTION_NAME
          The action name of the builtin action listener that is responsible for translating the servlet event into a suitable event for a menu item listener.
 
Constructor Summary
IlvPopupMenuServletSupport()
          Creates a new IlvPopupMenuServletSupport instance.
 
Method Summary
protected  IlvMenu createMenu(javax.servlet.http.HttpServletRequest request, IlvMenuFactory factory, Object graphicObject, Object selectedObject, String menuModelId)
          Calls the menu factory to return the menu model.
protected  IlvMenu createMenu(IlvMenuFactory factory, Object graphicObject, Object selectedObject, String menuModelId)
          Deprecated. Beginning with ILOG JViews 8.0 use createMenu(HttpServletRequest, IlvMenuFactory, Object, Object, String) instead.
protected abstract  Object getGraphicComponent(javax.servlet.http.HttpServletRequest request)
          Returns the graphic component displayed by the linked servlet.
protected  IlvPopupMenuEncoder getMenuEncoder(javax.servlet.http.HttpServletRequest request)
          Returns the menu encoder responsible for encoding the root IlvMenu into a code comprehensible for the client.
protected  IlvMenuFactory getMenuFactory(javax.servlet.http.HttpServletRequest request)
          Returns the factory that will dynamically generate the menu depending on: The graphic component.
protected abstract  String getMenuModelId(javax.servlet.http.HttpServletRequest request)
          Returns the menu model ID from the request.
protected  IlvMenu getPopupMenuFromSession(javax.servlet.http.HttpServletRequest request)
          Retrieve menu model stored in the session with the MENU_SESSION_KEY key.
protected abstract  Object getSelectedObject(javax.servlet.http.HttpServletRequest request, int x, int y)
          Returns the object selected by the user when he triggered the popup menu.
 javax.servlet.ServletContext getServletContext()
          Returns the servlet context.
 boolean handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Responds to HTTP requests.
abstract  void installListeners()
          Installs the server action listeners to properly handle popup actions.
protected  void prepareComponent(javax.servlet.http.HttpServletRequest request, Object graphicComponent)
          Configures the graphic component to be in a correct state before the selected object is picked.
abstract  void removeListeners()
          Removes the server action previously installed with installListeners.
protected  void savePopupMenuModelInSession(javax.servlet.http.HttpServletRequest request, IlvMenu root)
          Saves the generated menu in session using the MENU_SESSION_KEY key.
 void setMenuFactory(IlvMenuFactory menuFactory)
          Sets the menu factory that will generate the popup menu.
 void setServletContext(javax.servlet.ServletContext context)
          Sets the servlet context used by this support.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVLET_ACTION_NAME

public static final String SERVLET_ACTION_NAME
The action name of the builtin action listener that is responsible for translating the servlet event into a suitable event for a menu item listener.

See Also:
Constant Field Values

REQUEST_TYPE

public static final String REQUEST_TYPE
The request type of a dynamic popup menu request.

See Also:
Constant Field Values

MENU_SESSION_KEY

public static final String MENU_SESSION_KEY
The session key for the current menu handled by this servlet support.

See Also:
Constant Field Values
Constructor Detail

IlvPopupMenuServletSupport

public IlvPopupMenuServletSupport()
Creates a new IlvPopupMenuServletSupport instance.

Method Detail

installListeners

public abstract void installListeners()
Installs the server action listeners to properly handle popup actions.


removeListeners

public abstract void removeListeners()
Removes the server action previously installed with installListeners.


handleRequest

public boolean handleRequest(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws IOException,
                             javax.servlet.ServletException
Responds to HTTP requests. It returns false if the request is not a request recognized by this servlet. If the request is correct generate in the output stream the Javascript Code used by the client to display the popup menu.

Parameters:
request - the current Http request.
response - the Http response.
Returns:
true if the request was processed, false if an error occurred.
Throws:
IOException
javax.servlet.ServletException

prepareComponent

protected void prepareComponent(javax.servlet.http.HttpServletRequest request,
                                Object graphicComponent)
                         throws javax.servlet.ServletException
Configures the graphic component to be in a correct state before the selected object is picked. This implementation does nothing. Subclasses can override this method to do specific configuration.

Parameters:
request - The http request.
graphicComponent - The graphic component.
Throws:
javax.servlet.ServletException - If an error occurs during configuration.
Since:
JViews 8.0

createMenu

protected IlvMenu createMenu(javax.servlet.http.HttpServletRequest request,
                             IlvMenuFactory factory,
                             Object graphicObject,
                             Object selectedObject,
                             String menuModelId)
                      throws javax.servlet.ServletException
Calls the menu factory to return the menu model.

Parameters:
request - The http servlet request.
factory - The menu factory
graphicObject - The graphic component
selectedObject - The selected object
menuModelId - The menu model ID.
Returns:
The root menu of the model.
Throws:
javax.servlet.ServletException
Since:
JViews 8.0

createMenu

protected IlvMenu createMenu(IlvMenuFactory factory,
                             Object graphicObject,
                             Object selectedObject,
                             String menuModelId)
                      throws javax.servlet.ServletException
Deprecated. Beginning with ILOG JViews 8.0 use createMenu(HttpServletRequest, IlvMenuFactory, Object, Object, String) instead.

Calls the menu factory to return the menu model.

Parameters:
factory - The menu factory
graphicObject - The graphic component
selectedObject - The selected object
menuModelId - The menu model ID.
Returns:
The root menu of the model.
Throws:
javax.servlet.ServletException

savePopupMenuModelInSession

protected void savePopupMenuModelInSession(javax.servlet.http.HttpServletRequest request,
                                           IlvMenu root)
Saves the generated menu in session using the MENU_SESSION_KEY key.

Parameters:
request - The Http request.
root - The root menu of the menu model.

getPopupMenuFromSession

protected IlvMenu getPopupMenuFromSession(javax.servlet.http.HttpServletRequest request)
Retrieve menu model stored in the session with the MENU_SESSION_KEY key.

Parameters:
request - The Http request.
Returns:
The menu stored in session.

getGraphicComponent

protected abstract Object getGraphicComponent(javax.servlet.http.HttpServletRequest request)
                                       throws javax.servlet.ServletException
Returns the graphic component displayed by the linked servlet.
Subclasses must precise the type of this object.

Parameters:
request - The Http request.
Returns:
The graphic component.
Throws:
javax.servlet.ServletException

getSelectedObject

protected abstract Object getSelectedObject(javax.servlet.http.HttpServletRequest request,
                                            int x,
                                            int y)
                                     throws javax.servlet.ServletException
Returns the object selected by the user when he triggered the popup menu.
This object is passed to the menu factory.
Subclasses must precise the type of this object.

Parameters:
request - The Http request
x - x coordinate in image view coordinate system.
y - y coordinate in image view coordinate system.
Returns:
The selected object.
Throws:
javax.servlet.ServletException
See Also:
getGraphicComponent(HttpServletRequest)

getMenuFactory

protected IlvMenuFactory getMenuFactory(javax.servlet.http.HttpServletRequest request)
                                 throws javax.servlet.ServletException
Returns the factory that will dynamically generate the menu depending on: sent by the client.
By default this method returns the menu factory set with the setmenuFactory method.

Parameters:
request - The Http request.
Returns:
The menu factory.
Throws:
javax.servlet.ServletException

setMenuFactory

public void setMenuFactory(IlvMenuFactory menuFactory)
Sets the menu factory that will generate the popup menu.

Parameters:
menuFactory - The menu factory.

getMenuModelId

protected abstract String getMenuModelId(javax.servlet.http.HttpServletRequest request)
                                  throws javax.servlet.ServletException
Returns the menu model ID from the request.

Parameters:
request - The Http request.
Returns:
The menu model ID.
Throws:
javax.servlet.ServletException

getMenuEncoder

protected IlvPopupMenuEncoder getMenuEncoder(javax.servlet.http.HttpServletRequest request)
                                      throws javax.servlet.ServletException
Returns the menu encoder responsible for encoding the root IlvMenu into a code comprehensible for the client.
This method returns an IlvPopupMenuEncoder instance.

Parameters:
request - The Http request.
Returns:
The menu encoder.
Throws:
javax.servlet.ServletException

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns the servlet context.

Returns:
The servlet context.

setServletContext

public void setServletContext(javax.servlet.ServletContext context)
Sets the servlet context used by this support.
Should be set in the init() of the servlet.

Parameters:
context - The servlet context.


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