001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.component;
021
022 import javax.faces.context.FacesContext;
023 import javax.faces.el.ValueBinding;
024
025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
026
027 /*
028 * Date: 10.02.2006
029 * Time: 19:13:51
030 */
031 public class UIHiddenInput extends javax.faces.component.UIInput {
032
033 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.HiddenInput";
034
035 private Boolean disabled;
036
037 public boolean isDisabled() {
038 if (disabled != null) {
039 return disabled;
040 }
041 ValueBinding vb = getValueBinding(ATTR_DISABLED);
042 if (vb != null) {
043 return (Boolean.TRUE.equals(vb.getValue(getFacesContext())));
044 } else {
045 return false;
046 }
047 }
048
049 public void setDisabled(boolean disabled) {
050 this.disabled = disabled;
051 }
052
053 public void restoreState(FacesContext context, Object state) {
054 Object[] values = (Object[]) state;
055 super.restoreState(context, values[0]);
056 disabled = (Boolean) values[1];
057 }
058
059 public Object saveState(FacesContext context) {
060 Object[] values = new Object[2];
061 values[0] = super.saveState(context);
062 values[1] = disabled;
063 return values;
064 }
065 }