public abstract class IlxWComponent extends IlxWContainer implements ilog.webui.dhtml.IlxWConstants, ilog.webui.dhtml.IlxWJSObject
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| Modifier and Type | Class and Description |
|---|---|
class |
IlxWComponent.DynamicStyleMap
Dynamic style map.
|
listenerList| Constructor and Description |
|---|
IlxWComponent()
Constructs a new web component.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a
PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a
PropertyChangeListener for a specific property. |
protected void |
detach() |
protected void |
doPrint(IlxWPort port) |
void |
firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
Reports a bound property change.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Support for reporting property changes.
|
java.lang.String |
getName()
Gets the name of this component.
|
protected java.lang.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(java.beans.PropertyChangeListener listener)
Removes a
PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a
PropertyChangeListener for a specific property. |
void |
setName(java.lang.String name)
Sets the name of this component.
|
void |
validate()
Validate this component.
|
add, add, getAttribute, getAttributeNames, getComponent, getComponentCount, getComponentNamed, getComponents, getManager, getParent, getUserAgentRules, indexOf, isAncestorOf, remove, remove, removeAll, removeAttribute, setAttribute, setAuthorRules, setFinalizerpublic java.lang.String getName()
setName(java.lang.String)public void setName(java.lang.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 java.io.IOException
print(ilog.webui.dhtml.IlxWPort) method.IOException - if an error occurs while printing
the components.java.io.IOExceptionport - The port on which the component will be printed.print(ilog.webui.dhtml.IlxWPort)public final void print(IlxWPort port) throws java.io.IOException
printComponent(ilog.webui.dhtml.IlxWPort) method.IOException - if an error occurs while printing
the component.IllegalStateException - if the given port is not
open.java.io.IOExceptionprintComponent(ilog.webui.dhtml.IlxWPort)protected java.lang.String getRealHtmlTagName(IlxWPort port)
protected void doPrint(IlxWPort port) throws java.io.IOException
java.io.IOExceptionprotected void detach()
protected void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.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.PropertyChangeSupportpublic void firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
public void addPropertyChangeListener(java.beans.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(java.lang.String propertyName,
java.beans.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(java.beans.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(java.lang.String propertyName,
java.beans.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.IlxWDependencyProvidernotifyDependencies in class IlxWContainer© Copyright IBM Corp. 1987, 2017