|
Decision Center API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ilog.webui.dhtml.IlxWContainer ilog.webui.dhtml.IlxWComponent
public abstract class IlxWComponent
The base class for the web components.
A web component is intended to be deployed in a servlet or a JSP page.
It uses the method print(ilog.webui.dhtml.IlxWPort)
to print its graphical representation
to the designated port.
To be used (that is, displayed on a web browser), a component has to be
associated with a manager (see IlxWManager
).
Once a component has been stored in a manager, it can be printed
to the current response writer through a port (see IlxWPort
).
The following code shows how you can integrate a web component in a servlet:
import ilog.webui.dhtml.*; import ilog.webui.dhtml.components.*; public MyServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpservletResponse response) { doPost(request, response); } public void doPost(HttpServletRequest request, HttpservletResponse response) { // Gets the manager associated with the current session. IlxWManager manager = IlxWManager.getManager(request.getSession()); final String treeId = "MyServlet.myTree"; IlxWTree tree; synchronized (manager) { // Gets the component in the manager, or creates it if null. tree = (IlxWTree)manager.getComponentNamed(treeId); if (tree==null) { tree = new IlxWTree(); // register the tree in the manager. tree.setName(treeId); manager.add(tree); } } PrintWriter out = response.getWriter(); ServletContext ctx = getServletContext(); // Creates a port. IlxWPort port = new IlxWPort(ctx, request, response, out); // Prints the well-known HTML code. out.println("<html>"); out.println("<body>"); // Opens the port (this generates some JavaScript code) port.open(); out.println("<h1>This is the tree</h1>"); // Prints the tree. tree.print(port); // Closes the port (this generates some JavaScript code) port.close(); out.println("</body>"); out.println("</html>"); } }
Once rendered to an HTML page, a web component has two representations:
IlxWComponent
associated with the current session by its
manager.IlxWController
).
IlxWManager
,
IlxWPort
,
IlxWController
,
Serialized Form
Nested Class Summary | |
---|---|
class |
IlxWComponent.DynamicStyleMap
Dynamic style map. |
Field Summary |
---|
Fields inherited from class ilog.webui.dhtml.IlxWContainer |
---|
listenerList |
Constructor Summary | |
---|---|
IlxWComponent()
Constructs a new web component. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Adds a PropertyChangeListener for a specific property. |
protected void |
detach()
|
protected void |
doPrint(IlxWPort port)
|
void |
firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
Reports a bound property change. |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Support for reporting property changes. |
String |
getName()
Gets the name of this component. |
protected String |
getRealHtmlTagName(IlxWPort port)
|
IlxWComponent.DynamicStyleMap |
getStyle()
Gets the dynamic style map of this component. |
void |
invalidate()
Invalidates this component so that its print method
is called as soon as possible. |
boolean |
isInvalidated()
Tells whether the invalidate method has been called
since the last time this component has been printed in a port. |
void |
notifyDependencies(IlxWPort port)
|
void |
print(IlxWPort port)
Prints the component to the given port. |
protected abstract void |
printComponent(IlxWPort port)
Prints the HTML code that will display the graphical representation of this component. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Removes a PropertyChangeListener for a specific property. |
void |
setName(String name)
Sets the name of this component. |
void |
validate()
Validate this component. |
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 |
Constructor Detail |
---|
public IlxWComponent()
Method Detail |
---|
public String getName()
setName(java.lang.String)
public void setName(String name)
getName()
public void invalidate()
print
method
is called as soon as possible.
Note: With browsers that do not support incremental
redisplaying, like
Netscape 3 or Netscape 4, calling invalidate
has no effect because the whole page is redisplayed each time the server
is called (the target is set to _self
).
On the other hand, with browsers like MS IE5, only the components that
need to be redisplayed will be actually refreshed. This is the reason why
we need to specify that a component modified on the server has to be
redisplayed.
Component deployers will typically call this method at the end of
the implementation of a business method of the component.
Suppose you have a component with a setColor
method, you will
typically implement it as follows:
class MyComponent extends IlxWComponent { ... public void setColor(String color) { this.color = color; invalidate(); } }
public boolean isInvalidated()
invalidate
method has been called
since the last time this component has been printed in a port.
invalidate()
,
print(ilog.webui.dhtml.IlxWPort)
public void validate()
invalidate()
had been called before.
protected abstract void printComponent(IlxWPort port) throws IOException
print(ilog.webui.dhtml.IlxWPort)
method.
IOException
- if an error occurs while printing
the components.
IOException
port
- The port on which the component will be printed.print(ilog.webui.dhtml.IlxWPort)
public final void print(IlxWPort port) throws IOException
printComponent(ilog.webui.dhtml.IlxWPort)
method.
IOException
- if an error occurs while printing
the component.
IllegalStateException
- if the given port is not
open.
IOException
printComponent(ilog.webui.dhtml.IlxWPort)
protected String getRealHtmlTagName(IlxWPort port)
protected void doPrint(IlxWPort port) throws IOException
IOException
protected void detach()
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
oldValue
and
newValue
are not equal and the PropertyChangeEvent
listener list
isn't empty, then fire a PropertyChange
event to each listener.
propertyName
- The name of the property that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.PropertyChangeSupport
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
firePropertyChange(java.lang.String, java.lang.Object,
java.lang.Object)
public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
to the listener list.
The listener is registered for all properties.
A PropertyChangeEvent
will get fired in response to setting
a property.
listener
- The PropertyChangeListener
to be added.public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangeListener
for a specific property.
The listener will be invoked only when a call on firePropertyChange
names that specific property.
If the listener is null, no exception is thrown and no action is performed.
propertyName
- The name of the property to listen on.listener
- The PropertyChangeListener
to be added.public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from the listener list.
This removes a PropertyChangeListener
that was registered
for all properties.
listener
- The PropertyChangeListener
to be removed.public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangeListener
for a specific property.
If the listener is null, no exception is thrown and no action is performed.
propertyName
- The name of the property that was listened on.listener
- The PropertyChangeListener
to be removed.public IlxWComponent.DynamicStyleMap getStyle()
null
.public void notifyDependencies(IlxWPort port)
notifyDependencies
in interface ilog.webui.dhtml.IlxWDependencyProvider
notifyDependencies
in class IlxWContainer
|
Decision Center API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |