|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.roscopeco.janno.views.AbstractViewDispatcher
org.roscopeco.janno.views.ScriptedActionDispatcher
public class ScriptedActionDispatcher
Attempts to dispatch to a specific set of context-relative URLs based on
predefined arrangements of the action path, name and result. As the name
implies, this is primarily intended to be used alongside scripted actions,
but it can in fact be used with both scripted and configured actions as
a more implicit alternative to the full URLMappingDispatcher.
ScriptedActionDispatcher you may supply
a List with the view file extensions to be tried, in
order. When searching for a view the dispatcher will try each of the
path/name/result combinations detailed below for each extension in the
order they're supplied (i.e. [each combination].jsp, then
[each combination].vm, and so on). A convienience constructor
is provided that will construct a single-element list for a String argument
when only a single extension is to be used.
Assume we have a ScriptedActionDispatcher dispatcher, to which
we supplied an extension list containing a single entry, jsp.
Given an action mapped (either by script location or configuration) to the
path /path/to/my and having the name action,
which returns the value result, this class would attempt to
dispatch to the following URLs in order:
/path/to/my_action_result.jsp/path/to/my_result.jsp/path/to/action_result.jsp/path/to/result.jsp/result.jsp
| Constructor Summary | |
|---|---|
ScriptedActionDispatcher()
Convienience constructor that uses a default set of extensions, namely .vm and .jsp, in that order. |
|
ScriptedActionDispatcher(List<String> extensions)
Create a new ScriptedActionDispatcher that will attempt to dispatch to each of the path/name/result combinations for each file extension in the supplied List. |
|
ScriptedActionDispatcher(String extension)
Convienience constructor for use with a single extension. |
|
ScriptedActionDispatcher(String[] extensions)
Convienience constructor for use with a String array of view extensions. |
|
| Method Summary | |
|---|---|
boolean |
dispatchView(ServletContext ctx,
HttpServletRequest req,
HttpServletResponse resp,
String actionPath,
String actionName,
String actionResult)
Attempt to dispatch an action-view through this dispatcher. This method checks each view path combination in turn, checking first if it exists, and then attempting to dispatch to it (forwarding or including as appropriate). |
protected List<String> |
viewsFor(String path,
String name,
String result)
Returns a List of context-relative URL specs that should be
tried by the dispatcher in order. |
| Methods inherited from class org.roscopeco.janno.views.AbstractViewDispatcher |
|---|
dispatchTo |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ScriptedActionDispatcher(List<String> extensions)
jsp and .jsp
are equal for the purposes of this method.
Although of little value, it is possible to create a dispatcher that won't
actually dispatch anything by passing in either an empty list or
null.
extensions - The List of String
URL extensions.public ScriptedActionDispatcher(String extension)
extension - The String extension for dispatched
views.public ScriptedActionDispatcher(String[] extensions)
extensions - An array of String containing the
view extensions. The same parameter rules apply as for the
ScriptedActionDispatcher(List) constructor.public ScriptedActionDispatcher()
.vm and .jsp, in that order. If you are
using JSP routinely it is highly recommended that
you call another constructor, since the ordering used by this one will
result in a lot of work on every request.
| Method Detail |
|---|
public boolean dispatchView(ServletContext ctx,
HttpServletRequest req,
HttpServletResponse resp,
String actionPath,
String actionName,
String actionResult)
throws IOException,
ServletException
ActionViewDispatcher for general information on the dispatch
process.
This method checks each view path combination in turn, checking first if
it exists, and then attempting to dispatch to it (forwarding or including
as appropriate).
dispatchView in interface ActionViewDispatcherdispatchView in class AbstractViewDispatcherctx - The ServletContext within which the view
request is to be processed.req - The HttpServletRequest representing
the user request.resp - The HttpServletResponse in use.actionPath - The path that was requested and resolved to the action.actionName - The name of the action method that was called.actionResult - The String result from the action.
true if the view was dispatched (even if an error
occured), or false if the view could not be mapped to
a view builder.
ServletException - if an error occurs during view processing.
IOException
protected List<String> viewsFor(String path,
String name,
String result)
List of context-relative URL specs that should be
tried by the dispatcher in order. This method is protected to
allow subclasses to easily affect the list of possible views.
For performance reasons this method is required to return a single List with
all possible view combinations for all of the supplied extensions.
path - The path to the action. This is the path from which the action
was loaded (scripts) or the key with which it was instantiated
(configured actions).name - The action name (the name of the method that was executed)result - The String result from the action.
List of String with all
the URL combinations that should be tried by this dispatcher for
a given action / result combination.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||