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.AbstractUICommandBase;
25  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
26  import org.apache.myfaces.tobago.internal.util.StringUtils;
27  import org.apache.myfaces.tobago.internal.util.Deprecation;
28  import org.apache.myfaces.tobago.renderkit.MarginValues;
29  import org.apache.myfaces.tobago.renderkit.SpacingValues;
30  import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
31  import javax.el.ELException;
32  import javax.faces.FacesException;
33  import java.util.ArrayList;
34  import java.util.List;
35  import javax.el.MethodExpression;
36  import javax.el.ValueExpression;
37  
38  /** 
39   Renders a menu item. (This tag was renamed from tc:menuItem since Tobago 1.5.0)
40    * UIComponent class, generated from template {@code component2.0.stg} with class
41    * {@link org.apache.myfaces.tobago.internal.taglib.component.MenuCommandTagDeclaration}.
42   */
43  public class UIMenuCommand
44      extends AbstractUICommandBase implements SupportsMarkup {
45  
46    public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.MenuCommand";
47  
48    public static final String COMPONENT_FAMILY = "javax.faces.Command";
49  
50    private org.apache.myfaces.tobago.context.Markup currentMarkup;
51  
52    enum PropertyKeys {
53      markup,
54      accessKey,
55      labelWithAccessKey,
56      link,
57      resource,
58      jsfResource,
59      image,
60      transition,
61      label,
62      omit,
63      target,
64      renderedPartially,
65      onclick,
66      disabled,
67    }
68  
69    public String getFamily() {
70      return COMPONENT_FAMILY;
71    }
72  
73  
74    public org.apache.myfaces.tobago.context.Markup getMarkup() {
75      Object object = getStateHelper().eval(PropertyKeys.markup);
76      if (object != null) {
77        return Markup.valueOf(object);
78      }
79      return null;
80    }
81  
82    public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
83      getStateHelper().put(PropertyKeys.markup, markup);
84    }
85  
86    /**
87    Deprecated! Has not longer any function.
88  
89    @deprecated*/
90    @Deprecated
91    public java.lang.Character getAccessKey() {
92      return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
93    }
94  
95    @Deprecated
96    public void setAccessKey(java.lang.Character accessKey) {
97        Deprecation.LOG.error("The attribute 'accessKey' of 'UIMenuCommand' is deprecated. "
98            + "Please refer the documentation for further information.");
99      getStateHelper().put(PropertyKeys.accessKey, accessKey);
100   }
101 
102   /**
103   Deprecated! Use 'label' instead.
104    Text value to display as label.
105    If text contains an underscore the next character overwrites 'accesskey'.
106 
107   @deprecated*/
108   @Deprecated
109   public java.lang.String getLabelWithAccessKey() {
110     return (java.lang.String) getStateHelper().eval(PropertyKeys.labelWithAccessKey);
111   }
112 
113   @Deprecated
114   public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
115       Deprecation.LOG.error("The attribute 'labelWithAccessKey' of 'UIMenuCommand' is deprecated. "
116           + "Please refer the documentation for further information.");
117     getStateHelper().put(PropertyKeys.labelWithAccessKey, labelWithAccessKey);
118   }
119 
120   /**
121   Link to an arbitrary URL, either an internal link or an external link.
122 
123    <dl>
124      <dt>internal absolute link</dt>
125      <dd>Starts with a slash '/' character. The context path will be added.
126          A session id will be added, if needed.</dd>
127      <dt>external link</dt>
128      <dd>Contains a colon ':' character.
129          The link will not be modified.</dd>
130      <dt>internal relative link</dt>
131      <dd>Any other strings. A session id will be added, if needed.</dd>
132    </dl>
133 
134   */
135   public java.lang.String getLink() {
136     return (java.lang.String) getStateHelper().eval(PropertyKeys.link);
137   }
138 
139   public void setLink(java.lang.String link) {
140     getStateHelper().put(PropertyKeys.link, link);
141   }
142 
143   /**
144   Link to an internal resource.
145    Resources will be processed by the resource management.
146    E. g. define help.html and it will be served help_es.html or help_de.html if available.
147    For JSF-Pages you have to set the jsfResource attribute.
148 
149   */
150   public java.lang.String getResource() {
151     return (java.lang.String) getStateHelper().eval(PropertyKeys.resource);
152   }
153 
154   public void setResource(java.lang.String resource) {
155     getStateHelper().put(PropertyKeys.resource, resource);
156   }
157 
158   /**
159   Flag indicating that the resource referenced by the resource attribute is a jsf resource.
160    That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
161    /faces/*). Default is false.
162   <br />Default: <code>false</code>
163   */
164   public boolean isJsfResource() {
165     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.jsfResource);
166     if (bool != null) {
167       return bool;
168     }
169     return false;
170   }
171 
172   public void setJsfResource(boolean jsfResource) {
173     getStateHelper().put(PropertyKeys.jsfResource, jsfResource);
174   }
175 
176   /**
177   Url to an image to display.
178 
179   */
180   public java.lang.String getImage() {
181     return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
182   }
183 
184   public void setImage(java.lang.String image) {
185     getStateHelper().put(PropertyKeys.image, image);
186   }
187 
188   /**
189   Specify, if the command calls an JSF-Action.
190    Useful to switch off the Double-Submit-Check and Waiting-Behavior.
191   <br />Default: <code>true</code>
192   */
193   public boolean isTransition() {
194     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.transition);
195     if (bool != null) {
196       return bool;
197     }
198     return true;
199   }
200 
201   public void setTransition(boolean transition) {
202     getStateHelper().put(PropertyKeys.transition, transition);
203   }
204 
205   /**
206   Text value to display as label.
207    If text contains an underscore the next character is used as accesskey.
208 
209   */
210   public java.lang.String getLabel() {
211     return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
212   }
213 
214   public void setLabel(java.lang.String label) {
215     getStateHelper().put(PropertyKeys.label, label);
216   }
217 
218   /**
219   Flag indicating that the action of this element, will not be executed from client side
220    (e. g. when the user clicks a button.
221    When setting this value to true, the action will not be executed by the Tobago, but it can executed
222    by JavaScript.
223    This attribute is useful, when you want to add JavaScript event handlers to commands manually.
224    In this case you usually don't want a submit with a full reload of the page.
225   <br />Default: <code>false</code>
226   */
227   public boolean isOmit() {
228     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.omit);
229     if (bool != null) {
230       return bool;
231     }
232     return false;
233   }
234 
235   public void setOmit(boolean omit) {
236     getStateHelper().put(PropertyKeys.omit, omit);
237   }
238 
239   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
240     if (currentMarkup != null) {
241       return currentMarkup;
242     }
243     return null;
244   }
245 
246   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
247     this.currentMarkup = currentMarkup;
248   }
249 
250   /**
251   Name of a frame where the resource retrieved via this hyperlink is to be
252    displayed.
253 
254   */
255   public java.lang.String getTarget() {
256     return (java.lang.String) getStateHelper().eval(PropertyKeys.target);
257   }
258 
259   public void setTarget(java.lang.String target) {
260     getStateHelper().put(PropertyKeys.target, target);
261   }
262 
263   /**
264   Indicate the partially rendered Components in a case of a submit.
265 
266   */
267   public String[] getRenderedPartially() {
268     Object strArray = getStateHelper().eval(PropertyKeys.renderedPartially);
269     if (strArray != null) {
270       if (strArray instanceof String[]) {
271         return (String[]) strArray;
272       } else if (strArray instanceof String) {
273         String[] strings = StringUtils.split((String) strArray, ", ");
274         List<String> result = new ArrayList<String>(strings.length);
275         for (String string : strings) {
276           if (string.trim().length() != 0) {
277             result.add(string.trim());
278           }
279         }
280         return result.toArray(new String[result.size()]);
281       } else if (strArray == null) {
282         return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
283       } else {
284         return new String[]{strArray.toString()};
285       }
286     }
287     return org.apache.myfaces.tobago.internal.util.ArrayUtils.EMPTY_STRING_ARRAY;
288   }
289 
290   public void setRenderedPartially(String[] renderedPartially) {
291     getStateHelper().put(PropertyKeys.renderedPartially, renderedPartially);
292   }
293 
294   /**
295   Script to be invoked when clicked
296 
297   */
298   public java.lang.String getOnclick() {
299     return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
300   }
301 
302   public void setOnclick(java.lang.String onclick) {
303     getStateHelper().put(PropertyKeys.onclick, onclick);
304   }
305 
306   /**
307   Flag indicating that this element is disabled.
308   <br />Default: <code>false</code>
309   */
310   public boolean isDisabled() {
311     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
312     if (bool != null) {
313       return bool;
314     }
315     return false;
316   }
317 
318   public void setDisabled(boolean disabled) {
319     getStateHelper().put(PropertyKeys.disabled, disabled);
320   }
321 
322   public Object saveState(FacesContext context) {
323     currentMarkup = null;
324     return super.saveState(context);
325   }
326 
327 
328 }