|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zk.ui.metainfo.ZScript
public class ZScript
Represents a zscript element.
Constructor Summary | |
---|---|
ZScript(EvaluatorRef evalr,
java.lang.String zslang,
java.lang.String content,
ConditionImpl cond)
Creates a zscript object with the content directly. |
|
ZScript(EvaluatorRef evalr,
java.lang.String zslang,
java.lang.String url,
ConditionImpl cond,
Locator locator)
Constructs a ZScript with an URL, which might contain an EL
expression. |
|
ZScript(EvaluatorRef evalr,
java.lang.String zslang,
java.net.URL url,
ConditionImpl cond)
Create a zscript object with an URL that is used to load the content. |
Method Summary | |
---|---|
java.lang.String |
getContent(Page page,
Component comp)
Returns the content of zscript. |
java.lang.String |
getLanguage()
Returns the scripting language, or null if the default scripting language is preferred. |
java.lang.String |
getRawContent()
Returns the raw content. |
boolean |
isDeferred()
Returns whether the evaluation of the zscript shall be deferred. |
boolean |
isEffective(Component comp)
Used to evaluate whether it is effective. |
boolean |
isEffective(Page page)
Used to evaluate whether it is effective. |
static ZScript |
parseContent(java.lang.String content)
Parses the content into a ZScript instance. |
static ZScript |
parseContent(java.lang.String content,
int lineno)
Parses the content into a ZScript instance. |
void |
setDeferred(boolean deferred)
Sets whether the evaluation of the zscript shall be deferred. |
void |
setLanguage(java.lang.String zslang)
Sets the scripting language. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ZScript(EvaluatorRef evalr, java.lang.String zslang, java.lang.String content, ConditionImpl cond)
evalr
- the evaluator reference. It is required if cond is not null.zslang
- the scripting language. If null, it is the same as
Page.getZScriptLanguage()
.content
- the zscript contentpublic ZScript(EvaluatorRef evalr, java.lang.String zslang, java.net.URL url, ConditionImpl cond)
evalr
- the evaluator reference. It is required if cond is not null.url
- the URL to load the content of zscript.public ZScript(EvaluatorRef evalr, java.lang.String zslang, java.lang.String url, ConditionImpl cond, Locator locator)
ZScript
with an URL, which might contain an EL
expression.
evalr
- the evaluator reference.
It is required if cond is not null or url contains EL expression.url
- the URL. It may contain XEL expressions.locator
- the locator used to locate the zscript fileMethod Detail |
---|
public static final ZScript parseContent(java.lang.String content)
ZScript
instance.
This method assumes the content is in the following format:
lang:codes
codes
For example, "javascript:var m = 0;" returns "javascript", while "var m = 0;" returns null.
Note: if the language doesn't exist, null is returned. Reason: the above syntax may be conflict with some scripting languages.
Note: no space is allowed.
content
- the content of zscript codespublic static final ZScript parseContent(java.lang.String content, int lineno)
ZScript
instance.
It is similar to parseContent(String)
except it
allows the caller to specify the line number of the first line of the
content.
content
- the content of zscript codeslineno
- the linenumber of the first line. Ignored if
zero (or negative).public java.lang.String getLanguage()
public void setLanguage(java.lang.String zslang)
zslang
- the scripting language. If null, the default scripting
language is assume.public java.lang.String getRawContent()
ZScript(EvaluatorRef, String, String, ConditionImpl)
.
If URL is specified in the contructor, null is returned.
On the other hand, getContent(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component)
will load the content
automatically if URL is specified.
public java.lang.String getContent(Page page, Component comp)
Note: before evaluating the returned script, you have to invoke
isEffective(Component)
or isEffective(Page)
first.
page
- the page when this zscript is interpreted.
Used only if this object is contructed with ZScript(EvaluatorRef, String, String, ConditionImpl, Locator)
.comp
- the component when this zscript is interpreted.
Used only if this object is contructed with ZScript(EvaluatorRef, String, String, ConditionImpl, Locator)
.
UiException
- if faied to load the contentpublic boolean isDeferred()
public void setDeferred(boolean deferred)
Default: false.
public boolean isEffective(Component comp)
Condition
isEffective
in interface Condition
comp
- used as the self variable. Ignored if null.public boolean isEffective(Page page)
Condition
isEffective
in interface Condition
page
- used as the self variable. Ignored if null.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |