result"

From Documentation
m
m (correct highlight (via JWB))
 
Line 36: Line 36:
 
  [since 1.1.0]
 
  [since 1.1.0]
  
It specifies the type of result. By default, it is <tt>foward</tt>. If you prefer ''send-redirect'' (i.e., <code>HttpServletResponse.sendRedirect</code>), you could specify the type as <tt>redirect</tt>, 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>.
+
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 <tt>error</tt>, and put the error code in the element, such as
+
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">
 
<source lang="xml">
Line 45: Line 45:
 
</source>
 
</source>
  
If the action generates the output directly to the response, you could specify the type as <tt>done</tt>, then ZEST won't handle it further but returning the response directly.
+
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=

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.