Java Doc for Component.java in  » Ajax » zk » org » zkoss » zk » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » zk » org.zkoss.zk.ui 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.zkoss.zk.ui.Component

All known Subclasses:   org.zkoss.zk.ui.AbstractComponent,
Component
public interface Component extends java.io.Serializable,Cloneable(Code)
A UI component.

There are two kind of lifecycles: one is page creations and the other is asynchronous updates.

The Page Creation

The page creation occurs when a page is about to render at the first time. The detailed phases can be found in the devloper's guide.

The Asynchronous Update

The asynchronous update occurs when users does something on the browser, such as changing the content of input, clicking buttons and so on. Such behaviors are packed as requests, queue in the browser, and then send to the server at the proper time. The detailed phases can be found in the developer's guide.

No Synchronization Required

To simplify the development of components and applications, invocations of methods of components and event listener are all serialized. In other words, application and component developers need not worry synchronization and other thread issues (unless you are developing background thread to handle long operations).

It also implies a limitation that you cannot access components belonging to other desktops when processing an event.
author:
   tomyeh



Field Summary
final public static  intAPPLICATION_SCOPE
     Used with Component.getAttribute and relevants to denote custom attributes shared by the whole application.
final public static  intCOMPONENT_SCOPE
     Used with Component.getAttribute and relevants to denote custom attributes private to a component is searched.
final public static  intDESKTOP_SCOPE
     Used with Component.getAttribute and relevants to denote custom attributes shared by the same desktop.
final public static  intPAGE_SCOPE
     Used with Component.getAttribute and relevants to denote custom attributes shared by the same page.
final public static  intREQUEST_SCOPE
     Used with Component.getAttribute and relevants to denote custom attributes shared by the same request.
final public static  intSESSION_SCOPE
     Used with Component.getAttribute and relevants to denote custom attributes shared by the same session.
final public static  intSPACE_SCOPE
     Used with Component.getAttribute and relevants to denote custom attributes shared by the same ID space.


Method Summary
public  booleanaddEventListener(String evtnm, EventListener listener)
     Adds an event listener to specified event for this component.
public  booleanaddForward(String originalEvent, Component target, String targetEvent)
     Adds a forward condition to forward the event received by this component to another component.

Default: no forward condition at all.

Once the condition is added, a event called targetEvent is posted to the target compoennt, when this component receives the orginalEvent event.
Parameters:
  originalEvent - the original event that was receivedby this component.

public  booleanaddForward(String originalEvent, String targetPath, String targetEvent)
     Adds a forward condition to forward the event received by this component to another component, specified with a path.

Note: the target component is retrieved from the path, each time the event is received.

public  booleanappendChild(Component child)
     Appends a child.
public  voidapplyProperties()
     Initializes the properties (aka.
public  Objectclone()
     Clones the component. All of its children is cloned. Notice that the cloned component doesn't belong to any page, nor desktop.
public  booleancontainsVariable(String name, boolean local)
     Returns whether the specified variable is defined.
public  voiddetach()
     Detaches this component such that it won't belong to any page.
public  ObjectgetAttribute(String name, int scope)
     Returns the value of the specified custom attribute in the specified scope, or null if not defined.
public  ObjectgetAttribute(String name)
     Returns the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE .
public  MapgetAttributes(int scope)
     Returns all custom attributes of the specified scope.
public  MapgetAttributes()
     Returns all custom attributes associated with this component, i.e., Component.COMPONENT_SCOPE .
public  ListgetChildren()
     Returns a live list of children.
public  ComponentDefinitiongetDefinition()
     Returns the component definition of this component (never null).
public  DesktopgetDesktop()
     Returns the desktop of this component, or null if this component doesn't belong to any desktop.

When a component is created in an event listener, it is assigned to the current desktop automatically. If a component is created not in any event listener, it doesn't belong to any desktop and this method returns null. Once a component is attached to a desktop (thru Component.setPage or Component.setParent ), it belongs to the desktop.

Notice: there is no way to detach a component from a desktop, once it is attached as described above. In other words, you cannot move a component (or page) from one desktop to another.

In summary, there are only two ways to handle components.

  1. Handle them all in event listeners and don't access any components from other desktops.
public  ComponentgetFellow(String id)
     Returns a component of the specified ID in the same ID space.
public  ComponentgetFellowIfAny(String id)
     Returns a component of the specified ID in the same ID space, or null if not found.
public  ComponentgetFirstChild()
     Returns the first child component, or null if no child at all.
public  StringgetId()
     Returns the ID.
public  ComponentgetLastChild()
     Returns the last child component, or null if no child at all.
public  IteratorgetListenerIterator(String evtnm)
     Returns an iterator for iterating listener for the specified event.
public  StringgetMold()
     Returns the mold for this component.
public  NamespacegetNamespace()
     Returns the namespace to store variables and functions belonging to the ID space of this component.

Exactly one namespace is allocated for each ID space. For example, if the space owner of this component is the page, then the returned namespace is the same as Page.getNamespace . Otherwise, it is the same as the namspace returned by the component owning this ID space.

Namspace is another part of an ID space.

public  ComponentgetNextSibling()
     Returns the next sibling, or null if it is the last child.
public  PagegetPage()
     Returns the page that this component belongs to, or null if it doesn't belong to any page.

When a component is created (aka., constructed), it doesn't belong to any page.

public  ComponentgetParent()
     Returns the parent component, or null if this is the root component.
public  ComponentgetPreviousSibling()
     Returns the previous sibling, or null if it is the first child.
public  ComponentgetRoot()
     Returns the root of this component.
public  IdSpacegetSpaceOwner()
     Returns the owner of the ID space that this component belongs to. The returned value could be a component, a page or null. If this component itself implements IdSpace , this method returns itself. If it has an ancestor that implements IdSpace , the ancestor is returned. Otherwise, the page it belongs to is returned

Each ID space defines an independent set of IDs.

public  StringgetUuid()
     Returns UUID (universal unique ID) which is unquie in the whole session.
public  ObjectgetVariable(String name, boolean local)
     Returns the value of a variable defined in the namespace, or null if not defined or the value is null.
public  booleaninsertBefore(Component newChild, Component refChild)
     Inserts a child before the reference child.

You could use Component.setParent or Component.appendChild instead of this method, unless you want to control where to put the child.

Note: Component.setParent always calls back Component.insertBefore and/or Component.removeChild , while Component.insertBefore and Component.removeChild always calls back Component.setParent , if the parent is changed.

public  voidinvalidate()
     Invalidates this component by setting the dirty flag such that it will be redraw the whole content later.
public  booleanisChildable()
     Returns whether this component allows to have any child.
public  booleanisListenerAvailable(String evtnm, boolean asap)
     Returns whether the event listener is available.
public  booleanisVisible()
     Returns whether this component is visible.
public  voidonChildAdded(Component child)
     Called when a child is added. If a component want to optimize the update, it might do something different.
public  voidonChildRemoved(Component child)
     Called when a child is removed. If a component want to optimize the update, it might do something different.
public  voidonDrawNewChild(Component child, StringBuffer out)
     Called when a new-created child is about to render.
public  voidonPageAttached(Page newpage, Page oldpage)
     Called when this component is attached to a page.
public  voidonPageDetached(Page page)
     Called when this component is detached from a page.
public  voidredraw(Writer out)
     AuRequest this component to render (aka., redraw) itself and its children.
public  ObjectremoveAttribute(String name, int scope)
     Removes the specified custom attribute in the specified scope.
public  ObjectremoveAttribute(String name)
     Removes the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE .
public  booleanremoveChild(Component child)
     Removes a child.
public  booleanremoveEventListener(String evtnm, EventListener listener)
     Removes an event listener.
public  booleanremoveForward(String originalEvent, Component target, String targetEvent)
     Removes a forward condition that was added by Component.addForward(String,Component,String) . If no such forward condition exists, nothing happens but return false.
Parameters:
  originalEvent - the oringal event that was receivedby this component.It must be the same as the one passed to Component.addForward(String,Component,String).
Parameters:
  target - the target component to receive the event.It must be the same as the one passed to Component.addForward(String,Component,String).
Parameters:
  targetEvent - the target event that the target component will receive.It must be the same as the one passed to Component.addForward(String,Component,String).
public  booleanremoveForward(String originalEvent, String targetPath, String targetEvent)
     Removes a forward condition that was added by Component.addForward(String,String,String) . If no such forward condition exists, nothing happens but return false.
Parameters:
  originalEvent - the oringal event that was receivedby this component.It must be the same as the one passed to Component.addForward(String,Component,String).
Parameters:
  targetPath - the target component's path related to this component.If ".", this component is assumed.If null, the space owner is assumed.If null and the space owner is the page, the root component is assumed.
Parameters:
  targetEvent - the target event that the target component will receive.It must be the same as the one passed to Component.addForward(String,Component,String).
public  voidresponse(String key, AuResponse response)
     Causes a response (aka., a command) to be sent to the client.

If AuResponse.getDepends is not null, the response depends on the existence of the returned componet. In other words, the response is removed if the component is removed. If it is null, the response is component-independent and it is always sent to the client.

Unlike Component.smartUpdate , responses are sent to client if it is component independent or it is not removed. In other words, it is sent even if Component.invalidate() was called. Typical examples include setting the focus, selecting the text and so on.

It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.
Parameters:
  key - could be anything.The second invocation of this methodin the same execution with the same key will override the previous one.However, if key is null, it won't override any other.

public  ObjectsetAttribute(String name, Object value, int scope)
     Sets the value of the specified custom attribute in the specified scope.

Note: The attribute is removed (by Component.removeAttribute if value is null, while Component.setVariable considers null as a legal value.

If scope is Component.COMPONENT_SCOPE , it means custom attributes private to this component.

If scope is Component.SPACE_SCOPE , it means custom attributes shared by components from the same ID space as this one's.

If scope is Component.PAGE_SCOPE , it means custom attributes shared by components from the same page as this one's.

If scope is Component.DESKTOP_SCOPE , it means custom attributes shared by components from the same desktopas this one's.
Parameters:
  scope - Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,
Parameters:
  value - the value.

public  ObjectsetAttribute(String name, Object value)
     Sets the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE .
public  voidsetId(String id)
     Sets the ID.
public  voidsetMold(String mold)
     Sets the mold for this component.
Parameters:
  mold - the mold.
public  voidsetPage(Page page)
     Sets what page this component belongs to. If this component already belongs to the same page, nothing is changed.

For child components, the page they belong is maintained automatically.

public  voidsetPageBefore(Page page, Component refRoot)
     Sets what page this component belongs to, and insert this component right before the reference component.

For child components, the page they belong is maintained automatically.

public  voidsetParent(Component parent)
     Sets the parent component.

Note: Component.setParent always calls back Component.insertBefore and/or Component.removeChild , while Component.insertBefore and Component.removeChild always calls back Component.setParent , if the parent is changed.

public  voidsetVariable(String name, Object val, boolean local)
     Sets a variable to the namespace.

This method is the same as getNamespace().setVariable(name, value, local).

Once a variable is set thru this method, it is visible to both the interpreter and EL.

Note: Exactly one namespace is allocated for each ID space. For example, if the space owner of this component is the page, then the returned namespace is the same as Page.getNamespace . Otherwise, it is the same as the namspace returned by the component owning this ID space.

When to use setVariable and setAttribute?

First, only the ID space support Component.setVariable and so. Second, the variables can be referenced directly in zscript and EL expressions, while attributes are referenced thru the scope, such as spaceScope. On the other hand, using attributes causes less name popultion. In general, if you could use attributes, don't use variable.
Parameters:
  local - whether not to search any of the ancestor namespace definesthe variable.

public  booleansetVisible(boolean visible)
     Sets whether this component is visible.
public  voidsmartUpdate(String attr, String value)
     Smart-updates a property with the specified value. Called by component developers to do precise-update.

The second invocation with the same property will replace the previous call.

public  voidsmartUpdateDeferred(String attr, DeferredValue value)
     Smart-updates a property with a deferred value. A deferred value is used to encapsulate a value that shall be retrieved only in the rendering phase. In other words, DeferredValue.getValue won't be called until the rendering phase.
public  voidunsetVariable(String name, boolean local)
     Unsets a variable defined in the namespace.

Field Detail
APPLICATION_SCOPE
final public static int APPLICATION_SCOPE(Code)
Used with Component.getAttribute and relevants to denote custom attributes shared by the whole application.

It is also known as the application attributes.

It is the same as WebApp.getAttributes .




COMPONENT_SCOPE
final public static int COMPONENT_SCOPE(Code)
Used with Component.getAttribute and relevants to denote custom attributes private to a component is searched.

It is also known as the component attributes.

It is the same as Component.getAttributes .




DESKTOP_SCOPE
final public static int DESKTOP_SCOPE(Code)
Used with Component.getAttribute and relevants to denote custom attributes shared by the same desktop.

It is also known as the desktop attributes.

It is the same as Desktop.getAttributes .




PAGE_SCOPE
final public static int PAGE_SCOPE(Code)
Used with Component.getAttribute and relevants to denote custom attributes shared by the same page.

It is also known as the page attributes.

It is the same as Page.getAttributes .




REQUEST_SCOPE
final public static int REQUEST_SCOPE(Code)
Used with Component.getAttribute and relevants to denote custom attributes shared by the same request.

It is also known as the request attributes.

It is the same as Execution.getAttributes .




SESSION_SCOPE
final public static int SESSION_SCOPE(Code)
Used with Component.getAttribute and relevants to denote custom attributes shared by the same session.

It is also known as the session attributes.

It is the same as Session.getAttributes .




SPACE_SCOPE
final public static int SPACE_SCOPE(Code)
Used with Component.getAttribute and relevants to denote custom attributes shared by the same ID space.

It is also known as the ID space attributes.






Method Detail
addEventListener
public boolean addEventListener(String evtnm, EventListener listener)(Code)
Adds an event listener to specified event for this component. The second registration is ignored and false is returned.

You could register listener to all components in the same page by use of Page.addEventListener .
Parameters:
  evtnm - what event to listen (never null) whether the listener is added; false if it was added before
See Also:   Page.addEventListener




addForward
public boolean addForward(String originalEvent, Component target, String targetEvent)(Code)
Adds a forward condition to forward the event received by this component to another component.

Default: no forward condition at all.

Once the condition is added, a event called targetEvent is posted to the target compoennt, when this component receives the orginalEvent event.
Parameters:
  originalEvent - the original event that was receivedby this component. If null, "onClick" is assumed.
Parameters:
  target - the target component to receive the event.If null, the space owner Component.getSpaceOwner is assumed.If null and the space owner is the page, the root component is assumed.
Parameters:
  targetEvent - the target event that the target componentwill receive.If null, it is the same as the original event. whether it is added successfully.It returns false if the conditioin was always added before.
since:
   3.0.0
See Also:   Component.removeForward(String,Component,String)




addForward
public boolean addForward(String originalEvent, String targetPath, String targetEvent)(Code)
Adds a forward condition to forward the event received by this component to another component, specified with a path.

Note: the target component is retrieved from the path, each time the event is received. Thus, you can reference to a component that is created later.
Parameters:
  originalEvent - the original event that was receivedby this component. If null, "onClick" is assumed.
Parameters:
  targetPath - the target component's path related to this component.If ".", this component is assumed.If null, the space owner is assumed.If null and the space owner is the page, the root component is assumed.
Parameters:
  targetEvent - the target event that the target componentwill receive.If null, it is the same as the original event. whether it is added successfully.It returns false if the conditioin was always added before.
See Also:   Component.addForward(String,Component,String)
See Also:   Component.removeForward(String,String,String)
since:
   3.0.0




appendChild
public boolean appendChild(Component child)(Code)
Appends a child. A shortcut to insertBefore(child, null).
See Also:   Component.insertBefore



applyProperties
public void applyProperties()(Code)
Initializes the properties (aka. members) and custom-attributes based on what are defined in the component definition.

This method is invoked automatically if a component is created by evaluating a ZUML page, i.e., if it is specified as an elemnt of a ZUML page.

On the other hand, if it is created manually (by program), developer might choose to invoke this method or not, depending whether he wants to initializes the component with the properties and custom-attributes defined in the ZUML page ( org.zkoss.zk.ui.metainfo.PageDefinition ) and the language definition ( org.zkoss.zk.ui.metainfo.LanguageDefinition ).




clone
public Object clone()(Code)
Clones the component. All of its children is cloned. Notice that the cloned component doesn't belong to any page, nor desktop. It doesn't have parent, either.



containsVariable
public boolean containsVariable(String name, boolean local)(Code)
Returns whether the specified variable is defined.

Note: null is a valid value for variable, so this method is used to know whether a variable is defined. On the other hand, Component.setAttribute actually remove an attribute (by Component.removeAttribute if value is null.
Parameters:
  local - whether not to search its ancestor.If false and the current namespace doen't define the variable,it searches up its ancestor (via Component.getParent) to seeany of them has defined the specified variable.




detach
public void detach()(Code)
Detaches this component such that it won't belong to any page. If you don't call Component.setParent or Component.setPage to attach it to any page, it will be removed automatically (from the client) after the current event is processed.



getAttribute
public Object getAttribute(String name, int scope)(Code)
Returns the value of the specified custom attribute in the specified scope, or null if not defined.

If scope is Component.COMPONENT_SCOPE , it means attributes private to this component.

If scope is Component.SPACE_SCOPE , it means custom attributes shared by components from the same ID space as this one's.

If scope is Component.PAGE_SCOPE , it means custom attributes shared by components from the same page as this one's.

If scope is Component.DESKTOP_SCOPE , it means custom attributes shared by components from the same desktopas this one's.
Parameters:
  scope - Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,




getAttribute
public Object getAttribute(String name)(Code)
Returns the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE .



getAttributes
public Map getAttributes(int scope)(Code)
Returns all custom attributes of the specified scope. You could reference them thru componentScope, spaceScope, pageScope, requestScope and desktopScope in zscript and EL.

If scope is Component.COMPONENT_SCOPE , it means custom attributes private to this component.

If scope is Component.SPACE_SCOPE , it means custom attributes shared by components from the same ID space as this one's.

If scope is Component.PAGE_SCOPE , it means custom attributes shared by components from the same page as this one's.

If scope is Component.DESKTOP_SCOPE , it means custom attributes shared by components from the same desktopas this one's.
Parameters:
  scope - Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,




getAttributes
public Map getAttributes()(Code)
Returns all custom attributes associated with this component, i.e., Component.COMPONENT_SCOPE .



getChildren
public List getChildren()(Code)
Returns a live list of children. You could add or remove a child by manipulating the returned list directly.



getDefinition
public ComponentDefinition getDefinition()(Code)
Returns the component definition of this component (never null).



getDesktop
public Desktop getDesktop()(Code)
Returns the desktop of this component, or null if this component doesn't belong to any desktop.

When a component is created in an event listener, it is assigned to the current desktop automatically. If a component is created not in any event listener, it doesn't belong to any desktop and this method returns null. Once a component is attached to a desktop (thru Component.setPage or Component.setParent ), it belongs to the desktop.

Notice: there is no way to detach a component from a desktop, once it is attached as described above. In other words, you cannot move a component (or page) from one desktop to another.

In summary, there are only two ways to handle components.

  1. Handle them all in event listeners and don't access any components from other desktops. This is simplest and clearest.
  2. Creates components in another thread (other than event listener) and attach them to a page (and then desktop) upon an event is received.



getFellow
public Component getFellow(String id)(Code)
Returns a component of the specified ID in the same ID space. Components in the same ID space are called fellows.

Unlike Component.getFellowIfAny , it throws an exception if not found.
exception:
  ComponentNotFoundException - is thrown if fellow not found




getFellowIfAny
public Component getFellowIfAny(String id)(Code)
Returns a component of the specified ID in the same ID space, or null if not found.

Unlike Component.getFellow , it returns null if not found.




getFirstChild
public Component getFirstChild()(Code)
Returns the first child component, or null if no child at all.
since:
   3.0.0



getId
public String getId()(Code)
Returns the ID. If it is a root component (i.e., without parent), its ID must be unquie among root components of the same page.

If a component belongs to an ID space (see IdSpace ), the ID must also be unique in the ID space it belongs. any its parent and ancestor implements IdSpace .

A page itself is also an ID space, so you could retrieve compnents in a page by use of Page.getFellow , unless the component is a descendant of another component that implements IdSpace . In this case, you have to retrieve the parent first (by use of Page.getFellow and then use Component.getFellow against the owner of the ID space.

In zscript and EL, a component with explicit ID can be accessed directly by the ID. In other word, a variable named by the ID is created automatically.
See Also:   Page




getLastChild
public Component getLastChild()(Code)
Returns the last child component, or null if no child at all.
since:
   3.0.0



getListenerIterator
public Iterator getListenerIterator(String evtnm)(Code)
Returns an iterator for iterating listener for the specified event.



getMold
public String getMold()(Code)
Returns the mold for this component.

Default: "default"
See Also:   org.zkoss.zk.ui.metainfo.ComponentDefinition




getNamespace
public Namespace getNamespace()(Code)
Returns the namespace to store variables and functions belonging to the ID space of this component.

Exactly one namespace is allocated for each ID space. For example, if the space owner of this component is the page, then the returned namespace is the same as Page.getNamespace . Otherwise, it is the same as the namspace returned by the component owning this ID space.

Namspace is another part of an ID space. It holds only variables defined thru Component.setVariable (and Namespace.setVariable .

Note: The namespace doesn't include any variable defined by executing zscripts. To retrieve them, use Page.getZScriptVariable .
See Also:   Component.getSpaceOwner




getNextSibling
public Component getNextSibling()(Code)
Returns the next sibling, or null if it is the last child.
since:
   3.0.0



getPage
public Page getPage()(Code)
Returns the page that this component belongs to, or null if it doesn't belong to any page.

When a component is created (aka., constructed), it doesn't belong to any page. And, if a component doesn't belong to any page, they won't be displayed at the client.

When changing parent ( Component.setParent ), the child component's page will become the same as parent's. In other words, a component is added to a page automatically if it becomes a child of another component (who belongs to a page).

For root components, you have to invoke Component.setPage explicityly.
See Also:   Component.setParent
See Also:   Component.setPage




getParent
public Component getParent()(Code)
Returns the parent component, or null if this is the root component.



getPreviousSibling
public Component getPreviousSibling()(Code)
Returns the previous sibling, or null if it is the first child.
since:
   3.0.0



getRoot
public Component getRoot()(Code)
Returns the root of this component.



getSpaceOwner
public IdSpace getSpaceOwner()(Code)
Returns the owner of the ID space that this component belongs to. The returned value could be a component, a page or null. If this component itself implements IdSpace , this method returns itself. If it has an ancestor that implements IdSpace , the ancestor is returned. Otherwise, the page it belongs to is returned

Each ID space defines an independent set of IDs. No component in the same ID space could have the same ID. To get any component in the same ID space, you could use Component.getFellow . See IdSpace for more details.

The ID space relevant methods include Component.getFellow , Component.getAttribute and Component.getVariable .
See Also:   Component.getNamespace




getUuid
public String getUuid()(Code)
Returns UUID (universal unique ID) which is unquie in the whole session. The UUID is generated automatically and immutable, unless org.zkoss.zk.ui.ext.RawId is also implemented.

It is mainly used for communication between client and server and you rarely need to access it.

If org.zkoss.zk.ui.ext.RawId is implemented as part of a component, UUID is the same as Component.getId if Component.setId is ever called. It is designed to migrate HTML pages to ZK, such that the element ID could remain the same.




getVariable
public Object getVariable(String name, boolean local)(Code)
Returns the value of a variable defined in the namespace, or null if not defined or the value is null.

This method is the same as getNamespace().getVariable(name, local).

Differences between Component.getVariable and Page.getZScriptVariable

Component.getVariable returns only variables defined by Component.setVariable (i.e., a shortcut of Namespace.setVariable ). On the other hand, Page.getZScriptVariable returns these variables and those defined when executing zscripts.
Parameters:
  local - whether not to search its ancestor.If false and the current namespace doen't define the variable,it searches up its ancestor (via Component.getParent) to seeany of them has defined the specified variable.
See Also:   Component.getSpaceOwner
See Also:   Component.getNamespace




insertBefore
public boolean insertBefore(Component newChild, Component refChild)(Code)
Inserts a child before the reference child.

You could use Component.setParent or Component.appendChild instead of this method, unless you want to control where to put the child.

Note: Component.setParent always calls back Component.insertBefore and/or Component.removeChild , while Component.insertBefore and Component.removeChild always calls back Component.setParent , if the parent is changed. Thus, you don't need to override both Component.insertBefore and Component.setParent , if you want to customize the behavior.
Parameters:
  newChild - the new child to be inserted.
Parameters:
  refChild - the child before which you want the new childbeing inserted. If null, the new child is append to the end. true if newChild is added successfully or moved;false if it already has the specified child and the order doesn'tchange.




invalidate
public void invalidate()(Code)
Invalidates this component by setting the dirty flag such that it will be redraw the whole content later.

It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

There are two ways to draw a component, one is to invoke Component.invalidate() , and the other is Component.smartUpdate . While Component.invalidate() causes the whole content to redraw, Component.smartUpdate let component developer control which part to redraw.

Once this method is called, all invocations to Component.smartUpdate will then be ignored, and Component.redraw will be invoked later.




isChildable
public boolean isChildable()(Code)
Returns whether this component allows to have any child.



isListenerAvailable
public boolean isListenerAvailable(String evtnm, boolean asap)(Code)
Returns whether the event listener is available.

Unlike org.zkoss.zk.ui.event.Events.isListened , this method checks only the event listener registered by Component.addEventListener .
Parameters:
  asap - whether to check only non-deferrable listener,i.e., not implementing org.zkoss.zk.ui.event.Deferrable,or org.zkoss.zk.ui.event.Deferrable.isDeferrable is false.
See Also:   org.zkoss.zk.ui.event.Deferrable
See Also:   org.zkoss.zk.ui.event.Events.isListened
See Also:   Component.addEventListener




isVisible
public boolean isVisible()(Code)
Returns whether this component is visible.
See Also:   Components.isRealVisible



onChildAdded
public void onChildAdded(Component child)(Code)
Called when a child is added. If a component want to optimize the update, it might do something different. Otherwise, it does nothing.

Note: Component.onChildAdded is called in the request-processing phase, while Component.onDrawNewChild is called in the redrawing phase. See Component.onDrawNewChild for more details.

It is not a good idea to throw an exception in this method, since it is in the middle of modifying the component tree.




onChildRemoved
public void onChildRemoved(Component child)(Code)
Called when a child is removed. If a component want to optimize the update, it might do something different. Otherwise, it simply does nothing.

It is not a good idea to throw an exception in this method, since it is in the middle of modifying the component tree.




onDrawNewChild
public void onDrawNewChild(Component child, StringBuffer out) throws IOException(Code)
Called when a new-created child is about to render. It gives the parent a chance to fine-tune the output. Note: it won't be called if the parent is rendered, too. In other words, it is called only if the child is attached dynamically.

It is called in the redrawing phase by the kernel, so it is too late to call Component.invalidate() or Component.smartUpdate in this method.

Note: Component.onChildAdded is called in the request-processing phase, while Component.onDrawNewChild is called in the redrawing phase. Component developer might do one of the follows:

  • Nothing, if new child can be inserted directly.
  • Overwrite Component.onDrawNewChild to add special tags, if new child needs to be added an exterior with some tags before insertion.
    Morever, if you shall add id="${child.uuid}!chdextr" to the added exterior.
  • Redraw the parent, if it is too complicated. How: overwrite Component.onChildAdded and calls Component.invalidate()

Parameters:
  child - the child being rendered
Parameters:
  out - the rendered result of the child.



onPageAttached
public void onPageAttached(Page newpage, Page oldpage)(Code)
Called when this component is attached to a page.

If a component is moved from one page to another, Component.onPageAttached is called with both pages. Note: Component.onPageDetached is not called in this case.

Note: this method is called even if the component is attached to a page implicitly thru, say, Component.setParent .

It is not a good idea to throw an exception in this method, since it is in the middle of modifying the component tree.
Parameters:
  newpage - the new page (never null).
Parameters:
  oldpage - the previous page, if any, or null if it didn'tbelong to any page.
since:
   3.0.0




onPageDetached
public void onPageDetached(Page page)(Code)
Called when this component is detached from a page.

If a component is moved from one page to another, Component.onPageAttached is called with both pages. Note: Component.onPageDetached is not called in this case. In other words, Component.onPageDetached is called only if a component is detached from a page (not belong to any other page).

Note: this method is called even if the component is detached to a page implicitly thru, say, Component.setParent .

It is not a good idea to throw an exception in this method, since it is in the middle of modifying the component tree.
Parameters:
  page - the previous page (never null)
since:
   3.0.0




redraw
public void redraw(Writer out) throws IOException(Code)
AuRequest this component to render (aka., redraw) itself and its children.

It is called in the redrawing phase by the kernel, so it is too late to call Component.invalidate() or Component.smartUpdate in this method.




removeAttribute
public Object removeAttribute(String name, int scope)(Code)
Removes the specified custom attribute in the specified scope.

If scope is Component.COMPONENT_SCOPE , it means attributes private to this component.

If scope is Component.SPACE_SCOPE , it means custom attributes shared by components from the same ID space as this one's.

If scope is Component.PAGE_SCOPE , it means custom attributes shared by components from the same page as this one's.

If scope is Component.DESKTOP_SCOPE , it means custom attributes shared by components from the same desktopas this one's.
Parameters:
  scope - Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,




removeAttribute
public Object removeAttribute(String name)(Code)
Removes the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE .



removeChild
public boolean removeChild(Component child)(Code)
Removes a child. The child is not actually removed. Rather, it is detached (see Component.detach ) and it will be removed if it is no longer used.

You could use Component.setParent with null instead of this method.

Note: Component.setParent always calls back Component.insertBefore and/or Component.removeChild , while Component.insertBefore and Component.removeChild always calls back Component.setParent , if the parent is changed. Thus, you don't need to override both Component.insertBefore and Component.setParent , if you want to customize the behavior. true if child is removed successfully; false if it doesn'thave the specified child




removeEventListener
public boolean removeEventListener(String evtnm, EventListener listener)(Code)
Removes an event listener. whether the listener is removed; false if it was never added.



removeForward
public boolean removeForward(String originalEvent, Component target, String targetEvent)(Code)
Removes a forward condition that was added by Component.addForward(String,Component,String) . If no such forward condition exists, nothing happens but return false.
Parameters:
  originalEvent - the oringal event that was receivedby this component.It must be the same as the one passed to Component.addForward(String,Component,String).
Parameters:
  target - the target component to receive the event.It must be the same as the one passed to Component.addForward(String,Component,String).
Parameters:
  targetEvent - the target event that the target component will receive.It must be the same as the one passed to Component.addForward(String,Component,String). whether the forward is removed successfully.It returns false if the forward condition is not found
See Also:   Component.addForward(String,Component,String)
since:
   3.0.0



removeForward
public boolean removeForward(String originalEvent, String targetPath, String targetEvent)(Code)
Removes a forward condition that was added by Component.addForward(String,String,String) . If no such forward condition exists, nothing happens but return false.
Parameters:
  originalEvent - the oringal event that was receivedby this component.It must be the same as the one passed to Component.addForward(String,Component,String).
Parameters:
  targetPath - the target component's path related to this component.If ".", this component is assumed.If null, the space owner is assumed.If null and the space owner is the page, the root component is assumed.
Parameters:
  targetEvent - the target event that the target component will receive.It must be the same as the one passed to Component.addForward(String,Component,String). whether the forward is removed successfully.It returns false if the forward condition is not found
See Also:   Component.addForward(String,String,String)
since:
   3.0.0



response
public void response(String key, AuResponse response)(Code)
Causes a response (aka., a command) to be sent to the client.

If AuResponse.getDepends is not null, the response depends on the existence of the returned componet. In other words, the response is removed if the component is removed. If it is null, the response is component-independent and it is always sent to the client.

Unlike Component.smartUpdate , responses are sent to client if it is component independent or it is not removed. In other words, it is sent even if Component.invalidate() was called. Typical examples include setting the focus, selecting the text and so on.

It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.
Parameters:
  key - could be anything.The second invocation of this methodin the same execution with the same key will override the previous one.However, if key is null, it won't override any other. All responseswith key == null will be sent.




setAttribute
public Object setAttribute(String name, Object value, int scope)(Code)
Sets the value of the specified custom attribute in the specified scope.

Note: The attribute is removed (by Component.removeAttribute if value is null, while Component.setVariable considers null as a legal value.

If scope is Component.COMPONENT_SCOPE , it means custom attributes private to this component.

If scope is Component.SPACE_SCOPE , it means custom attributes shared by components from the same ID space as this one's.

If scope is Component.PAGE_SCOPE , it means custom attributes shared by components from the same page as this one's.

If scope is Component.DESKTOP_SCOPE , it means custom attributes shared by components from the same desktopas this one's.
Parameters:
  scope - Component.COMPONENT_SCOPE, Component.SPACE_SCOPE,Component.PAGE_SCOPE, Component.DESKTOP_SCOPE, Component.SESSION_SCOPE,Component.REQUEST_SCOPE or Component.APPLICATION_SCOPE,
Parameters:
  value - the value. If null, the attribute is removed.




setAttribute
public Object setAttribute(String name, Object value)(Code)
Sets the custom attribute associated with this component, i.e., Component.COMPONENT_SCOPE .



setId
public void setId(String id)(Code)
Sets the ID. The scope of uniqunes depends on whether this component is a root component. Refer to Component.getId for more details.

When a component is constructed, an ID is generated automatically. Thus, calling this method only you need to identify a component.
See Also:   Page




setMold
public void setMold(String mold)(Code)
Sets the mold for this component.
Parameters:
  mold - the mold. If null or empty, "default" is assumed.
See Also:   org.zkoss.zk.ui.metainfo.ComponentDefinition



setPage
public void setPage(Page page)(Code)
Sets what page this component belongs to. If this component already belongs to the same page, nothing is changed.

For child components, the page they belong is maintained automatically. You need to invoke this method only for root components.




setPageBefore
public void setPageBefore(Page page, Component refRoot)(Code)
Sets what page this component belongs to, and insert this component right before the reference component.

For child components, the page they belong is maintained automatically. You need to invoke this method only for root components.

It is similar to Component.setPage , except this component will be placed before the reference component. If the reference component is null, this component is placed at the end of all root components.
Parameters:
  refRoot - another root component used as a referencewhich this component will be placed before.If null, this component will be placed at the end of allroot components (no matter whether it already belongs to the same page).
since:
   3.0.0




setParent
public void setParent(Component parent)(Code)
Sets the parent component.

Note: Component.setParent always calls back Component.insertBefore and/or Component.removeChild , while Component.insertBefore and Component.removeChild always calls back Component.setParent , if the parent is changed. Thus, you don't need to override both Component.insertBefore and Component.setParent , if you want to customize the behavior.




setVariable
public void setVariable(String name, Object val, boolean local)(Code)
Sets a variable to the namespace.

This method is the same as getNamespace().setVariable(name, value, local).

Once a variable is set thru this method, it is visible to both the interpreter and EL.

Note: Exactly one namespace is allocated for each ID space. For example, if the space owner of this component is the page, then the returned namespace is the same as Page.getNamespace . Otherwise, it is the same as the namspace returned by the component owning this ID space.

When to use setVariable and setAttribute?

First, only the ID space support Component.setVariable and so. Second, the variables can be referenced directly in zscript and EL expressions, while attributes are referenced thru the scope, such as spaceScope. On the other hand, using attributes causes less name popultion. In general, if you could use attributes, don't use variable.
Parameters:
  local - whether not to search any of the ancestor namespace definesthe variable. If local is false and an ancesotor has defined a variablewith the same name, the variable in the ancestor is changed directly.Otherwise, a new variable is created in the namespace containingthis component.
See Also:   Component.getSpaceOwner
See Also:   Component.getNamespace




setVisible
public boolean setVisible(boolean visible)(Code)
Sets whether this component is visible. the previous visibility



smartUpdate
public void smartUpdate(String attr, String value)(Code)
Smart-updates a property with the specified value. Called by component developers to do precise-update.

The second invocation with the same property will replace the previous call. In other words, the same property will be set only once in each execution.

This method has no effect if Component.invalidate() is ever invoked (during this execution).

It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

There are two ways to draw a component, one is to invoke Component.invalidate() , and the other is Component.smartUpdate . While Component.invalidate() causes the whole content to redraw, Component.smartUpdate let component developer control which part to redraw.
Parameters:
  value - the new value. If null, it means removing the property.




smartUpdateDeferred
public void smartUpdateDeferred(String attr, DeferredValue value)(Code)
Smart-updates a property with a deferred value. A deferred value is used to encapsulate a value that shall be retrieved only in the rendering phase. In other words, DeferredValue.getValue won't be called until the rendering phase. On the other hand, this method is usually called in the event processing phase.

For some old application servers (example, Webshpere 5.1), Execution.encodeURL cannot be called in the event processing thread. So, the developers have to use DeferredValue or disable the use of the event processing thread (by use of disable-event-thread in zk.xml).
since:
   3.0.1




unsetVariable
public void unsetVariable(String name, boolean local)(Code)
Unsets a variable defined in the namespace.

This method is the same as getNamespace().getVariable(name, local).
Parameters:
  local - whether not to search its ancestor.If false and the current namespace doen't define the variable,it searches up its ancestor (via Component.getParent) to seeany of them has defined the specified variable.
See Also:   Component.getSpaceOwner
See Also:   Component.getNamespace




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.