|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object portal.core.api.Component
This is the super class for all classes that take part in the user interface. An instance of a component can be rendered and (optionally) manipulated by the user.
A component can optionally have a model to store it's internal state. This is not an obligation, some simpler components can choose to store their internal state within the component instance itself. Only components that which to be more generic and extensible by means of implementing the required Model interface, can delegate some of the logic to a model.
Every component has a parent. The only exceptions are top level components like a frame. See the documentation about internal desktop management. Not every component will have children. The Component classes only models the parent relationship. The Container class keeps track of the child relationship. Developers wishing the implement their own container classes will have to make sure the parent - child relationship is consistent.
The component instance can choose to render itself by overriding the
draw()
method, or it can delegate the rendering
to a layout manager. Layout managers can be set using the
setLayout()
Constructor Summary | |
Component()
Creates a new Component instance. |
|
Component(Model model)
Creates a new Component instance with the given
initial model. |
|
Component(java.lang.String name)
Creates a new Component instance with the given name. |
|
Component(java.lang.String name,
Model model)
Creates a new Component instance with the given name
and initial model. |
Method Summary | |
void |
afterRender()
This method is called after the actual rendering (either through a layout manager or by the draw method implementation) took place. |
void |
beforeRender()
This method is called before the actual rendering takes place. |
protected Model |
createDefaultModel()
This method is called by the constructor to create a default model for this component. |
protected void |
draw(HtmlGraphics htmlGraphics)
With this method the component can render itself using the passed HtmlGraphics object. |
LayoutManager |
getLayout()
Get the layout manager that will render this component, if set. |
Model |
getModel()
Returns the current model instance or null when there is no model for this component. |
Component |
getParent()
Returns the current parent or null if there is no parent. |
boolean |
isEnabled()
Determines whether this component is enabled. |
boolean |
isVisible()
Return if this component is visible or not. |
void |
render(RenderContext renderContext)
Describe render method here. |
void |
setEnabled(boolean enabled)
Enables or disables this component, depending on the value of the parameter enabled. |
void |
setLayout(LayoutManager layout)
Set the layout manager for this component. |
protected void |
setModel(Model model)
Set a new model for this component. |
void |
setParent(Component parent)
Sets a new parent. |
void |
setVisible(boolean visible)
Set the visibility for this component. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Component()
Creates a new Component
instance.
Calling this method is equivalent to calling
Component(null, null)
Component(String,Model)
.
public Component(java.lang.String name)
Creates a new Component
instance with the given name.
Calling this method is equivalent to calling
Component(name, null)
Component(String,Model)
.
name
- the name of this component or null for no namepublic Component(Model model)
Creates a new Component
instance with the given
initial model.
Calling this method is equivalent to calling
Component(null, model)
Component(String,Model)
.
model
- the initial value of the model of this instance
or null for no initial modelpublic Component(java.lang.String name, Model model)
Creates a new Component
instance with the given name
and initial model.
The name is only used in debug output. Both the name and model parameters can be null.
name
- the name of this new instance of Componentmodel
- the model of this componentMethod Detail |
public final void setParent(Component parent)
Sets a new parent. When the new parent is null, it will reset the parent and make this component top level in the UI tree.
parent
- a Component
valuepublic final Component getParent()
Returns the current parent or null if there is no parent.
public final boolean isVisible()
Return if this component is visible or not. See setVisible(booleaan)
for
more information.
isVisible
in interface Renderable
public final void setVisible(boolean visible)
Set the visibility for this component. Visible means this component will be rendered. When the component is not visible, it will be ignored in the rendering process.
setVisible
in interface Renderable
visible
- true if this component should be visible, false for not visiblepublic final boolean isEnabled()
Determines whether this component is enabled. An enabled component can respond to user input and generate events. Components are enabled initially by default.
See also setEnabled(boolean)
.
public final void setEnabled(boolean enabled)
Enables or disables this component, depending on the value of the parameter enabled. An enabled component can respond to user input. Components are enabled initially by default.
enabled
- when true, the component is enabled, false if the component should be disabledpublic void beforeRender() throws RenderException
This method is called before the actual rendering takes place. This is true
both when the draw() or a layout manager is used for rendering.
When this method throws an exception, the render process for the tree rooted at this component is stopped.
beforeRender
in interface Renderable
RenderException
public final void render(RenderContext renderContext) throws RenderException
render
method here.
render
in interface Renderable
renderContext
- the engine render context
RenderException
- when an error occurs during the renderingpublic void afterRender() throws RenderException
This method is called after the actual rendering (either through
a layout manager or by the draw method implementation) took place.
Even when the render()
threw an exception.
It is guaranteed that this method is called, even when the previous render
step threw an error. However when the beforeRender()
method threw an
exception, the afterRender()
method is not called.
afterRender
in interface Renderable
RenderException
protected void draw(HtmlGraphics htmlGraphics) throws RenderException
With this method the component can render itself using the passed HtmlGraphics object.
This method is not called when a layout manager is set since the existence of a layout
manager takes precedence above the draw()
method.
htmlGraphics
- the html graphics instance to use for drawing this component
RenderException
- when the rendering process could not proceed or encountered an errorpublic final LayoutManager getLayout()
Get the layout manager that will render this component, if set.
getLayout
in interface Renderable
public final void setLayout(LayoutManager layout)
Set the layout manager for this component. Passing null resets the layout manager.
setLayout
in interface Renderable
layout
- the new layout manager.public final Model getModel()
Returns the current model instance or null when there is no model for this component.
protected final void setModel(Model model)
Set a new model for this component. Passing null will reset the currently set model.
model
- the new model or null to reset the current modelprotected Model createDefaultModel()
This method is called by the constructor to create a default model for this component. If this component type does not use a model or does not have a suitable default model, this method can return null.
The default implementation should return null.
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |