action"

From Documentation
m (Created page with "{{ZESTEssentialsPageHeader}} =Version History= {{LastUpdated}} {| border='1px' | width="100%" ! Version !! Date !! Content |- |   |   |   |} {{ZESTEssentialsPage...")
 
m (correct highlight (via JWB))
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{ZESTEssentialsPageHeader}}
 
{{ZESTEssentialsPageHeader}}
 +
 +
__NOTOC__
 +
 +
'''Syntax:'''
 +
 +
<action path="''regex''" class="''class-name''" [method="''method-name''"]>
 +
 +
It specifies the definition of [[ZEST Essentials/Quick Start/Action|an action]].  To map a pattern of URI to an action, you have to specify one action definition.
 +
 +
Inside each action element, you could specify one or multiple result elements identifying the URI of the views.
 +
 +
<source lang="xml">
 +
<action path="/foo" class="my.Foo">
 +
    <result name="success">/WEB-INF/foo/used-if-success.zul</result>
 +
    <result>/WEB-INF/foo/used-if-no-matched-result</result>
 +
</action>
 +
</source>
 +
 +
{{ZESTEssentialsHeadingToc}}
 +
 +
=Attributes=
 +
==The path Attribute==
 +
[Required][EL ''not'' allowed]
 +
 +
It specifies the URI that matches this action. It could be a regular expression, such as <code>/foo/hello[^/]*/do</code>.
 +
 +
If the URI consists several logic segments, you could use [http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html#cg regular expression's grouping] to split them into several groups. For example, <code>/foo/([^/])*/do</code> matches any URI starting with <code>/foo</code> and ending with <code>/do</code>. Furthermore, the text between the second and third slashes is considered as the first matched group.
 +
 +
Then, you could use an implicit object called [[ZEST Essentials/EL Expressions/Implicit Objects/matches|matches]] to retrieve the matched group in an EL expression:
 +
 +
<source lang="xml">
 +
${matches[1]}
 +
</source>
 +
 +
Notice that <code>matches[0]</code> is the whole pattern, while <code>matches[1]</code> is the first matched group (aka., segment).
 +
 +
==The class Attribute==
 +
[Required][EL Allowed]
 +
 +
It specifies the name of the class of the action. It is used to instantiate an action when the path matches the request's URI. It could be any POJO class as long as it contains a method specified in the method attribute as described below.
 +
 +
Since EL expressions are allowed, you could specify a class's name depending on the request (such as HTTP method and parameters).
 +
 +
==The method Attribute==
 +
[Optional][EL Allowed][Default: execute]
 +
 +
It specifies the method's name to execute. If omitted, <code>execute</code> is assumed.
 +
 +
There are two kind of signatures are allowed. Please refer to [[ZEST_Essentials/Quick_Start/Action#Signature_of_the_execute_Method|the Signature of the execute Method section]] for more information.
 +
 +
Since EL expressions are allowed, you could specify a method's name depending on the request (such as HTTP method and parameters).
  
 
=Version History=
 
=Version History=

Latest revision as of 02:57, 18 January 2022



Syntax:

<action path="regex" class="class-name" [method="method-name"]>

It specifies the definition of an action. To map a pattern of URI to an action, you have to specify one action definition.

Inside each action element, you could specify one or multiple result elements identifying the URI of the views.

<action path="/foo" class="my.Foo">
    <result name="success">/WEB-INF/foo/used-if-success.zul</result>
    <result>/WEB-INF/foo/used-if-no-matched-result</result>
</action>


Subsections:


Attributes

The path Attribute

[Required][EL not allowed]

It specifies the URI that matches this action. It could be a regular expression, such as /foo/hello[^/]*/do.

If the URI consists several logic segments, you could use regular expression's grouping to split them into several groups. For example, /foo/([^/])*/do matches any URI starting with /foo and ending with /do. Furthermore, the text between the second and third slashes is considered as the first matched group.

Then, you could use an implicit object called matches to retrieve the matched group in an EL expression:

${matches[1]}

Notice that matches[0] is the whole pattern, while matches[1] is the first matched group (aka., segment).

The class Attribute

[Required][EL Allowed]

It specifies the name of the class of the action. It is used to instantiate an action when the path matches the request's URI. It could be any POJO class as long as it contains a method specified in the method attribute as described below.

Since EL expressions are allowed, you could specify a class's name depending on the request (such as HTTP method and parameters).

The method Attribute

[Optional][EL Allowed][Default: execute]

It specifies the method's name to execute. If omitted, execute is assumed.

There are two kind of signatures are allowed. Please refer to the Signature of the execute Method section for more information.

Since EL expressions are allowed, you could specify a method's name depending on the request (such as HTTP method and parameters).

Version History

Last Update : 2022/01/18


Version Date Content
     



Last Update : 2022/01/18

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.