Action"

From Documentation
m
Line 25: Line 25:
  
 
=Signature of the execute Method=
 
=Signature of the execute Method=
 +
 +
There are two  kinds of signatures are allowed for the execute method of an action.
 +
 +
# <code>public String ''execute''();</code>
 +
# <code>public String ''execute''(ActionContext ac);</code>
 +
 +
The method's name could be anything you prefer, as long as it is the same as the one you specified in <tt>WEB-INF/zest.xml</tt>.
 +
 +
The signature with <javadoc type="interface">org.zkoss.zest.sys.ActionContext</javadoc> has higher priority if both method are specified (and the signature with no arg will be ignored). It is used if you need the information of the request, such as HttpServletRequest.
  
 
=Parameters of the Request=
 
=Parameters of the Request=

Revision as of 02:05, 14 March 2011


An action is POJO. It does not have to implement any interface. Of course, it has to implement the method specified in WEB-INF/zest. For example,

package foo;
public class HelloAction {
	private String _message = "Welcome";

	/** The execute method specified in WEB-INF/zest.xml. */
	public String execute() {
		return "success";
	}

	/** Sets the message. */
	public void setMessage(String message) {
		_message = message;
	}
	/** Returns the message. */
	public String getMessage() {
		return _message;
	}
}

Signature of the execute Method

There are two kinds of signatures are allowed for the execute method of an action.

  1. public String execute();
  2. public String execute(ActionContext ac);

The method's name could be anything you prefer, as long as it is the same as the one you specified in WEB-INF/zest.xml.

The signature with ActionContext has higher priority if both method are specified (and the signature with no arg will be ignored). It is used if you need the information of the request, such as HttpServletRequest.

Parameters of the Request

Version History

Last Update : 2011/03/14


Version Date Content
     



Last Update : 2011/03/14

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