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.context.FacesContext;
023    import org.apache.commons.lang.ArrayUtils;
024    import org.apache.commons.lang.StringUtils;
025    import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression;
026    import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding;
027    import org.apache.myfaces.tobago.internal.util.Deprecation;
028    import org.apache.myfaces.tobago.renderkit.MarginValues;
029    import org.apache.myfaces.tobago.renderkit.SpacingValues;
030    import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
031    import javax.el.ELException;
032    import javax.faces.FacesException;
033    import java.util.ArrayList;
034    import java.util.List;
035    import javax.el.MethodExpression;
036    import javax.el.ValueExpression;
037    
038    /** 
039     Renders a menu item.
040      <p>
041      Please use menuCommand instead!
042      * UIComponent class, generated from template {@code component1.2.stg} with class
043      * {@link org.apache.myfaces.tobago.internal.taglib.component.MenuItemTagDeclaration}.
044       @deprecated
045     */
046    @Deprecated
047    public class UIMenuItem
048        extends UIMenuCommand  {
049    
050      public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.MenuItem";
051    
052      private java.lang.Boolean jsfResource;
053      private java.lang.Boolean transition;
054      private java.lang.Boolean immediate;
055      private java.lang.Boolean disabled;
056    
057    
058      /**
059      Flag indicating that the resource referenced by the resource attribute is a jsf resource.
060       That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
061       /faces/*). Default is false.
062      <br />Default: <code>false</code>
063      */
064      public boolean isJsfResource() {
065        if (jsfResource != null) {
066          return jsfResource;
067        }
068        ValueExpression ve = getValueExpression("jsfResource");
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 false;
080      }
081    
082      public void setJsfResource(boolean jsfResource) {
083        this.jsfResource = jsfResource;
084      }
085    
086      /**
087      Specify, if the command calls an JSF-Action.
088       Useful to switch off the Double-Submit-Check and Waiting-Behavior.
089      <br />Default: <code>true</code>
090      */
091      public boolean isTransition() {
092        if (transition != null) {
093          return transition;
094        }
095        ValueExpression ve = getValueExpression("transition");
096        if (ve != null) {
097          try {
098            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
099            if (bool != null) {
100              return bool;
101            }
102          } catch (ELException e) {
103                      throw new FacesException(e);
104              }
105        }
106        return true;
107      }
108    
109      public void setTransition(boolean transition) {
110        this.transition = transition;
111      }
112    
113      /**
114      Flag indicating that, if this component is activated by the user,
115       notifications should be delivered to interested listeners and actions
116       immediately (that is, during Apply Request Values phase) rather than
117       waiting until Invoke Application phase.
118      <br />Default: <code>false</code>
119      */
120      public boolean isImmediate() {
121        if (immediate != null) {
122          return immediate;
123        }
124        ValueExpression ve = getValueExpression("immediate");
125        if (ve != null) {
126          try {
127            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
128            if (bool != null) {
129              return bool;
130            }
131          } catch (ELException e) {
132                      throw new FacesException(e);
133              }
134        }
135        return false;
136      }
137    
138      public void setImmediate(boolean immediate) {
139        this.immediate = immediate;
140      }
141    
142      /**
143      Flag indicating that this element is disabled.
144      <br />Default: <code>false</code>
145      */
146      public boolean isDisabled() {
147        if (disabled != null) {
148          return disabled;
149        }
150        ValueExpression ve = getValueExpression("disabled");
151        if (ve != null) {
152          try {
153            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
154            if (bool != null) {
155              return bool;
156            }
157          } catch (ELException e) {
158                      throw new FacesException(e);
159              }
160        }
161        return false;
162      }
163    
164      public void setDisabled(boolean disabled) {
165        this.disabled = disabled;
166      }
167    
168      public void restoreState(FacesContext context, Object componentState) {
169        Object[] values = (Object[]) componentState;
170        super.restoreState(context, values[0]);
171        jsfResource = (java.lang.Boolean) values[1];
172        transition = (java.lang.Boolean) values[2];
173        immediate = (java.lang.Boolean) values[3];
174        disabled = (java.lang.Boolean) values[4];
175      }
176    
177      public Object saveState(FacesContext context) {
178        Object[] values = new Object[5];
179        values[0] = super.saveState(context);
180        values[1] = jsfResource;
181        values[2] = transition;
182        values[3] = immediate;
183        values[4] = disabled;
184        return values;
185      }
186    
187    
188    }