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.AbstractUICommand;
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 menu item. (This tag was renamed from tc:menuItem since Tobago 1.5.0)
39    * UIComponent class, generated from template {@code component.stg} with class
40    * {@link org.apache.myfaces.tobago.internal.taglib.component.MenuCommandTagDeclaration}.
41   */
42  public class UIMenuCommand
43      extends AbstractUICommand implements SupportsAccessKey, Visual {
44  
45    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.MenuCommand";
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      label,
56      transition,
57      target,
58      renderedPartially,
59      jsfResource,
60      accessKey,
61      customClass,
62      style,
63      tip,
64      omit,
65    }
66  
67    public String getFamily() {
68      return COMPONENT_FAMILY;
69    }
70  
71  
72    /**
73    Url to an image to display.
74  
75    */
76    public java.lang.String getImage() {
77      return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
78    }
79  
80    public void setImage(java.lang.String image) {
81      getStateHelper().put(PropertyKeys.image, image);
82    }
83  
84    public org.apache.myfaces.tobago.context.Markup getMarkup() {
85      Object object = getStateHelper().eval(PropertyKeys.markup);
86      if (object != null) {
87        return Markup.valueOf(object);
88      }
89      return null;
90    }
91  
92    public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
93      getStateHelper().put(PropertyKeys.markup, markup);
94    }
95  
96    /**
97    Link to an internal resource.
98     Resources will be processed by the resource management.
99     E. g. define help.html and it will be served help_es.html or help_de.html if available.
100    For JSF-Pages you have to set the jsfResource attribute.
101 
102   */
103   public java.lang.String getResource() {
104     return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
105   }
106 
107   public void setResource(java.lang.String resource) {
108     getStateHelper().put(PropertyKeys.resource, resource);
109   }
110 
111   /**
112   Link to an arbitrary URL, either an internal link or an external link.
113 
114    <dl>
115      <dt>internal absolute link</dt>
116      <dd>Starts with a slash '/' character. The context path will be added.
117          A session id will be added, if needed.</dd>
118      <dt>external link</dt>
119      <dd>Starts with protocol followed by a colon ':' character.
120          The link will not be modified.</dd>
121      <dt>internal relative link</dt>
122      <dd>Any other strings. A session id will be added, if needed.</dd>
123    </dl>
124 
125   */
126   public java.lang.String getLink() {
127     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
128   }
129 
130   public void setLink(java.lang.String link) {
131     getStateHelper().put(PropertyKeys.link, link);
132   }
133 
134   /**
135   Text value to display as label.
136    If text contains an underscore the next character is used as accesskey (if configured so and possible).
137 
138   */
139   public java.lang.String getLabel() {
140     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
141   }
142 
143   public void setLabel(java.lang.String label) {
144     getStateHelper().put(PropertyKeys.label, label);
145   }
146 
147   /**
148   Specify, if the command calls an JSF-Action.
149    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
150   <br>Default: <code>true</code>
151   */
152   public boolean isTransition() {
153     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
154     if (bool != null) {
155       return bool;
156     }
157     return true;
158   }
159 
160   public void setTransition(boolean transition) {
161     getStateHelper().put(PropertyKeys.transition, transition);
162   }
163 
164   /**
165   Name of a frame where the resource retrieved via this hyperlink is to be
166    displayed.
167 
168   */
169   public java.lang.String getTarget() {
170     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
171   }
172 
173   public void setTarget(java.lang.String target) {
174     getStateHelper().put(PropertyKeys.target, target);
175   }
176 
177   /**
178   <p>
179    Indicate the partially rendered components in a case of a submit.
180    </p>
181    <p>
182    The search depends on the number of prefixed colons in the relativeId:
183    </p>
184    <dl>
185      <dd>number of prefixed colons == 0</dd>
186      <dt>fully relative</dt>
187      <dd>number of prefixed colons == 1</dd>
188      <dt>absolute (still normal findComponent syntax)</dt>
189      <dd>number of prefixed colons == 2</dd>
190      <dt>search in the current naming container (same as 0 colons)</dt>
191      <dd>number of prefixed colons == 3</dd>
192      <dt>search in the parent naming container of the current naming container</dt>
193      <dd>number of prefixed colons &gt; 3</dd>
194      <dt>go to the next parent naming container for each additional colon</dt>
195    </dl>
196    <p>
197    If a literal is specified: to use more than one identifier the identifiers must be space delimited.
198    </p>
199    <p>
200    Using this in a UISheet or UITabGroup component this list indicates components to update when calling
201    internal AJAX requests like sort or paging commands.
202    Don't forget to add the sheet-id or tagGroup-id in that case, if needed.
203    </p>
204    <p>
205    You can also use
206 
207   */
208   public String[] getRenderedPartially() {
209     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
210     if (strArray != null) {
211       if (strArray instanceof String[]) {
212         return (String[]) strArray;
213       } else if (strArray instanceof String) {
214         String[] strings = StringUtils.split((String) strArray, ", ");
215         List<String> result = new ArrayList<String>(strings.length);
216         for (String string : strings) {
217           if (string.trim().length() != 0) {
218             result.add(string.trim());
219           }
220         }
221         return result.toArray(new String[result.size()]);
222       } else if (strArray == null) {
223         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
224       } else {
225         return new String[]{strArray.toString()};
226       }
227     }
228     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
229   }
230 
231   public void setRenderedPartially(String[] renderedPartially) {
232     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
233   }
234 
235   /**
236   Flag indicating that the resource referenced by the resource attribute is a jsf resource.
237    That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
238    /faces/*). Default is false.
239   <br>Default: <code>false</code>
240   */
241   public boolean isJsfResource() {
242     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
243     if (bool != null) {
244       return bool;
245     }
246     return false;
247   }
248 
249   public void setJsfResource(boolean jsfResource) {
250     getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
251   }
252 
253   /**
254   The access key of this control.
255 
256   */
257   public java.lang.Character getAccessKey() {
258     return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
259   }
260 
261   public void setAccessKey(java.lang.Character accessKey) {
262     getStateHelper().put(PropertyKeys.accessKey, accessKey);
263   }
264 
265   /**
266   Sets a CSS class in its parent, if the parent supports it.
267 
268    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
269 
270    <pre>
271    &lt;tc:in&gt;
272      &lt;tc:style customClass="my-emphasized"/&gt;
273    &lt;/tc:in&gt;
274    </pre>
275 
276    One capability is, to used external CSS libs.
277    <br>
278    This feature should not be used imprudent.
279    Because it might be unstable against changes in the renderered HTML code.
280 
281   */
282   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
283     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
284   }
285 
286   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
287     getStateHelper().put(PropertyKeys.customClass, customClass);
288   }
289 
290   /**
291   For internal use. Used for rendering, if there is a child tag &lt;tc:style&gt;
292 
293   */
294   public org.apache.myfaces.tobago.renderkit.css.Style getStyle() {
295     return (org.apache.myfaces.tobago.renderkit.css.Style) getStateHelper().eval(PropertyKeys.style);
296   }
297 
298   public void setStyle(org.apache.myfaces.tobago.renderkit.css.Style style) {
299     getStateHelper().put(PropertyKeys.style, style);
300   }
301 
302   /**
303   Text value to display as tooltip.
304 
305   */
306   public java.lang.String getTip() {
307     return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
308   }
309 
310   public void setTip(java.lang.String tip) {
311     getStateHelper().put(PropertyKeys.tip, tip);
312   }
313 
314   /**
315   Flag indicating that the action of this element, will not be executed from client side
316    (e. g. when the user clicks a button.
317    When setting this value to true, the action will not be executed by the Tobago, but it can executed
318    by JavaScript.
319    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
320    In this case you usually don't want a submit with a full reload of the page.
321   <br>Default: <code>false</code>
322   */
323   public boolean isOmit() {
324     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
325     if (bool != null) {
326       return bool;
327     }
328     return false;
329   }
330 
331   public void setOmit(boolean omit) {
332     getStateHelper().put(PropertyKeys.omit, omit);
333   }
334 
335 
336 }