|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> [ controller overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jcorporate.expresso.core.controller
Class Transition

java.lang.Objectcom.jcorporate.expresso.core.controller.ControllerElement
com.jcorporate.expresso.core.controller.Transition
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class Transition
- extends ControllerElement
- implements java.lang.Cloneable, java.io.Serializable
- extends ControllerElement
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
| Field Summary | |
private java.lang.String |
cacheParamStringSansController
This is used to store a constructed parameter string to save on re-constructing multiple times. |
private java.lang.String |
cacheParamStringWithController
This is used to store a constructed parameter string to save on re-constructing multiple times. |
private java.lang.String |
controllerObject
The name of a controller object that handles this action |
private static org.apache.log4j.Logger |
log
|
private java.lang.String |
myState
|
private java.lang.String |
ownerObject
name of the controller object that created this transition |
private java.util.Hashtable |
params
The parameters to the controller object |
private boolean |
returnToSender
|
private javax.servlet.http.HttpServletResponse |
servletResponse
Used in place of ControllerResponse for URL encoding |
| Fields inherited from class com.jcorporate.expresso.core.controller.ControllerElement |
|
| Constructor Summary | |
Transition()
Default Constructor. |
|
Transition(java.lang.String label,
java.lang.Class controllerClass,
java.lang.String controllerState)
Convenience method to allow for one line of code to construct a transition. |
|
Transition(java.lang.String newState,
Controller myController)
Convenience method to transition to another state in this same controller. |
|
Transition(java.lang.String newLabel,
java.lang.String newObject)
Convenience constructor to create an action with a label and a controller already set. |
|
Transition(java.lang.String name,
java.lang.String label,
java.lang.Class controllerClass,
java.lang.String controllerState)
Convenience method to allow for one line of code to construct a transition. |
|
Transition(java.lang.String newName,
java.lang.String newLabel,
java.lang.String newObject)
Convenience constructor to create an action with a label and a controller already set. |
|
| Method Summary | |
private void |
addNonControllerParams(com.jcorporate.expresso.kernel.util.FastStringBuffer paramString)
|
void |
addParam(java.lang.String paramCode,
java.lang.String paramValue)
Adds a parameter to a transition. |
private void |
clearCache()
|
java.lang.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(java.lang.String newTransition)
Return a Transition based upon the String based xml fragment |
java.lang.String |
getControllerObject()
Return the name of the controller object that this Transition referred to. |
java.lang.String |
getFullUrl()
Similar to getURL but also includes the context path. |
java.lang.String |
getHTMLParamString()
Returns a hidden form field string that is safe in either the GET or POST case. |
java.lang.String |
getMapping()
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()
Sets the controller that created this transition. |
java.lang.String |
getParam(java.lang.String paramCode)
Return the value for a specific parameter for this transition object. |
java.util.Hashtable |
getParams()
Return the hashtable of parameters for this transition object. |
java.lang.String |
getParamString()
Return a string of the current params This is NOT URL encoded string. |
java.lang.String |
getParamString(boolean includeControllerParameter)
|
javax.servlet.http.HttpServletResponse |
getServletResponse()
Gets an underlying ServletResponse if it has been set either through setting the controller response or manually |
java.lang.String |
getState()
Retrieve the currently set state |
java.lang.String |
getTheUrl(boolean resolveControllerReference)
Internal use for retrieving the URL that this transition points to. |
java.lang.String |
getUrl()
Returns a URL reference for this transition. |
boolean |
isExternalTransition(java.lang.String runningController)
Returns True if the destination for this transition is a different controller from the one currently active. |
boolean |
isRecursiveTransition(java.lang.String runningState,
java.lang.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(java.lang.Class c)
Mor Typesafe way of setting the controller object. |
void |
setControllerObject(java.lang.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(java.lang.String newController)
Sets the controller that created this transition. |
void |
setParams(java.util.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(javax.servlet.http.HttpServletResponse servletResponse)
Low level, sets the servlet response. |
void |
setState(java.lang.String newState)
Sets the target state to transition to. |
com.jcorporate.expresso.kernel.util.FastStringBuffer |
toXML(com.jcorporate.expresso.kernel.util.FastStringBuffer stream)
Convert the object to an xml fragment. |
ControllerResponse |
transition(ControllerRequest req,
ControllerResponse res)
Run this transition - e.g. |
ControllerResponse |
transition(ControllerRequest req,
ControllerResponse res,
boolean clear)
Run this transition - e.g. |
| 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 |
| Field Detail |
log
private static org.apache.log4j.Logger log
ownerObject
private java.lang.String ownerObject
- name of the controller object that created this transition
controllerObject
private java.lang.String controllerObject
- The name of a controller object that handles this action
params
private java.util.Hashtable params
- The parameters to the controller object
myState
private java.lang.String myState
returnToSender
private boolean returnToSender
cacheParamStringSansController
private transient java.lang.String cacheParamStringSansController
- This is used to store a constructed parameter string to save on
re-constructing multiple times.
cacheParamStringWithController
private transient java.lang.String cacheParamStringWithController
- This is used to store a constructed parameter string to save on
re-constructing multiple times.
servletResponse
private transient javax.servlet.http.HttpServletResponse servletResponse
- Used in place of ControllerResponse for URL encoding
| Constructor Detail |
Transition
public Transition()
- Default Constructor. Normally you don't use this.
Transition
public Transition(java.lang.String newState, Controller myController)
- Convenience method to transition to another state in this same controller.
Transition
public Transition(java.lang.String newLabel, java.lang.String newObject)
- Convenience constructor to create an action with a label
and a controller already set.
Transition
public Transition(java.lang.String newName, java.lang.String newLabel, java.lang.String newObject)
- Convenience constructor to create an action with a label
and a controller already set.
Transition
public Transition(java.lang.String name, java.lang.String label, java.lang.Class controllerClass, java.lang.String controllerState)
- Convenience method to allow for one line of code to construct a transition.
Transition
public Transition(java.lang.String label, java.lang.Class controllerClass, java.lang.String controllerState)
- Convenience method to allow for one line of code to construct a transition.
The (internal) name of the transition will be the state name.
| Method Detail |
addParam
public void addParam(java.lang.String paramCode, java.lang.String paramValue)
- Adds a parameter to a transition. These parameters are meant to
be eventually consumed by the target controller via the request.getParameter()
method.
clearCache
private void clearCache()
setState
public void setState(java.lang.String newState)
- Sets the target state to transition to.
getState
public java.lang.String getState()
- Retrieve the currently set state
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Returns a copy of itself
- Overrides:
clonein classControllerElement
enableReturnToSender
public void enableReturnToSender(ControllerResponse response) throws ControllerException
- 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.
isExternalTransition
public boolean isExternalTransition(java.lang.String runningController)
- Returns True if the destination for this transition is a different
controller from the one currently active.
getControllerObject
public java.lang.String getControllerObject()
- 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)
getOwnerController
public java.lang.String getOwnerController()
- Sets the controller that created this transition. If controllerObject
equals owner controller, then no controller= parameter is generated.
getParam
public java.lang.String getParam(java.lang.String paramCode)
- Return the value for a specific parameter for this transition object.
getParams
public java.util.Hashtable getParams()
- Return the hashtable of parameters for this transition object.
These parameters are to be handed to the new controller
when the action is called.
getParamString
public java.lang.String getParamString(boolean includeControllerParameter)
addNonControllerParams
private void addNonControllerParams(com.jcorporate.expresso.kernel.util.FastStringBuffer paramString)
getParamString
public java.lang.String getParamString()
- Return a string of the current params This is NOT URL encoded string.
Use either getUrl() OR java.net.URLEncoder() to do this job.
newStateDispatch
protected ControllerResponse newStateDispatch(ControllerRequest request) throws ControllerException, NonHandleableException
- 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.
isRecursiveTransition
public boolean isRecursiveTransition(java.lang.String runningState, java.lang.String runningController)
- Returns True if the destination for this transition is the same as the
currently active state. Avoid infinite loop.
isReturnToSenderEnabled
public boolean isReturnToSenderEnabled()
- Return the return-to-sender flag.
getHTMLParamString
public java.lang.String getHTMLParamString()
- 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
setControllerObject
public void setControllerObject(java.lang.String newObject)
- Set the Controller that this action referrs to
setControllerObject
public void setControllerObject(java.lang.Class c)
- 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);
setOwnerController
public void setOwnerController(java.lang.String newController)
- Sets the controller that created this transition. If controllerObject
equals owner controller, then no controller= parameter is generated.
setParams
public void setParams(java.util.Hashtable newParams)
- Set this transition's parameters to the passed in collection.
setReturnToSenderParms
public 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. These parameters
will then be used when this state is reinvoked (return-to-sender) in order
to re-establish the parameter context.
toXML
public com.jcorporate.expresso.kernel.util.FastStringBuffer toXML(com.jcorporate.expresso.kernel.util.FastStringBuffer stream)
- Convert the object to an xml fragment.
- Overrides:
toXMLin classControllerElement
fromXML
public static Transition fromXML(java.lang.String newTransition) throws ControllerException
- Return a Transition based upon the String based xml fragment
fromXML
public static ControllerElement fromXML(org.w3c.dom.Node n) throws ControllerException
- Return a controller element based upon the xml fragment
getTheUrl
public java.lang.String getTheUrl(boolean resolveControllerReference) throws ControllerException
- Internal use for retrieving the URL that this transition points to.
getUrl
public java.lang.String getUrl() throws ControllerException
- Returns a URL reference for this transition. The URL does NOT include
the context path.
getFullUrl
public java.lang.String getFullUrl() throws ControllerException
- 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).
getMapping
public java.lang.String getMapping() throws ControllerException
- This function returns the mapping of the Struts action (including the
.do part) but without a context prepended to the mapping.
transition
public ControllerResponse transition(ControllerRequest req, ControllerResponse res) throws ControllerException, NonHandleableException
- 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
redirectTransition
public void redirectTransition(ControllerRequest request, ControllerResponse response) throws ControllerException
- Transition to a new controller and state by issuing a
Redirectrequest 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.
transition
public ControllerResponse transition(ControllerRequest req, ControllerResponse res, boolean clear) throws ControllerException, NonHandleableException
- 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(),
getServletResponse
public javax.servlet.http.HttpServletResponse getServletResponse()
- Gets an underlying ServletResponse if it has been set either through
setting the controller response or manually
setServletResponse
public void setServletResponse(javax.servlet.http.HttpServletResponse servletResponse)
- 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
setControllerResponse
public void setControllerResponse(ControllerResponse newResponse)
- Override of the normal setControllerResponse so that the HttpServletResponse
is also set for this particular transition.
- Overrides:
setControllerResponsein classControllerElement
|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> [ controller overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC