001 package org.apache.myfaces.tobago.taglib.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_IMMEDIATE;
023 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTED_INDEX;
024 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SWITCH_TYPE;
025 import org.apache.myfaces.tobago.component.ComponentUtil;
026 import org.apache.myfaces.tobago.component.UITabGroup;
027 import static org.apache.myfaces.tobago.component.UITabGroup.SWITCH_TYPE_CLIENT;
028 import static org.apache.myfaces.tobago.component.UITabGroup.SWITCH_TYPE_RELOAD_PAGE;
029
030 import javax.faces.component.UIComponent;
031
032 public class TabGroupTag extends TobagoTag
033 implements TabGroupTagDeclaration {
034
035 private static final Log LOG = LogFactory.getLog(TabGroupTag.class);
036
037 private String selectedIndex;
038 private String switchType;
039 private String immediate;
040 private String state;
041
042 @Override
043 public String getComponentType() {
044 return UITabGroup.COMPONENT_TYPE;
045 }
046
047 @Override
048 protected void setProperties(UIComponent component) {
049 super.setProperties(component);
050 ComponentUtil.setIntegerProperty(component, ATTR_SELECTED_INDEX, selectedIndex);
051 ComponentUtil.setIntegerProperty(component, ATTR_SELECTED_INDEX, state);
052 ComponentUtil.setStringProperty(component, ATTR_SWITCH_TYPE, switchType);
053 ComponentUtil.setBooleanProperty(component, ATTR_IMMEDIATE, immediate);
054 }
055
056 @Override
057 public void release() {
058 super.release();
059 state = null;
060 switchType = null;
061 immediate = null;
062 selectedIndex = null;
063 }
064
065 public void setServerside(String serverside) {
066 LOG.warn("Attribute 'serverside' is deprecated! Use 'switchType' instead.");
067 this.switchType = Boolean.valueOf(serverside)
068 ? SWITCH_TYPE_RELOAD_PAGE : SWITCH_TYPE_CLIENT;
069 }
070
071 public void setState(String state) {
072 this.state = state;
073 }
074
075 public void setSelectedIndex(String selectedIndex) {
076 this.selectedIndex = selectedIndex;
077 }
078
079 public void setSwitchType(String switchType) {
080 this.switchType = switchType;
081 }
082
083 public void setImmediate(String immediate) {
084 this.immediate = immediate;
085 }
086 }
087