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 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_INNER_HEIGHT;
023 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_INNER_WIDTH;
024 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_HEIGHT;
025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LAYOUT_WIDTH;
026 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_DEFAULT_LAYOUT;
027
028 import javax.faces.component.UIComponent;
029 import javax.faces.context.FacesContext;
030
031 public class UIDefaultLayout extends UILayout {
032 private static final Log LOG = LogFactory.getLog(UIDefaultLayout.class);
033
034 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.DefaultLayout";
035 public static final String COMPONENT_FAMILY = "org.apache.myfaces.tobago.Layout";
036
037
038 private static UIDefaultLayout instance;
039
040 public static synchronized UIDefaultLayout getInstance() {
041 if (instance == null) {
042 instance = (UIDefaultLayout)
043 ComponentUtil.createComponent(COMPONENT_TYPE, RENDERER_TYPE_DEFAULT_LAYOUT, "UIDefaultLayout");
044 }
045 return instance;
046 }
047
048 public void layoutBegin(FacesContext facesContext, UIComponent component) {
049 super.layoutBegin(facesContext, component);
050 //TODO why is this needed?
051 for (Object child : component.getChildren()) {
052 ((UIComponent) child).getAttributes().remove(ATTR_INNER_WIDTH);
053 ((UIComponent) child).getAttributes().remove(ATTR_INNER_HEIGHT);
054 ((UIComponent) child).getAttributes().remove(ATTR_LAYOUT_WIDTH);
055 ((UIComponent) child).getAttributes().remove(ATTR_LAYOUT_HEIGHT);
056 }
057 }
058
059 public String getFamily() {
060 return COMPONENT_FAMILY;
061 }
062
063 }