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