View Javadoc

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