View Javadoc

1   /*
2    * $Id: ApplyRequestValuesInterceptor.java 440597 2006-09-06 03:34:39Z wsmoak $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.jsf;
19  
20  import javax.faces.FacesException;
21  import javax.faces.context.FacesContext;
22  import javax.faces.event.PhaseId;
23  
24  /***
25   * Applies the request values to the component tree
26   */
27  public class ApplyRequestValuesInterceptor extends FacesInterceptor {
28  
29      private static final long serialVersionUID = -1471180154211835323L;
30  
31      /***
32       * Apply Request Values (JSF.2.2.2)
33       * 
34       * @param viewId
35       *            The view id
36       * @param facesContext
37       *            The faces context
38       * @return true, if response is complete
39       */
40      protected boolean executePhase(String viewId, FacesContext facesContext)
41              throws FacesException {
42          boolean skipFurtherProcessing = false;
43          if (log.isTraceEnabled())
44              log.trace("entering applyRequestValues");
45  
46          informPhaseListenersBefore(facesContext, PhaseId.APPLY_REQUEST_VALUES);
47  
48          try {
49              if (isResponseComplete(facesContext, "applyRequestValues", true)) {
50                  // have to return right away
51                  return true;
52              }
53              if (shouldRenderResponse(facesContext, "applyRequestValues", true)) {
54                  skipFurtherProcessing = true;
55              }
56  
57              facesContext.getViewRoot().processDecodes(facesContext);
58          } finally {
59              informPhaseListenersAfter(facesContext,
60                      PhaseId.APPLY_REQUEST_VALUES);
61          }
62  
63          if (isResponseComplete(facesContext, "applyRequestValues", false)
64                  || shouldRenderResponse(facesContext, "applyRequestValues",
65                          false)) {
66              // since this phase is completed we don't need to return right away
67              // even if the response is completed
68              skipFurtherProcessing = true;
69          }
70  
71          if (!skipFurtherProcessing && log.isTraceEnabled())
72              log.trace("exiting applyRequestValues");
73          return skipFurtherProcessing;
74      }
75  }