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