View Javadoc

1   /*
2    * $Id: ApplyRequestValuesInterceptor.java 471756 2006-11-06 15:01:43Z husted $
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  package org.apache.struts2.jsf;
22  
23  import javax.faces.FacesException;
24  import javax.faces.context.FacesContext;
25  import javax.faces.event.PhaseId;
26  
27  /***
28   * Applies the request values to the component tree
29   */
30  public class ApplyRequestValuesInterceptor extends FacesInterceptor {
31  
32      private static final long serialVersionUID = -1471180154211835323L;
33  
34      /***
35       * Apply Request Values (JSF.2.2.2)
36       *
37       * @param viewId
38       *            The view id
39       * @param facesContext
40       *            The faces context
41       * @return true, if response is complete
42       */
43      protected boolean executePhase(String viewId, FacesContext facesContext)
44              throws FacesException {
45          boolean skipFurtherProcessing = false;
46          if (log.isTraceEnabled())
47              log.trace("entering applyRequestValues");
48  
49          informPhaseListenersBefore(facesContext, PhaseId.APPLY_REQUEST_VALUES);
50  
51          try {
52              if (isResponseComplete(facesContext, "applyRequestValues", true)) {
53                  // have to return right away
54                  return true;
55              }
56              if (shouldRenderResponse(facesContext, "applyRequestValues", true)) {
57                  skipFurtherProcessing = true;
58              }
59  
60              facesContext.getViewRoot().processDecodes(facesContext);
61          } finally {
62              informPhaseListenersAfter(facesContext,
63                      PhaseId.APPLY_REQUEST_VALUES);
64          }
65  
66          if (isResponseComplete(facesContext, "applyRequestValues", false)
67                  || shouldRenderResponse(facesContext, "applyRequestValues",
68                          false)) {
69              // since this phase is completed we don't need to return right away
70              // even if the response is completed
71              skipFurtherProcessing = true;
72          }
73  
74          if (!skipFurtherProcessing && log.isTraceEnabled())
75              log.trace("exiting applyRequestValues");
76          return skipFurtherProcessing;
77      }
78  }