| java.lang.Object com.jcorporate.expresso.core.controller.ControllerElement com.jcorporate.expresso.core.controller.Transition
Transition | public class Transition extends ControllerElement implements Cloneable,java.io.Serializable(Code) | | An Transition is a choice that the user can make that initiates
either another sequence in this same controller or some new
controller. A transition is one of the three types of objects that
a controller produces when it enters a new state, the others
being Input objects and Output objects.
Another use of a Transition object is for internal transitioning between
various controllers and their states. Typical example is as follows:
Transition t = new Transition();
t.setControllerObject(com.myapp.MyController.class);
t.setState("State2");
t.addParameter("SampleParam","This is a parameter value");
return t.transition();
Recognized Attributes:
The following types are recognized by the expresso framework and
automatically rendered: You may add your own types or ignore them
if you are doing your own page rendering.
header: Renders the transition in the jc-header class style
button: Renders the transition as a button.
default behavior: Renders as a clickable button
|
Constructor Summary | |
public | Transition() Default Constructor. | public | Transition(String newState, Controller myController) Convenience method to transition to another state in this same controller.
Parameters: newState - the new name of the state. Parameters: myController - An instantiated Controller object. | public | Transition(String newLabel, String newObject) Convenience constructor to create an action with a label
and a controller already set. | public | Transition(String newName, String newLabel, String newObject) Convenience constructor to create an action with a label
and a controller already set. | public | Transition(String name, String label, Class controllerClass, String controllerState) Convenience method to allow for one line of code to construct a transition. | public | Transition(String label, Class controllerClass, String controllerState) Convenience method to allow for one line of code to construct a transition. |
Transition | public Transition()(Code) | | Default Constructor. Normally you don't use this.
|
Transition | public Transition(String newState, Controller myController)(Code) | | Convenience method to transition to another state in this same controller.
Parameters: newState - the new name of the state. Parameters: myController - An instantiated Controller object. Use a ControllerFactory to instantiate the controller if you must use this constructor. |
Transition | public Transition(String newLabel, String newObject)(Code) | | Convenience constructor to create an action with a label
and a controller already set.
Parameters: newLabel - Label for the new action Parameters: newObject - The name of the object this action referred to |
Transition | public Transition(String newName, String newLabel, String newObject)(Code) | | Convenience constructor to create an action with a label
and a controller already set.
Parameters: newName - Name of this Transition object Parameters: newLabel - Label for the new action Parameters: newObject - The name of the Controller object this action referred to |
Transition | public Transition(String name, String label, Class controllerClass, String controllerState)(Code) | | Convenience method to allow for one line of code to construct a transition.
Parameters: name - The name of the transition Parameters: label - The label to use for the transition Parameters: controllerClass - The Class of the controller to use Parameters: controllerState - The name of the controller's state. |
Transition | public Transition(String label, Class controllerClass, String controllerState)(Code) | | Convenience method to allow for one line of code to construct a transition.
The (internal) name of the transition will be the state name.
Parameters: label - The label to use for the transition Parameters: controllerClass - The Class of the controller to use Parameters: controllerState - The name of the controller's state. |
addParam | public synchronized void addParam(String paramCode, String paramValue)(Code) | | Adds a parameter to a transition. These parameters are meant to
be eventually consumed by the target controller via the request.getParameter()
method.
Parameters: paramCode - The code name of the parameter Parameters: paramValue - The value for the paramter |
enableReturnToSender | public void enableReturnToSender(ControllerResponse response) throws ControllerException(Code) | | Call this method when the state/controller being transitioned to should return control back
to the calling state once it has 'completed' successfully. Th 'completion' point depends on
whether the transition is to an external (new controller) or internal state. For external
transitions, the completion point is once the Final state has run successfully. For internal
transitions, the completion point is once the called state has run successfully.
When this method is called with a non-null response parameter, this indicates the currently
running state should be the return address. If this method is called with a null response
parameter then this indicates that the return address should be determined at transition
execution time. This is useful/necessary when a transition is instantiated outside the scope
of a state execution. For example, when the controllerSecurityTransition value is set in
the controller constructor, the return state is not known/active.
Parameters: response - the ControllerResponse object throws: ControllerException - upon error |
getControllerObject | public String getControllerObject()(Code) | | Return the name of the controller object that this Transition
referred to. If this is null, then it refers to the same controller
object (e.g. intra-controller transition)
The class name of the controller object this actionrefers to. |
getFullUrl | public String getFullUrl() throws ControllerException(Code) | | Similar to getURL but also includes the context path. Useful for working
with JSTL cout expressions inside an <a> link.
If the ControllerResponse has been set and running in a servlet environment,
then this function also encodes the resulting URL with suitable session id's
if necessary too
This URL is optimized, so it includes a Controller.CONTROLLER_PARAM_KEY param only if
the destination controller is different than the controller of the ControllerResponse (if
the response is known).
java.lang.String throws: ControllerException - upon error. See Also: Transition.getTheUrl |
getHTMLParamString | public String getHTMLParamString()(Code) | | Returns a hidden form field string that is safe in either the GET or POST
case.
Creation date: (1/10/01 11:24:00 AM)
author: Adam Rossi, PlatinumSolutions
java.lang.String |
getMapping | public String getMapping() throws ControllerException(Code) | | This function returns the mapping of the Struts action (including the
.do part) but without a context prepended to the mapping.
java.lang.String |
getOwnerController | public String getOwnerController()(Code) | | Sets the controller that created this transition. If controllerObject
equals owner controller, then no controller= parameter is generated.
the owner controller |
getParam | public String getParam(String paramCode)(Code) | | Return the value for a specific parameter for this transition object.
Parameters: paramCode - The code (name) of the parameter The value of the parameter as a string |
getParamString | public synchronized String getParamString(boolean includeControllerParameter)(Code) | | Parameters: includeControllerParameter - whether to include controller param or not. parameter string which includes all params added to trans, as wellas state param. controller param added optionally |
getParamString | public String getParamString()(Code) | | Return a string of the current params This is NOT URL encoded string.
Use either getUrl() OR java.net.URLEncoder() to do this job.
java.lang.String |
getParams | public Hashtable getParams()(Code) | | Return the hashtable of parameters for this transition object.
These parameters are to be handed to the new controller
when the action is called.
A hashtable of name/value pairs for the parameters |
getServletResponse | public HttpServletResponse getServletResponse()(Code) | | Gets an underlying ServletResponse if it has been set either through
setting the controller response or manually
HttpServletResponse or NULL if not being used. |
getState | public String getState()(Code) | | Retrieve the currently set state
java.lang.String |
getTheUrl | public String getTheUrl(boolean resolveControllerReference) throws ControllerException(Code) | | Internal use for retrieving the URL that this transition points to.
Parameters: resolveControllerReference - should the controller be resolved toa mapping, or should it just be the request path with a controller equalsparameter. True if you want the URL mapped to a .do mapping. java.lang.String throws: ControllerException - if there is an error or there is no controllerresponse object available to help resoolve the reference. |
isExternalTransition | public boolean isExternalTransition(String runningController)(Code) | | Returns True if the destination for this transition is a different
controller from the one currently active.
Parameters: runningController - the name of the controller we're currently in.Usually you woulduse this.getClass().getName() within your own controller asa parameter. true if this is a transition to a another controller. |
isRecursiveTransition | public boolean isRecursiveTransition(String runningState, String runningController)(Code) | | Returns True if the destination for this transition is the same as the
currently active state. Avoid infinite loop.
Parameters: runningState - the current state Parameters: runningController - the current controller true if we're recusing to the same state and controller as we'realready in. |
isReturnToSenderEnabled | public boolean isReturnToSenderEnabled()(Code) | | Return the return-to-sender flag.
boolean |
newStateDispatch | protected ControllerResponse newStateDispatch(ControllerRequest request) throws ControllerException, NonHandleableException(Code) | | This method invokes a new controller by dispatching to it rather than
calling it directly. This is required when transitioning to external
states so that Struts can setup the controller form.
The currently active controller request is passed to the new state to
simulate a direct call to the state. The request is then picked up
by the controller's perform method. Any exceptions raised by the
target state will filter back here to be passed on. This approach
was needed in order to simulate a direct call the the state while at
the same time allowing Struts to setup the controller form.
Parameters: request - the ControllerRequest Object an instantiated ControllerResponse object |
redirectTransition | public void redirectTransition(ControllerRequest request, ControllerResponse response) throws ControllerException(Code) | | Transition to a new controller and state by issuing a Redirect
request to the browser. This can only be used in a Servlet environment,
and is mainly useful when you want the URL for the browser to change after
a request, so for example, after making an online purchase, you display the
invoice, but if the user hit's refresh, you don't want the processing
to occur again.
Parameters: request - The ControllerRequest object handed to you by the framework Parameters: response - the ControllerResponse object handed to you by the framework |
setControllerObject | public synchronized void setControllerObject(String newObject)(Code) | | Set the Controller that this action referrs to
Parameters: newObject - Name of the Controller object that this Transition refers to |
setControllerObject | public synchronized void setControllerObject(Class c)(Code) | | Mor Typesafe way of setting the controller object. Any typos will be caught
at compile time. Example usage:
Transition t = new Transition();
t.setControllerObject(com.jcorporate.expresso.services.Status.class);
Parameters: c - the class of the controller object to add. |
setControllerResponse | public synchronized void setControllerResponse(ControllerResponse newResponse)(Code) | | Override of the normal setControllerResponse so that the HttpServletResponse
is also set for this particular transition.
Parameters: newResponse - the controllerResponse to set. |
setOwnerController | public synchronized void setOwnerController(String newController)(Code) | | Sets the controller that created this transition. If controllerObject
equals owner controller, then no controller= parameter is generated.
Parameters: newController - the classname of the new controller |
setParams | public synchronized void setParams(Hashtable newParams)(Code) | | Set this transition's parameters to the passed in collection.
Parameters: newParams - the new parameters in bulk |
setReturnToSenderParms | public synchronized void setReturnToSenderParms(ControllerRequest newReturnToSenderRequest)(Code) | | This method will take the request parameters that were passed to this state
and will copy them into this transition's parameters. These parameters
will then be used when this state is reinvoked (return-to-sender) in order
to re-establish the parameter context.
Parameters: newReturnToSenderRequest - The ControllerRequest object |
setServletResponse | public void setServletResponse(HttpServletResponse servletResponse)(Code) | | Low level, sets the servlet response. Normally you won't use this function
except under specialty situations where you are using a Transition more
as a URL generator
Parameters: servletResponse - a servlet response object for encoding URLs |
setState | public synchronized void setState(String newState)(Code) | | Sets the target state to transition to.
Parameters: newState - java.lang.String |
toXML | public FastStringBuffer toXML(FastStringBuffer stream)(Code) | | Convert the object to an xml fragment.
Parameters: stream - an instantiated FastStringBuffer to which we append to. a FastStringBuffer object |
transition | public ControllerResponse transition(ControllerRequest req, ControllerResponse res, boolean clear) throws ControllerException, NonHandleableException(Code) | | Run this transition - e.g. transition to the new state of the
specified controller object immediately, setting the specified
response to the response of this new controller/state, discarding
any previous response (if "clear" is specified)
NB: all parameters in the original request are discarded, except
those that are explicit params added to this Transition.
Therefore, if you have a param X in the original state,
and you need it in the upcoming
state, use addParam() to preserve it, OR use the ControllerResponse.setFormCache()
to save them before the transition(),
Parameters: req - The ControllerRequest object handed to you by the framework Parameters: res - the ControllerResponse object handed to you by the framework Parameters: clear - True clears the response object before adding the outputsfrom the called controller? the ControllerResponse Object from the called controller throws: ControllerException - upon error throws: NonHandleableException - upon fatal error See Also: ControllerResponse.setFormCache See Also: See Also: and response.getFormCache(paramName) to retrieve them See Also: ControllerResponse.getFormCache(String) |
|
|