001 package org.apache.myfaces.tobago.component;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one or more
005 * contributor license agreements. See the NOTICE file distributed with
006 * this work for additional information regarding copyright ownership.
007 * The ASF licenses this file to You under the Apache License, Version 2.0
008 * (the "License"); you may not use this file except in compliance with
009 * the License. You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020 import org.apache.commons.logging.Log;
021 import org.apache.commons.logging.LogFactory;
022
023 import javax.faces.component.UIComponent;
024 import javax.faces.context.FacesContext;
025 import java.util.Iterator;
026
027 public class UIForm extends javax.faces.component.UIForm {
028
029 private static final Log LOG = LogFactory.getLog(UIForm.class);
030
031 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Form";
032 public static final String SUBMITTED_MARKER = COMPONENT_TYPE + ".InSubmitted";
033
034 public void processDecodes(FacesContext facesContext) {
035
036 // Process this component first
037 // to know the active actionId
038 // for the following childrend
039 decode(facesContext);
040
041 Iterator kids = getFacetsAndChildren();
042 while (kids.hasNext()) {
043 UIComponent kid = (UIComponent) kids.next();
044 kid.processDecodes(facesContext);
045 }
046 }
047
048 public void setSubmitted(boolean b) {
049 super.setSubmitted(b);
050
051 // set submitted for all subforms
052 for (UIForm subForm : ComponentUtil.findSubForms(this)) {
053 subForm.setSubmitted(b);
054 }
055 }
056
057 public void processValidators(FacesContext facesContext) {
058 // if we're not the submitted form, only process subforms.
059 if (LOG.isDebugEnabled()) {
060 LOG.debug("processValidators for form: " + getClientId(facesContext));
061 }
062 if (!isSubmitted()) {
063 for (UIForm subForm : ComponentUtil.findSubForms(this)) {
064 subForm.processValidators(facesContext);
065 }
066 } else {
067 // Process all facets and children of this component
068 Iterator kids = getFacetsAndChildren();
069 while (kids.hasNext()) {
070 UIComponent kid = (UIComponent) kids.next();
071 kid.processValidators(facesContext);
072 }
073 }
074 }
075
076 public void processUpdates(FacesContext facesContext) {
077 // if we're not the submitted form, only process subforms.
078 if (LOG.isDebugEnabled()) {
079 LOG.debug("processUpdates for form: " + getClientId(facesContext));
080 }
081 if (!isSubmitted()) {
082 for (UIForm subForm : ComponentUtil.findSubForms(this)) {
083 subForm.processUpdates(facesContext);
084 }
085 } else {
086 // Process all facets and children of this component
087 Iterator kids = getFacetsAndChildren();
088 while (kids.hasNext()) {
089 UIComponent kid = (UIComponent) kids.next();
090 kid.processUpdates(facesContext);
091 }
092 }
093 }
094 }