|
Expresso 5-5-0 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.controller.ControllerElement
com.jcorporate.expresso.core.controller.Transition
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();
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
image: Renders the transition as a clickable 'picture' Must use setImageURL to be set properly. If what's specified is simply the name, then the default renderers will look in the images directory for the appropriate icon.
button: Renders the transition as a button.
default behavior: Renders as a clickable button
Copyright 1999-2002 Jcorporate Ltd.
| Constructor Summary | |
Transition()
Default Constructor. |
|
Transition(String label,
Class controllerClass,
String controllerState)
Convenience method to allow for one line of code to construct a transition. |
|
Transition(String newState,
Controller myController)
Convenience method to transition to another state in this same controller. |
|
Transition(String newLabel,
String newObject)
Convenience constructor to create an action with a label and a controller already set. |
|
Transition(String name,
String label,
Class controllerClass,
String controllerState)
Convenience method to allow for one line of code to construct a transition. |
|
Transition(String newName,
String newLabel,
String newObject)
Convenience constructor to create an action with a label and a controller already set. |
|
| Method Summary | |
void |
addParam(String paramCode,
String paramValue)
Adds a parameter to a transition. |
Object |
clone()
Returns a copy of itself |
void |
enableReturnToSender(ControllerResponse response)
Call this method when the state/controller being transitioned to should return control back to the calling state once it has 'completed' successfully. |
static ControllerElement |
fromXML(org.w3c.dom.Node n)
Return a controller element based upon the xml fragment |
static Transition |
fromXML(String newTransition)
Return a Transition based upon the String based xml fragment |
String |
getControllerObject()
Return the name of the controller object that this Transition referred to. |
String |
getFullUrl()
Similar to getURL but also includes the context path. |
String |
getHTMLParamString()
Returns a hidden form field string that is safe in either the GET or POST case. |
String |
getMapping()
This function returns the mapping of the Struts action (including the .do part) but without a context prepended to the mapping. |
String |
getOwnerController()
Sets the controller that created this transition. |
String |
getParam(String paramCode)
Return the value for a specific parameter for this transition object. |
Hashtable |
getParams()
Return the hashtable of parameters for this transition object. |
String |
getParamString()
Return a string of the current params This is NOT URL encoded string. |
String |
getParamString(boolean includeControllerParameter)
|
HttpServletResponse |
getServletResponse()
Gets an underlying ServletResponse if it has been set either through setting the controller response or manually |
String |
getState()
Retrieve the currently set state |
String |
getTheUrl(boolean resolveControllerReference)
Internal use for retrieving the URL that this transition points to. |
String |
getUrl()
Returns a URL reference for this transition. |
boolean |
isExternalTransition(String runningController)
Returns True if the destination for this transition is a different controller from the one currently active. |
boolean |
isRecursiveTransition(String runningState,
String runningController)
Returns True if the destination for this transition is the same as the currently active state. |
boolean |
isReturnToSenderEnabled()
Return the return-to-sender flag. |
protected ControllerResponse |
newStateDispatch(ControllerRequest request)
This method invokes a new controller by dispatching to it rather than calling it directly. |
void |
redirectTransition(ControllerRequest request,
ControllerResponse response)
Transition to a new controller and state by issuing a Redirect
request to the browser. |
void |
setControllerObject(Class c)
Mor Typesafe way of setting the controller object. |
void |
setControllerObject(String newObject)
Set the Controller that this action referrs to |
void |
setControllerResponse(ControllerResponse newResponse)
Override of the normal setControllerResponse so that the HttpServletResponse is also set for this particular transition. |
void |
setOwnerController(String newController)
Sets the controller that created this transition. |
void |
setParams(Hashtable newParams)
Set this transition's parameters to the passed in collection. |
void |
setReturnToSenderParms(ControllerRequest newReturnToSenderRequest)
This method will take the request parameters that were passed to this state and will copy them into this transition's parameters. |
void |
setServletResponse(HttpServletResponse servletResponse)
Low level, sets the servlet response. |
void |
setState(String newState)
Sets the target state to transition to. |
FastStringBuffer |
toXML(FastStringBuffer stream)
Convert the object to an xml fragment. |
ControllerResponse |
transition(ControllerRequest req,
ControllerResponse res)
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 |
ControllerResponse |
transition(ControllerRequest req,
ControllerResponse res,
boolean clear)
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. |
| Methods inherited from class com.jcorporate.expresso.core.controller.ControllerElement |
addNested, allNested, fromXML, getAttribute, getAttributes, getAttributesOrNull, getContent, getContents, getControllerResponse, getDescription, getDisplayLength, getLabel, getLines, getName, getNested, getNested, getNestedCount, getNestedIterator, getNestedMap, getNestedOrNull, getParent, getTitle, getType, remove, removeNested, setAttribute, setDescription, setDisplayLength, setLabel, setLines, setName, setParent, setType |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Transition()
public Transition(String newState,
Controller myController)
newState - the new name of the state.myController - An instantiated Controller object. Use a ControllerFactory
to instantiate the controller if you must use this constructor.
public Transition(String newLabel,
String newObject)
newLabel - Label for the new actionnewObject - The name of the object this action referred to
public Transition(String newName,
String newLabel,
String newObject)
newName - Name of this Transition objectnewLabel - Label for the new actionnewObject - The name of the Controller object this action referred to
public Transition(String name,
String label,
Class controllerClass,
String controllerState)
name - The name of the transitionlabel - The label to use for the transitioncontrollerClass - The Class of the controller to usecontrollerState - The name of the controller's state.
public Transition(String label,
Class controllerClass,
String controllerState)
label - The label to use for the transitioncontrollerClass - The Class of the controller to usecontrollerState - The name of the controller's state.| Method Detail |
public void addParam(String paramCode,
String paramValue)
paramCode - The code name of the parameterparamValue - The value for the paramterpublic void setState(String newState)
newState - java.lang.Stringpublic String getState()
public Object clone()
throws CloneNotSupportedException
clone in class ControllerElementTransition object.
CloneNotSupportedException - as required by the method
signature.
public void enableReturnToSender(ControllerResponse response)
throws ControllerException
response - the ControllerResponse object
ControllerException - upon errorpublic boolean isExternalTransition(String runningController)
runningController - the name of the controller we're currently in.
Usually you would
use this.getClass().getName() within your own controller as
a parameter.
public String getControllerObject()
public String getOwnerController()
public String getParam(String paramCode)
paramCode - The code (name) of the parameter
public Hashtable getParams()
public String getParamString(boolean includeControllerParameter)
public String getParamString()
protected ControllerResponse newStateDispatch(ControllerRequest request)
throws ControllerException,
NonHandleableException
request - the ControllerRequest Object
ControllerResponse object
ControllerException
NonHandleableException
public boolean isRecursiveTransition(String runningState,
String runningController)
runningState - the current staterunningController - the current controller
public boolean isReturnToSenderEnabled()
booleanpublic String getHTMLParamString()
public void setControllerObject(String newObject)
newObject - Name of the Controller object that this Transition refers topublic void setControllerObject(Class c)
Transition t = new Transition();
t.setControllerObject(com.jcorporate.expresso.services.Status.class);
c - the class of the controller object to add.public void setOwnerController(String newController)
newController - the classname of the new controllerpublic void setParams(Hashtable newParams)
newParams - the new parameters in bulkpublic void setReturnToSenderParms(ControllerRequest newReturnToSenderRequest)
newReturnToSenderRequest - The ControllerRequest objectpublic FastStringBuffer toXML(FastStringBuffer stream)
toXML in class ControllerElementstream - an instantiated FastStringBuffer to which we append to.
public static Transition fromXML(String newTransition)
throws ControllerException
newTransition - an xml fragment
ControllerException - upon error
public static ControllerElement fromXML(org.w3c.dom.Node n)
throws ControllerException
n - a DOM Node object
ControllerException - upon error
public String getTheUrl(boolean resolveControllerReference)
throws ControllerException
resolveControllerReference - should the controller be resolved to
a mapping or should it just be the request path with a controler equals
parameter. True if you want the URL mapped to a .do mapping.
ControllerException - if there is an error or there is no controller
response object available to help resoolve the reference.
public String getUrl()
throws ControllerException
ControllerException - upon error
public String getFullUrl()
throws ControllerException
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" param only if the destination controller is different than the controller of the ControllerResponse (if the response is known). For a guaranteed controller param,
ControllerException - upon error.getTheUrl(boolean)
public String getMapping()
throws ControllerException
ControllerException
public ControllerResponse transition(ControllerRequest req,
ControllerResponse res)
throws ControllerException,
NonHandleableException
req - The ControllerRequest object handed to you by the frameworkres - the ControllerResponse object handed to you by the framework
ControllerException - upon error
NonHandleableException - upon fatal error
public void redirectTransition(ControllerRequest request,
ControllerResponse response)
throws ControllerException
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.
request - The ControllerRequest object handed to you by the frameworkresponse - the ControllerResponse object handed to you by the framework
ControllerException
public ControllerResponse transition(ControllerRequest req,
ControllerResponse res,
boolean clear)
throws ControllerException,
NonHandleableException
req - The ControllerRequest object handed to you by the frameworkres - the ControllerResponse object handed to you by the frameworkclear - True clears the response object before adding the outputs
from the called controller?
ControllerException - upon error
NonHandleableException - upon fatal errorand response.getFormCache(paramName) to retrieve them,
ControllerResponse.getFormCache(String)public HttpServletResponse getServletResponse()
public void setServletResponse(HttpServletResponse servletResponse)
servletResponse - a servlet response object for encoding URLspublic void setControllerResponse(ControllerResponse newResponse)
setControllerResponse in class ControllerElementnewResponse - the controllerResponse to set.
|
Expresso 5-5-0 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||