View Javadoc
1   // ---------- Attention: Generated code, please do not modify! -----------  
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.myfaces.tobago.component;
21  
22  import javax.faces.context.FacesContext;
23  import org.apache.myfaces.tobago.context.Markup;
24  import org.apache.myfaces.tobago.internal.component.AbstractUILink;
25  import org.apache.myfaces.tobago.renderkit.css.CustomClass;
26  import org.apache.myfaces.tobago.renderkit.css.Style;
27  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
28  import org.apache.myfaces.tobago.internal.util.StringUtils;
29  import org.apache.myfaces.tobago.internal.util.Deprecation;
30  import javax.el.ELException;
31  import javax.faces.FacesException;
32  import java.util.ArrayList;
33  import java.util.List;
34  import javax.el.MethodExpression;
35  import javax.el.ValueExpression;
36  
37  /** 
38   Renders a link element.
39    * UIComponent class, generated from template {@code component.stg} with class
40    * {@link org.apache.myfaces.tobago.internal.taglib.component.LinkTagDeclaration}.
41   */
42  public class UILink
43      extends AbstractUILink implements SupportsAccessKey, Visual {
44  
45    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Link";
46  
47    public static final String COMPONENT_FAMILY = "javax.faces.Command";
48  
49  
50    enum PropertyKeys {
51      image,
52      markup,
53      resource,
54      link,
55      tabIndex,
56      label,
57      transition,
58      target,
59      renderedPartially,
60      jsfResource,
61      accessKey,
62      customClass,
63      tip,
64      style,
65      omit,
66    }
67  
68    public String getFamily() {
69      return COMPONENT_FAMILY;
70    }
71  
72  
73    /**
74    Url to an image to display.
75  
76    */
77    public java.lang.String getImage() {
78      return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
79    }
80  
81    public void setImage(java.lang.String image) {
82      getStateHelper().put(PropertyKeys.image, image);
83    }
84  
85    public org.apache.myfaces.tobago.context.Markup getMarkup() {
86      Object object = getStateHelper().eval(PropertyKeys.markup);
87      if (object != null) {
88        return Markup.valueOf(object);
89      }
90      return null;
91    }
92  
93    public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
94      getStateHelper().put(PropertyKeys.markup, markup);
95    }
96  
97    /**
98    Link to an internal resource.
99     Resources will be processed by the resource management.
100    E. g. define help.html and it will be served help_es.html or help_de.html if available.
101    For JSF-Pages you have to set the jsfResource attribute.
102 
103   */
104   public java.lang.String getResource() {
105     return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
106   }
107 
108   public void setResource(java.lang.String resource) {
109     getStateHelper().put(PropertyKeys.resource, resource);
110   }
111 
112   /**
113   Link to an arbitrary URL, either an internal link or an external link.
114 
115    <dl>
116      <dt>internal absolute link</dt>
117      <dd>Starts with a slash '/' character. The context path will be added.
118          A session id will be added, if needed.</dd>
119      <dt>external link</dt>
120      <dd>Starts with protocol followed by a colon ':' character.
121          The link will not be modified.</dd>
122      <dt>internal relative link</dt>
123      <dd>Any other strings. A session id will be added, if needed.</dd>
124    </dl>
125 
126   */
127   public java.lang.String getLink() {
128     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
129   }
130 
131   public void setLink(java.lang.String link) {
132     getStateHelper().put(PropertyKeys.link, link);
133   }
134 
135   /**
136   Controls the navigation of the focus through the
137    input controls on a page with the Tab-Key.
138    The navigation starts from the element with
139    the lowest tabIndex value to the element with the highest value.
140    Elements that have identical tabIndex values should be navigated
141    in the order they appear in the character stream
142    Elements that are disabled or with a negative tabIndex
143    do not participate in the tabbing order.
144 
145   */
146   public java.lang.Integer getTabIndex() {
147     Number value  = (Number) getStateHelper().eval(PropertyKeys.tabIndex);
148     if (value != null) {
149       return value.intValue();
150     }
151     return null;
152   }
153 
154   public void setTabIndex(java.lang.Integer tabIndex) {
155     getStateHelper().put(PropertyKeys.tabIndex, tabIndex);
156   }
157 
158   /**
159   Text value to display as label.
160    If text contains an underscore the next character is used as accesskey (if configured so and possible).
161 
162   */
163   public java.lang.String getLabel() {
164     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
165   }
166 
167   public void setLabel(java.lang.String label) {
168     getStateHelper().put(PropertyKeys.label, label);
169   }
170 
171   /**
172   Specify, if the command calls an JSF-Action.
173    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
174   <br>Default: <code>true</code>
175   */
176   public boolean isTransition() {
177     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
178     if (bool != null) {
179       return bool;
180     }
181     return true;
182   }
183 
184   public void setTransition(boolean transition) {
185     getStateHelper().put(PropertyKeys.transition, transition);
186   }
187 
188   /**
189   Name of a frame where the resource retrieved via this hyperlink is to be
190    displayed.
191 
192   */
193   public java.lang.String getTarget() {
194     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
195   }
196 
197   public void setTarget(java.lang.String target) {
198     getStateHelper().put(PropertyKeys.target, target);
199   }
200 
201   /**
202   <p>
203    Indicate the partially rendered components in a case of a submit.
204    </p>
205    <p>
206    The search depends on the number of prefixed colons in the relativeId:
207    </p>
208    <dl>
209      <dd>number of prefixed colons == 0</dd>
210      <dt>fully relative</dt>
211      <dd>number of prefixed colons == 1</dd>
212      <dt>absolute (still normal findComponent syntax)</dt>
213      <dd>number of prefixed colons == 2</dd>
214      <dt>search in the current naming container (same as 0 colons)</dt>
215      <dd>number of prefixed colons == 3</dd>
216      <dt>search in the parent naming container of the current naming container</dt>
217      <dd>number of prefixed colons &gt; 3</dd>
218      <dt>go to the next parent naming container for each additional colon</dt>
219    </dl>
220    <p>
221    If a literal is specified: to use more than one identifier the identifiers must be space delimited.
222    </p>
223    <p>
224    Using this in a UISheet or UITabGroup component this list indicates components to update when calling
225    internal AJAX requests like sort or paging commands.
226    Don't forget to add the sheet-id or tagGroup-id in that case, if needed.
227    </p>
228    <p>
229    You can also use
230 
231   */
232   public String[] getRenderedPartially() {
233     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
234     if (strArray != null) {
235       if (strArray instanceof String[]) {
236         return (String[]) strArray;
237       } else if (strArray instanceof String) {
238         String[] strings = StringUtils.split((String) strArray, ", ");
239         List<String> result = new ArrayList<String>(strings.length);
240         for (String string : strings) {
241           if (string.trim().length() != 0) {
242             result.add(string.trim());
243           }
244         }
245         return result.toArray(new String[result.size()]);
246       } else if (strArray == null) {
247         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
248       } else {
249         return new String[]{strArray.toString()};
250       }
251     }
252     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
253   }
254 
255   public void setRenderedPartially(String[] renderedPartially) {
256     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
257   }
258 
259   /**
260   Flag indicating that the resource referenced by the resource attribute is a jsf resource.
261    That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
262    /faces/*). Default is false.
263   <br>Default: <code>false</code>
264   */
265   public boolean isJsfResource() {
266     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
267     if (bool != null) {
268       return bool;
269     }
270     return false;
271   }
272 
273   public void setJsfResource(boolean jsfResource) {
274     getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
275   }
276 
277   /**
278   The access key of this control.
279 
280   */
281   public java.lang.Character getAccessKey() {
282     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
283   }
284 
285   public void setAccessKey(java.lang.Character accessKey) {
286     getStateHelper().put(PropertyKeys.accessKey, accessKey);
287   }
288 
289   /**
290   Sets a CSS class in its parent, if the parent supports it.
291 
292    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
293 
294    <pre>
295    &lt;tc:in&gt;
296      &lt;tc:style customClass="my-emphasized"/&gt;
297    &lt;/tc:in&gt;
298    </pre>
299 
300    One capability is, to used external CSS libs.
301    <br>
302    This feature should not be used imprudent.
303    Because it might be unstable against changes in the renderered HTML code.
304 
305   */
306   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
307     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
308   }
309 
310   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
311     getStateHelper().put(PropertyKeys.customClass, customClass);
312   }
313 
314   /**
315   Text value to display as tooltip.
316 
317   */
318   public java.lang.String getTip() {
319     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
320   }
321 
322   public void setTip(java.lang.String tip) {
323     getStateHelper().put(PropertyKeys.tip, tip);
324   }
325 
326   /**
327   For internal use. Used for rendering, if there is a child tag &lt;tc:style&gt;
328 
329   */
330   public org.apache.myfaces.tobago.renderkit.css.Style getStyle() {
331     return (org.apache.myfaces.tobago.renderkit.css.Style) getStateHelper().eval(PropertyKeys.style);
332   }
333 
334   public void setStyle(org.apache.myfaces.tobago.renderkit.css.Style style) {
335     getStateHelper().put(PropertyKeys.style, style);
336   }
337 
338   /**
339   Flag indicating that the action of this element, will not be executed from client side
340    (e. g. when the user clicks a button.
341    When setting this value to true, the action will not be executed by the Tobago, but it can executed
342    by JavaScript.
343    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
344    In this case you usually don't want a submit with a full reload of the page.
345   <br>Default: <code>false</code>
346   */
347   public boolean isOmit() {
348     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
349     if (bool != null) {
350       return bool;
351     }
352     return false;
353   }
354 
355   public void setOmit(boolean omit) {
356     getStateHelper().put(PropertyKeys.omit, omit);
357   }
358 
359 
360 }