1 /*
2 * $Id: ProcessValidationsInterceptor.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 * Processes validations on the component tree
29 */
30 public class ProcessValidationsInterceptor extends FacesInterceptor {
31
32 private static final long serialVersionUID = 8785236570688278147L;
33
34 /***
35 * Process Validations (JSF.2.2.3)
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 processValidations");
48
49 informPhaseListenersBefore(facesContext, PhaseId.PROCESS_VALIDATIONS);
50
51 try {
52 if (isResponseComplete(facesContext, "processValidations", true)) {
53 // have to return right away
54 return true;
55 }
56 if (shouldRenderResponse(facesContext, "processValidations", true)) {
57 skipFurtherProcessing = true;
58 }
59
60 facesContext.getViewRoot().processValidators(facesContext);
61 } finally {
62 informPhaseListenersAfter(facesContext, PhaseId.PROCESS_VALIDATIONS);
63 }
64
65 if (isResponseComplete(facesContext, "processValidations", false)
66 || shouldRenderResponse(facesContext, "processValidations",
67 false)) {
68 // since this phase is completed we don't need to return right away
69 // even if the response is completed
70 skipFurtherProcessing = true;
71 }
72
73 if (!skipFurtherProcessing && log.isTraceEnabled())
74 log.trace("exiting processValidations");
75 return skipFurtherProcessing;
76 }
77 }