org.zkoss.jsp.zul
Class InitTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.SimpleTagSupport
      extended by org.zkoss.jsp.zul.impl.AbstractTag
          extended by org.zkoss.jsp.zul.InitTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.DynamicAttributes, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.SimpleTag

public class InitTag
extends AbstractTag
implements javax.servlet.jsp.tagext.DynamicAttributes

A Tag map to the ZK Initiator. Implemented by an initiator that will be invoked if it is specified in the init directive.

<z:init class="MyInit" />

Once specified, an instance inside this tag is created and Initiator.doInit(org.zkoss.zk.ui.Page, java.lang.Object[]) is called before the page is evaluated. Then, Initiator.doAfterCompose(org.zkoss.zk.ui.Page) is called after all components are created, and before any event is processed. In additions, Initiator.doFinally() is called after the page has been evaluated. If an exception occurs, Initiator.doCatch(java.lang.Throwable) is called.

A typical usage: starting a transaction in doInit, rolling back it in Initiator.doCatch(java.lang.Throwable) and commit it in Initiator.doFinally() (if Initiator.doCatch(java.lang.Throwable) is not called).

Author:
Ian Tsai

Constructor Summary
InitTag()
           
 
Method Summary
 void doTag()
          Add this Initiator into HttpRequest, this will be processed by Component container: PageTag.
 java.lang.String getUse()
          Returns the class that implements Initiator.
 void setDynamicAttribute(java.lang.String uri, java.lang.String localName, java.lang.Object value)
          Called when a tag declared to accept dynamic attributes is passed an attribute that is not declared in the Tag Library Descriptor.
 void setUse(java.lang.String clazz)
          Sets the class that implements Initiator.
 
Methods inherited from class org.zkoss.jsp.zul.impl.AbstractTag
getIf, getUnless, isEffective, setIf, setUnless
 
Methods inherited from class javax.servlet.jsp.tagext.SimpleTagSupport
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InitTag

public InitTag()
Method Detail

setDynamicAttribute

public void setDynamicAttribute(java.lang.String uri,
                                java.lang.String localName,
                                java.lang.Object value)
                         throws javax.servlet.jsp.JspException
Called when a tag declared to accept dynamic attributes is passed an attribute that is not declared in the Tag Library Descriptor.
In this InitTag implementation, this method is used to "add" args.
For Example:

<z:init use="demo.MyInit" arg0="an arg" arg1="another arg " ...../>

Specified by:
setDynamicAttribute in interface javax.servlet.jsp.tagext.DynamicAttributes
Parameters:
uri - the namespace of the attribute. Ignored in this version.
localName - the name of the attribute being set.
value - the value of the attribute
Throws:
javax.servlet.jsp.JspException

doTag

public void doTag()
           throws javax.servlet.jsp.JspException,
                  java.io.IOException
Add this Initiator into HttpRequest, this will be processed by Component container: PageTag.

Specified by:
doTag in interface javax.servlet.jsp.tagext.SimpleTag
Overrides:
doTag in class javax.servlet.jsp.tagext.SimpleTagSupport
Throws:
javax.servlet.jsp.JspException
java.io.IOException

setUse

public void setUse(java.lang.String clazz)
Sets the class that implements Initiator.

Parameters:
clazz - a class name with derived class which is implements Initiator
Throws:
java.lang.IllegalArgumentException - if input class can't be found or is not implement Initiator

getUse

public java.lang.String getUse()
Returns the class that implements Initiator.



Copyright © 2005-2007 Potix Corporation. All Rights Reserved.