001    // ---------- Attention: Generated code, please do not modify! -----------  
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    package org.apache.myfaces.tobago.component;
021    
022    import javax.faces.component.UIComponentBase;
023    import javax.faces.context.FacesContext;
024    import org.apache.commons.lang.ArrayUtils;
025    import org.apache.commons.lang.StringUtils;
026    import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression;
027    import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding;
028    import org.apache.myfaces.tobago.internal.util.Deprecation;
029    import org.apache.myfaces.tobago.renderkit.MarginValues;
030    import org.apache.myfaces.tobago.renderkit.SpacingValues;
031    import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
032    import javax.el.ELException;
033    import javax.faces.FacesException;
034    import java.util.ArrayList;
035    import java.util.List;
036    import javax.el.MethodExpression;
037    import javax.el.ValueExpression;
038    
039    /** 
040     Update the parent component
041      * UIComponent class, generated from template {@code component1.2.stg} with class
042      * {@link org.apache.myfaces.tobago.internal.taglib.component.ReloadTagDeclaration}.
043     */
044    public class UIReload
045        extends UIComponentBase  {
046    
047      public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Reload";
048    
049      public static final String COMPONENT_FAMILY = "org.apache.myfaces.tobago.Reload";
050    
051      private java.lang.Boolean update;
052      private java.lang.Boolean immediate;
053      private java.lang.Integer frequency;
054    
055      public String getFamily() {
056        return COMPONENT_FAMILY;
057      }
058    
059    
060      /**
061      Is update required.
062      <br />Default: <code>true</code>
063      */
064      public boolean isUpdate() {
065        if (update != null) {
066          return update;
067        }
068        ValueExpression ve = getValueExpression("update");
069        if (ve != null) {
070          try {
071            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
072            if (bool != null) {
073              return bool;
074            }
075          } catch (ELException e) {
076                      throw new FacesException(e);
077              }
078        }
079        return true;
080      }
081    
082      public void setUpdate(boolean update) {
083        this.update = update;
084      }
085    
086      /**
087      Flag indicating that
088       the update check should be performed
089       immediately (that is, during Apply Request Values phase) rather than
090       waiting until Render Response phase.
091      <br />Default: <code>true</code>
092      */
093      public boolean isImmediate() {
094        if (immediate != null) {
095          return immediate;
096        }
097        ValueExpression ve = getValueExpression("immediate");
098        if (ve != null) {
099          try {
100            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
101            if (bool != null) {
102              return bool;
103            }
104          } catch (ELException e) {
105                      throw new FacesException(e);
106              }
107        }
108        return true;
109      }
110    
111      public void setImmediate(boolean immediate) {
112        this.immediate = immediate;
113      }
114    
115      /**
116      Time in milliseconds after which the parent component is automatically reloaded.
117      <br />Default: <code>5000</code>
118      */
119      public java.lang.Integer getFrequency() {
120        if (frequency != null) {
121          return frequency;
122        }
123        ValueExpression ve = getValueExpression("frequency");
124        if (ve != null) {
125          try {
126            Number number = (Number) ve.getValue(getFacesContext().getELContext());
127            if (number != null) {
128              return number.intValue();
129            }
130          } catch (ELException e) {
131                      throw new FacesException(e);
132              }
133        }
134        return 5000;
135      }
136    
137      public void setFrequency(java.lang.Integer frequency) {
138        this.frequency = frequency;
139      }
140    
141      public void restoreState(FacesContext context, Object componentState) {
142        Object[] values = (Object[]) componentState;
143        super.restoreState(context, values[0]);
144        update = (java.lang.Boolean) values[1];
145        immediate = (java.lang.Boolean) values[2];
146        frequency = (java.lang.Integer) values[3];
147      }
148    
149      public Object saveState(FacesContext context) {
150        Object[] values = new Object[4];
151        values[0] = super.saveState(context);
152        values[1] = update;
153        values[2] = immediate;
154        values[3] = frequency;
155        return values;
156      }
157    
158    
159    }