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 link element.
040      * UIComponent class, generated from template {@code component1.2.stg} with class
041      * {@link org.apache.myfaces.tobago.internal.taglib.component.LinkTagDeclaration}.
042     */
043    public class UILink
044        extends UICommand implements UILinkCommand {
045    
046      public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Link";
047    
048      private java.lang.Character accessKey;
049      private java.lang.String labelWithAccessKey;
050      private java.lang.Integer tabIndex;
051      private java.lang.String tip;
052      private java.lang.Boolean inline;
053      private java.lang.Boolean jsfResource;
054      private java.lang.Boolean transition;
055      private java.lang.String image;
056      private java.lang.String label;
057      private java.lang.Boolean immediate;
058      private java.lang.Boolean disabled;
059    
060    
061      /**
062      Deprecated! Has not longer any function.
063    
064      @deprecated*/
065      @Deprecated
066      public java.lang.Character getAccessKey() {
067        if (accessKey != null) {
068          return accessKey;
069        }
070        ValueExpression ve = getValueExpression("accessKey");
071        if (ve != null) {
072          try {
073            return (java.lang.Character) ve.getValue(getFacesContext().getELContext());
074          } catch (ELException e) {
075                      throw new FacesException(e);
076              }
077        }
078        return null;
079      }
080    
081      @Deprecated
082      public void setAccessKey(java.lang.Character accessKey) {
083        this.accessKey = accessKey;
084      }
085    
086      /**
087      Deprecated! Use 'label' instead.
088       Text value to display as label.
089       If text contains an underscore the next character overwrites 'accesskey'.
090    
091      @deprecated*/
092      @Deprecated
093      public java.lang.String getLabelWithAccessKey() {
094        if (labelWithAccessKey != null) {
095          return labelWithAccessKey;
096        }
097        ValueExpression ve = getValueExpression("labelWithAccessKey");
098        if (ve != null) {
099          try {
100            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
101          } catch (ELException e) {
102                      throw new FacesException(e);
103              }
104        }
105        return null;
106      }
107    
108      @Deprecated
109      public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
110        this.labelWithAccessKey = labelWithAccessKey;
111      }
112    
113      /**
114      Controls the navigation of the focus through the
115       input controls on a page with the Tab-Key.
116       The navigation starts from the element with
117       the lowest tabIndex value to the element with the highest value.
118       Elements that have identical tabIndex values should be navigated
119       in the order they appear in the character stream
120       Elements that are disabled or with a negative tabIndex
121       do not participate in the tabbing order.
122    
123      */
124      public java.lang.Integer getTabIndex() {
125        if (tabIndex != null) {
126          return tabIndex;
127        }
128        ValueExpression ve = getValueExpression("tabIndex");
129        if (ve != null) {
130          try {
131            Number number = (Number) ve.getValue(getFacesContext().getELContext());
132            if (number != null) {
133              return number.intValue();
134            }
135          } catch (ELException e) {
136                      throw new FacesException(e);
137              }
138        }
139        return null;
140      }
141    
142      public void setTabIndex(java.lang.Integer tabIndex) {
143        this.tabIndex = tabIndex;
144      }
145    
146      /**
147      Text value to display as tooltip.
148    
149      */
150      public java.lang.String getTip() {
151        if (tip != null) {
152          return tip;
153        }
154        ValueExpression ve = getValueExpression("tip");
155        if (ve != null) {
156          try {
157            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
158          } catch (ELException e) {
159                      throw new FacesException(e);
160              }
161        }
162        return null;
163      }
164    
165      public void setTip(java.lang.String tip) {
166        this.tip = tip;
167      }
168    
169      /**
170      Flag indicating this component should rendered as an inline element.
171      <br />Default: <code>false</code>
172      */
173      public boolean isInline() {
174        if (inline != null) {
175          return inline;
176        }
177        ValueExpression ve = getValueExpression("inline");
178        if (ve != null) {
179          try {
180            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
181            if (bool != null) {
182              return bool;
183            }
184          } catch (ELException e) {
185                      throw new FacesException(e);
186              }
187        }
188        return false;
189      }
190    
191      public void setInline(boolean inline) {
192        this.inline = inline;
193      }
194    
195      /**
196      Flag indicating that the resource referenced by the resource attribute is a jsf resource.
197       That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
198       /faces/*). Default is false.
199      <br />Default: <code>false</code>
200      */
201      public boolean isJsfResource() {
202        if (jsfResource != null) {
203          return jsfResource;
204        }
205        ValueExpression ve = getValueExpression("jsfResource");
206        if (ve != null) {
207          try {
208            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
209            if (bool != null) {
210              return bool;
211            }
212          } catch (ELException e) {
213                      throw new FacesException(e);
214              }
215        }
216        return false;
217      }
218    
219      public void setJsfResource(boolean jsfResource) {
220        this.jsfResource = jsfResource;
221      }
222    
223      /**
224      Specify, if the command calls an JSF-Action.
225       Useful to switch off the Double-Submit-Check and Waiting-Behavior.
226      <br />Default: <code>true</code>
227      */
228      public boolean isTransition() {
229        if (transition != null) {
230          return transition;
231        }
232        ValueExpression ve = getValueExpression("transition");
233        if (ve != null) {
234          try {
235            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
236            if (bool != null) {
237              return bool;
238            }
239          } catch (ELException e) {
240                      throw new FacesException(e);
241              }
242        }
243        return true;
244      }
245    
246      public void setTransition(boolean transition) {
247        this.transition = transition;
248      }
249    
250      /**
251      Url to an image to display.
252    
253      */
254      public java.lang.String getImage() {
255        if (image != null) {
256          return image;
257        }
258        ValueExpression ve = getValueExpression("image");
259        if (ve != null) {
260          try {
261            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
262          } catch (ELException e) {
263                      throw new FacesException(e);
264              }
265        }
266        return null;
267      }
268    
269      public void setImage(java.lang.String image) {
270        this.image = image;
271      }
272    
273      /**
274      Text value to display as label.
275       If text contains an underscore the next character is used as accesskey.
276    
277      */
278      public java.lang.String getLabel() {
279        if (label != null) {
280          return label;
281        }
282        ValueExpression ve = getValueExpression("label");
283        if (ve != null) {
284          try {
285            return (java.lang.String) ve.getValue(getFacesContext().getELContext());
286          } catch (ELException e) {
287                      throw new FacesException(e);
288              }
289        }
290        return null;
291      }
292    
293      public void setLabel(java.lang.String label) {
294        this.label = label;
295      }
296    
297      /**
298      Flag indicating that, if this component is activated by the user,
299       notifications should be delivered to interested listeners and actions
300       immediately (that is, during Apply Request Values phase) rather than
301       waiting until Invoke Application phase.
302      <br />Default: <code>false</code>
303      */
304      public boolean isImmediate() {
305        if (immediate != null) {
306          return immediate;
307        }
308        ValueExpression ve = getValueExpression("immediate");
309        if (ve != null) {
310          try {
311            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
312            if (bool != null) {
313              return bool;
314            }
315          } catch (ELException e) {
316                      throw new FacesException(e);
317              }
318        }
319        return false;
320      }
321    
322      public void setImmediate(boolean immediate) {
323        this.immediate = immediate;
324      }
325    
326      /**
327      Flag indicating that this element is disabled.
328      <br />Default: <code>false</code>
329      */
330      public boolean isDisabled() {
331        if (disabled != null) {
332          return disabled;
333        }
334        ValueExpression ve = getValueExpression("disabled");
335        if (ve != null) {
336          try {
337            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
338            if (bool != null) {
339              return bool;
340            }
341          } catch (ELException e) {
342                      throw new FacesException(e);
343              }
344        }
345        return false;
346      }
347    
348      public void setDisabled(boolean disabled) {
349        this.disabled = disabled;
350      }
351    
352      public void restoreState(FacesContext context, Object componentState) {
353        Object[] values = (Object[]) componentState;
354        super.restoreState(context, values[0]);
355        accessKey = (java.lang.Character) values[1];
356        labelWithAccessKey = (java.lang.String) values[2];
357        tabIndex = (java.lang.Integer) values[3];
358        tip = (java.lang.String) values[4];
359        inline = (java.lang.Boolean) values[5];
360        jsfResource = (java.lang.Boolean) values[6];
361        transition = (java.lang.Boolean) values[7];
362        image = (java.lang.String) values[8];
363        label = (java.lang.String) values[9];
364        immediate = (java.lang.Boolean) values[10];
365        disabled = (java.lang.Boolean) values[11];
366      }
367    
368      public Object saveState(FacesContext context) {
369        Object[] values = new Object[12];
370        values[0] = super.saveState(context);
371        values[1] = accessKey;
372        values[2] = labelWithAccessKey;
373        values[3] = tabIndex;
374        values[4] = tip;
375        values[5] = inline;
376        values[6] = jsfResource;
377        values[7] = transition;
378        values[8] = image;
379        values[9] = label;
380        values[10] = immediate;
381        values[11] = disabled;
382        return values;
383      }
384    
385    
386    }