Class IlxWManager
- java.lang.Object
-
- ilog.webui.dhtml.IlxWContainer
-
- ilog.webui.dhtml.IlxWManager
-
- All Implemented Interfaces:
- ilog.webui.dhtml.IlxWConstants, ilog.webui.dhtml.IlxWCSSModelProvider, ilog.webui.dhtml.IlxWDependencyProvider, java.io.Serializable, java.util.EventListener, javax.servlet.http.HttpSessionBindingListener
public class IlxWManager extends IlxWContainer implements javax.servlet.http.HttpSessionBindingListener, ilog.webui.dhtml.IlxWConstants, java.io.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 methodprint
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 ofIlxWManager
associated with the current HTTP session. You can get this instance by callinggetManager(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 callinggetManager
.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$ } }
-
-
Field Summary
-
Fields inherited from class ilog.webui.dhtml.IlxWContainer
listenerList
-
-
Method Summary
Methods Modifier and Type Method and Description 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 theHttpSessionBindingListener
interface.void
valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
Defines theHttpSessionBindingListener
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
-
-
-
-
Method Detail
-
valueBound
public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
Defines theHttpSessionBindingListener
interface.- Specified by:
valueBound
in interfacejavax.servlet.http.HttpSessionBindingListener
-
valueUnbound
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
Defines theHttpSessionBindingListener
interface.- Specified by:
valueUnbound
in interfacejavax.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 theIlxWConfig.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 interfaceilog.webui.dhtml.IlxWDependencyProvider
- Overrides:
notifyDependencies
in classIlxWContainer
-
-