result"

From Documentation
m (correct highlight (via JWB))
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{ZESTEssentialsPageHeader}}
 
{{ZESTEssentialsPageHeader}}
 +
 +
__NOTOC__
  
 
'''Syntax:'''
 
'''Syntax:'''
  
  <result [name="''a-result''"]>''a-view's-uri''</result>
+
  <result [name="''a-result''"] [type="forward|redirect"]>''a-view's-uri''</result>
 +
<result [name="''a-result''"] type="error">''error-code''</result>
 +
<result [name="''a-result''"] type="error">''error-code'': ''error-message''</result>
 +
<result [name="''a-result''"] type="done"/>
  
It specifies a result of an action definition. It must be placed under [[ZEST Essentials/Configuration/zest.xml/action|the action element]].
+
It specifies a result of an action definition. It must be placed under [[ZEST Essentials/Configuration/zest.xml/action|the action element]], and an action definition could have one or multiple results.
 +
 
 +
The result consists of the name, the type, and the URI of the targeted view. The name, if any, is specified as the name attribute, while the URI of the view is specified as the inner text of the result element. For example,
 +
 
 +
<source lang="xml">
 +
<result name="success">/WEB-INF/hello/HelloWorld.jsp</result>
 +
<result>/WEB-INF/foo/Foo.jsp</result><!-- the default view -->
 +
<result name="success2" type="redirect">/somewhere/to/go</result>
 +
<result name="notfound" type="error">404</result>
 +
</source>
  
 
=Attributes=
 
=Attributes=
 
==name==
 
==name==
  [Optional][Default: '''null''']
+
  [Optional]
 +
[Default: '''null''']
 +
 
 +
It specifies the name of the result. The view specified in a result is used, if the result's name matches the return value of the execute method.
 +
 
 +
If the name attribute is omitted, it is the default result. In other words, the URI of the view is used if no other result is matched.
 +
 
 +
==type==
 +
[Optional]
 +
[Allowed: forward, redirect, error, done]
 +
[Default: forward]
 +
[since 1.1.0]
 +
 
 +
It specifies the type of result. By default, it is <code>foward</code>. If you prefer ''send-redirect'' (i.e., <code>HttpServletResponse.sendRedirect</code>), you could specify the type as <code>redirect</code>, and the URI must be an URL that the user is allowed to access, i.e., it can't be located in <code>/WEB-INF</code>.
 +
 
 +
If a result represents an error, you could specify the type as <code>error</code>, and put the error code in the element, such as
 +
 
 +
<source lang="xml">
 +
<result name="notfound" type="error">404</result>
 +
<result name="gone" type="error">301: moved</result>
 +
</source>
 +
 
 +
If the action generates the output directly to the response, you could specify the type as <code>done</code>, then ZEST won't handle it further but returning the response directly.
  
 
=Version History=
 
=Version History=
Line 16: Line 52:
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-
| &nbsp;
+
| 1.1.0
| &nbsp;
+
| June 2011
| &nbsp;
+
| Three new types, redirect, error and done, were introduced.
 
|}
 
|}
  
 
{{ZESTEssentialsPageFooter}}
 
{{ZESTEssentialsPageFooter}}

Latest revision as of 02:57, 18 January 2022



Syntax:

<result [name="a-result"] [type="forward|redirect"]>a-view's-uri</result>
<result [name="a-result"] type="error">error-code</result>
<result [name="a-result"] type="error">error-code: error-message</result>
<result [name="a-result"] type="done"/>

It specifies a result of an action definition. It must be placed under the action element, and an action definition could have one or multiple results.

The result consists of the name, the type, and the URI of the targeted view. The name, if any, is specified as the name attribute, while the URI of the view is specified as the inner text of the result element. For example,

<result name="success">/WEB-INF/hello/HelloWorld.jsp</result>
<result>/WEB-INF/foo/Foo.jsp</result><!-- the default view -->
<result name="success2" type="redirect">/somewhere/to/go</result>
<result name="notfound" type="error">404</result>

Attributes

name

[Optional]
[Default: null]

It specifies the name of the result. The view specified in a result is used, if the result's name matches the return value of the execute method.

If the name attribute is omitted, it is the default result. In other words, the URI of the view is used if no other result is matched.

type

[Optional]
[Allowed: forward, redirect, error, done]
[Default: forward]
[since 1.1.0]

It specifies the type of result. By default, it is foward. If you prefer send-redirect (i.e., HttpServletResponse.sendRedirect), you could specify the type as redirect, and the URI must be an URL that the user is allowed to access, i.e., it can't be located in /WEB-INF.

If a result represents an error, you could specify the type as error, and put the error code in the element, such as

<result name="notfound" type="error">404</result>
<result name="gone" type="error">301: moved</result>

If the action generates the output directly to the response, you could specify the type as done, then ZEST won't handle it further but returning the response directly.

Version History

Last Update : 2022/01/18


Version Date Content
1.1.0 June 2011 Three new types, redirect, error and done, were introduced.



Last Update : 2022/01/18

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