?? facestilesrequestprocessor.java
字號:
// Override default processing to provide logging
protected ActionForward processActionPerform(HttpServletRequest request,
HttpServletResponse response,
Action action,
ActionForm form,
ActionMapping mapping)
throws IOException, ServletException {
if (log.isTraceEnabled()) {
log.trace("Performing standard action perform");
}
ActionForward result =
super.processActionPerform(request, response, action,
form, mapping);
if (log.isDebugEnabled()) {
log.debug("Standard action perform returned " +
result.getPath() + " forward path");
}
return (result);
}
// Override default processing to provide logging
protected boolean processForward(HttpServletRequest request,
HttpServletResponse response,
ActionMapping mapping)
throws IOException, ServletException {
if (log.isTraceEnabled()) {
log.trace("Performing standard forward handling");
}
boolean result = super.processForward
(request, response, mapping);
if (log.isDebugEnabled()) {
log.debug("Standard forward handling returned " + result);
}
return (result);
}
// Override default processing to provide logging
protected void processForwardConfig(HttpServletRequest request,
HttpServletResponse response,
ForwardConfig forward)
throws IOException, ServletException {
if (log.isTraceEnabled()) {
log.trace("Performing standard forward config handling");
}
super.processForwardConfig(request, response, forward);
if (log.isDebugEnabled()) {
log.debug("Standard forward config handling completed");
}
}
// Override default processing to provide logging
protected boolean processInclude(HttpServletRequest request,
HttpServletResponse response,
ActionMapping mapping)
throws IOException, ServletException {
if (log.isTraceEnabled()) {
log.trace("Performing standard include handling");
}
boolean result = super.processInclude
(request, response, mapping);
if (log.isDebugEnabled()) {
log.debug("Standard include handling returned " + result);
}
return (result);
}
/**
* <p>Identify and return the path component (from the request URI for a
* non-Faces request, or from the form event for a Faces request)
* that we will use to select an ActionMapping to dispatch with.
* If no such path can be identified, create an error response and return
* <code>null</code>.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
*
* @exception IOException if an input/output error occurs
*/
protected String processPath(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
// Are we processing a Faces request?
ActionEvent event = (ActionEvent)
request.getAttribute(Constants.ACTION_EVENT_KEY);
// Handle non-Faces requests in the usual way
if (event == null) {
if (log.isTraceEnabled()) {
log.trace("Performing standard processPath() processing");
}
return (super.processPath(request, response));
}
// Calculate the path from the form name
UIComponent component = event.getComponent();
if (log.isTraceEnabled()) {
log.trace("Locating form parent for command component " +
event.getComponent());
}
while (!(component instanceof FormComponent)) {
component = component.getParent();
if (component == null) {
log.warn("Command component was not nested in a Struts form!");
return (null);
}
}
if (log.isTraceEnabled()) {
log.trace("Returning selected path of " +
((FormComponent) component).getAction());
}
return (((FormComponent) component).getAction());
}
/**
* <p>Populate the properties of the specified <code>ActionForm</code>
* instance from the request parameters included with this request,
* <strong>IF</strong> this is a non-Faces request. For a Faces request,
* this will have already been done by the <em>Update Model Values</em>
* phase of the request processing lifecycle, so all we have to do is
* recognize whether the request was cancelled or not.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param form The ActionForm instance we are populating
* @param mapping The ActionMapping we are using
*
* @exception ServletException if thrown by RequestUtils.populate()
*/
protected void processPopulate(HttpServletRequest request,
HttpServletResponse response,
ActionForm form,
ActionMapping mapping)
throws ServletException {
// Are we processing a Faces request?
ActionEvent event = (ActionEvent)
request.getAttribute(Constants.ACTION_EVENT_KEY);
// Handle non-Faces requests in the usual way
if (event == null) {
if (log.isTraceEnabled()) {
log.trace("Performing standard processPopulate() processing");
}
super.processPopulate(request, response, form, mapping);
return;
}
// Faces Requests require no processing for form bean population
// so we need only check for the cancellation command name
if (log.isTraceEnabled()) {
log.trace("Faces request, so no processPopulate() processing");
}
UIComponent source = event.getComponent();
if (source instanceof UICommand) {
UICommand command = (UICommand) source;
if ("cancel".equals(((UICommand) source).getId())) {
if (log.isTraceEnabled()) {
log.trace("Faces request with cancel button pressed");
}
request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE);
}
}
}
// Override default processing to provide logging
protected boolean processValidate(HttpServletRequest request,
HttpServletResponse response,
ActionForm form,
ActionMapping mapping)
throws IOException, ServletException {
if (log.isTraceEnabled()) {
log.trace("Performing standard validation");
}
boolean result = super.processValidate
(request, response, form, mapping);
if (log.isDebugEnabled()) {
log.debug("Standard validation processing returned " + result);
}
return (result);
}
// --------------------------------------------------------- Private Methods
/**
* <p>Return <code>true</code> if the specified context-relative URI
* specifies a request to be processed by the Struts controller servlet.</p>
*
* @param uri URI to be checked
*/
private boolean isStrutsRequest(String uri) {
int question = uri.indexOf("?");
if (question >= 0) {
uri = uri.substring(0, question);
}
String mapping = (String)
servlet.getServletContext().getAttribute(Globals.SERVLET_KEY);
if (mapping == null) {
return (false);
} else if (mapping.startsWith("*.")) {
return (uri.endsWith(mapping.substring(1)));
} else if (mapping.endsWith("/*")) {
return (uri.startsWith(mapping.substring(0, mapping.length() - 2)));
} else {
return (false);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -