Decision Center API

ilog.webui.dhtml
Class IlxWManager

java.lang.Object
  extended by ilog.webui.dhtml.IlxWContainer
      extended by ilog.webui.dhtml.IlxWManager
All Implemented Interfaces:
ilog.webui.dhtml.IlxWConstants, ilog.webui.dhtml.IlxWCSSModelProvider, ilog.webui.dhtml.IlxWDependencyProvider, Serializable, EventListener, javax.servlet.http.HttpSessionBindingListener

public class IlxWManager
extends IlxWContainer
implements javax.servlet.http.HttpSessionBindingListener, ilog.webui.dhtml.IlxWConstants, Serializable

IlxWManager represents a Web components container.

Overview

A web component is an instance of IlxWComponent. This class is designed to be deployed in a servlet or a JSP. It uses the method print to print its graphic representation to the designated port.

A port, that is, an an instance of IlxWPort, can be considered as a stream for displaying the HTML code representing the component in a web browser. This port encapsulates the response writer of a servlet.

All components are associated with a manager, that is, an instance of IlxWManager. A manager can be considered as a container of component objects. There is only one instance of IlxWManager associated with the current HTTP session. You can get this instance by calling getManager(javax.servlet.http.HttpSession) static method.

A session is an instance of javax.servlet.http.HttpSession. Each user is associated with a session. You can always retrieve the current session manager by calling getManager.

In order to print the HTML representation of Web components deployed in a servlet or a JSP page to a web browser, you must store your components in a manager so that you can retrieve them during the session.

Code example

The following code example shows how to save a decision table using a IlxWManager instance:

  public void doSave(HttpSession session, IlrBusinessRule element) throws Exception {
    IlrDecisionTable dt = (IlrDecisionTable)element;
    IlrSession rtsSession = dt.getSession();
    IlxWManager manager = IlxWManager.getManager(session);
    synchronized (manager) {
      String componentName = DTableEditor.EDITORNAME;
      DTableEditor dtEditor = (DTableEditor) manager.getComponentNamed(componentName);
      if (dtEditor == null) {
        throw new Exception(Messages.getString("DecisionTableEditor.DECISION_EDITOR_NAMED") + componentName + Messages.getString("DecisionTableEditor.NOT_FOUND_IN_CURRENT_SESSION")); //$NON-NLS-1$ //$NON-NLS-2$
      }
      IlrDTController dtcontroller = (IlrDTController) session.getAttribute("controller"); //$NON-NLS-1$
      if(dtcontroller!=null){
        String body = IlrSessionHelper.dtControllerToStorableString(rtsSession, dtcontroller);
        IlrDefinition definition = dt.getDefinition();
        definition.setRawValue(rtsSession.getBrmPackage().getDefinition_Body(), body);
        IlrCommitableObject  cobject = new IlrCommitableObject(dt);
        cobject.addModifiedElement(rtsSession.getBrmPackage().getRuleArtifact_Definition(), definition);
        rtsSession.commit(cobject);
      }
      session.removeAttribute("controller"); //$NON-NLS-1$
    }
  }
 

See Also:
Serialized Form

Field Summary
 
Fields inherited from class ilog.webui.dhtml.IlxWContainer
listenerList
 
Method Summary
 void cleanup()
          Called by the controller in order to cleanup the queue containing the components no longer referenced.
static IlxWManager getManager(javax.servlet.http.HttpSession session)
          Gets the manager associated with the session or creates that manager if this is the first time this method is called since the session was created.
 javax.servlet.http.HttpSession getSession()
          Gets the session in which this manager has been registered.
 void notifyDependencies(IlxWPort port)
           
static void releaseManager(javax.servlet.http.HttpSession session)
          Releases the manager from the session.
 void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
          Defines the HttpSessionBindingListener interface.
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
          Defines the HttpSessionBindingListener interface.
 
Methods inherited from class ilog.webui.dhtml.IlxWContainer
add, add, getAttribute, getAttributeNames, getComponent, getComponentCount, getComponentNamed, getComponents, getManager, getParent, getUserAgentRules, indexOf, isAncestorOf, remove, remove, removeAll, removeAttribute, setAttribute, setAuthorRules, setFinalizer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
Defines the HttpSessionBindingListener interface.

Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
Defines the HttpSessionBindingListener interface.

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener

releaseManager

public static void releaseManager(javax.servlet.http.HttpSession session)
Releases the manager from the session. This method must be called at the end of the session if the IlxWConfig.noSessionAttributes flag is set to true, otherwise, since in this mode the managers are stored in a singleton map, they will never be released.

If the IlxWConfig.noSessionAttributes flag is false (this is the default behavior), then you don't need to call this method, since it the manager corresponding to this session will be GCed when the session is GCed.


getManager

public static IlxWManager getManager(javax.servlet.http.HttpSession session)
Gets the manager associated with the session or creates that manager if this is the first time this method is called since the session was created.


getSession

public javax.servlet.http.HttpSession getSession()
Gets the session in which this manager has been registered.


cleanup

public void cleanup()
Called by the controller in order to cleanup the queue containing the components no longer referenced. Actually the manager holds an hashmap with component IDs as keys, and weak values on components as values. When a component is no longer referenced (or more precisely, the only reference is the weak reference), the component is moved in this queue.


notifyDependencies

public void notifyDependencies(IlxWPort port)
Specified by:
notifyDependencies in interface ilog.webui.dhtml.IlxWDependencyProvider
Overrides:
notifyDependencies in class IlxWContainer

Decision Center API

© Copyright IBM Corp. 1987, 2013