View Javadoc

1   // WARNING: This file was automatically generated. Do not edit it directly,
2   //          or you will lose your changes.
3   
4   /*
5    * Licensed to the Apache Software Foundation (ASF) under one
6    * or more contributor license agreements.  See the NOTICE file
7    * distributed with this work for additional information
8    * regarding copyright ownership.  The ASF licenses this file
9    * to you under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License.  You may obtain a copy of the License at
12   *
13   *   http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on an
17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied.  See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21  */
22  package org.apache.myfaces.trinidad.component.core.layout;
23  
24  import java.util.Arrays;
25  import java.util.Collection;
26  import java.util.Collections;
27  import java.util.List;
28  import java.util.Map;
29  import javax.faces.component.UIComponent;
30  import javax.faces.component.behavior.ClientBehavior;
31  import javax.faces.component.behavior.ClientBehaviorHolder;
32  import org.apache.myfaces.trinidad.bean.FacesBean;
33  import org.apache.myfaces.trinidad.bean.PropertyKey;
34  import org.apache.myfaces.trinidad.component.UIXPanel;
35  import org.apache.myfaces.trinidad.util.ComponentUtils;
36  
37  /**
38   *
39   * <html:p>
40   *           This component lays out a label, children, tip, and associated message.
41   *           Typically, the only child of this component will be an
42   *           input element of some sort, but as many children as necessary can
43   *           be added.  When using panelLabelAndMessage with a Trinidad
44   *           input component, you should <html:strong>always</html:strong>
45   *           set <html:code>simple=&quot;true&quot;</html:code> on the input
46   *           component.  Non-simple Trinidad input components already
47   *           effectively have all the functionality of
48   *           panelLabelAndMessage.
49   *         </html:p>
50   *         <html:p>
51   *           Note that the label and messages that are rendered only apply to the
52   *           "for" component so messages and labels will not be shown if there are multiple input
53   *           child components.
54   *         </html:p>
55   *         <html:p>
56   *           To lay out multiple panelLabelAndMessage components - or multiple
57   *           non-simple Trinidad input components - you can use the
58   *           panelForm component.  When panelLabelAndMessage components are
59   *           placed inside a panelForm the labels will line up.
60   *         </html:p>
61   *
62   * <h4>Events:</h4>
63   * <table border="1" width="100%" cellpadding="3" summary="">
64   * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
65   * <th align="left">Type</th>
66   * <th align="left">Phases</th>
67   * <th align="left">Description</th>
68   * </tr>
69   * <tr class="TableRowColor">
70   * <td valign="top"><code>org.apache.myfaces.trinidad.event.AttributeChangeEvent</code></td>
71   * <td valign="top" nowrap>Invoke<br>Application<br>Apply<br>Request<br>Values</td>
72   * <td valign="top">Event delivered to describe an attribute change.  Attribute change events are not delivered for any programmatic change to a property.  They are only delivered when a renderer changes a property without the application's specific request.  An example of an attribute change event might include the width of a column that supported client-side resizing.</td>
73   * </tr>
74   * </table>
75   */
76  public class CorePanelLabelAndMessage extends UIXPanel
77                                        implements ClientBehaviorHolder
78  {
79    static public final FacesBean.Type TYPE = new FacesBean.Type(
80      UIXPanel.TYPE);
81    static public final PropertyKey INLINE_STYLE_KEY =
82      TYPE.registerKey("inlineStyle", String.class);
83    static public final PropertyKey STYLE_CLASS_KEY =
84      TYPE.registerKey("styleClass", String.class);
85    static public final PropertyKey SHORT_DESC_KEY =
86      TYPE.registerKey("shortDesc", String.class);
87    static public final PropertyKey PARTIAL_TRIGGERS_KEY =
88      TYPE.registerKey("partialTriggers", String[].class, null, 0, PropertyKey.Mutable.RARELY);
89    static public final PropertyKey ONCLICK_KEY =
90      TYPE.registerKey("onclick", String.class);
91    static public final PropertyKey ONDBLCLICK_KEY =
92      TYPE.registerKey("ondblclick", String.class);
93    static public final PropertyKey ONMOUSEDOWN_KEY =
94      TYPE.registerKey("onmousedown", String.class);
95    static public final PropertyKey ONMOUSEUP_KEY =
96      TYPE.registerKey("onmouseup", String.class);
97    static public final PropertyKey ONMOUSEOVER_KEY =
98      TYPE.registerKey("onmouseover", String.class);
99    static public final PropertyKey ONMOUSEMOVE_KEY =
100     TYPE.registerKey("onmousemove", String.class);
101   static public final PropertyKey ONMOUSEOUT_KEY =
102     TYPE.registerKey("onmouseout", String.class);
103   static public final PropertyKey ONKEYPRESS_KEY =
104     TYPE.registerKey("onkeypress", String.class);
105   static public final PropertyKey ONKEYDOWN_KEY =
106     TYPE.registerKey("onkeydown", String.class);
107   static public final PropertyKey ONKEYUP_KEY =
108     TYPE.registerKey("onkeyup", String.class);
109   static public final PropertyKey SHOW_REQUIRED_KEY =
110     TYPE.registerKey("showRequired", Boolean.class, Boolean.FALSE);
111   static public final PropertyKey LABEL_KEY =
112     TYPE.registerKey("label", String.class);
113   static public final PropertyKey LABEL_STYLE_KEY =
114     TYPE.registerKey("labelStyle", String.class);
115   static public final PropertyKey ACCESS_KEY_KEY =
116     TYPE.registerKey("accessKey", Character.class);
117   static public final PropertyKey FOR_KEY =
118     TYPE.registerKey("for", String.class);
119   static public final String HELP_FACET = "help";
120   static public final String END_FACET = "end";
121 
122   static public final String COMPONENT_FAMILY =
123     "org.apache.myfaces.trinidad.Panel";
124   static public final String COMPONENT_TYPE =
125     "org.apache.myfaces.trinidad.CorePanelLabelAndMessage";
126   // Supported client events for client behaviors:
127   private final static Collection<String> _EVENT_NAMES = Collections.unmodifiableCollection(
128     Arrays.asList(
129       "click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove",
130       "mouseout", "keypress", "keydown", "keyup"
131     ));
132 
133   /**
134    * Construct an instance of the CorePanelLabelAndMessage.
135    */
136   public CorePanelLabelAndMessage()
137   {
138     super("org.apache.myfaces.trinidad.LabelAndMessage");
139   }
140 
141   /**
142    * This facet should contain field level help.
143    */
144   final public UIComponent getHelp()
145   {
146     return getFacet(HELP_FACET);
147   }
148 
149   /**
150    * This facet should contain field level help.
151    */
152   @SuppressWarnings("unchecked")
153   final public void setHelp(UIComponent helpFacet)
154   {
155     getFacets().put(HELP_FACET, helpFacet);
156   }
157 
158   /**
159    * Component to render after the children.
160    */
161   final public UIComponent getEnd()
162   {
163     return getFacet(END_FACET);
164   }
165 
166   /**
167    * Component to render after the children.
168    */
169   @SuppressWarnings("unchecked")
170   final public void setEnd(UIComponent endFacet)
171   {
172     getFacets().put(END_FACET, endFacet);
173   }
174 
175   /**
176    * Gets the CSS styles to use for this component.
177    *
178    * @return  the new inlineStyle value
179    */
180   final public String getInlineStyle()
181   {
182     return ComponentUtils.resolveString(getProperty(INLINE_STYLE_KEY));
183   }
184 
185   /**
186    * Sets the CSS styles to use for this component.
187    * 
188    * @param inlineStyle  the new inlineStyle value
189    */
190   final public void setInlineStyle(String inlineStyle)
191   {
192     setProperty(INLINE_STYLE_KEY, (inlineStyle));
193   }
194 
195   /**
196    * Gets a CSS style class to use for this component.
197    *
198    * @return  the new styleClass value
199    */
200   final public String getStyleClass()
201   {
202     return ComponentUtils.resolveString(getProperty(STYLE_CLASS_KEY));
203   }
204 
205   /**
206    * Sets a CSS style class to use for this component.
207    * 
208    * @param styleClass  the new styleClass value
209    */
210   final public void setStyleClass(String styleClass)
211   {
212     setProperty(STYLE_CLASS_KEY, (styleClass));
213   }
214 
215   /**
216    * Gets The short description of the component. This text is commonly used by user agents to display tooltip help text.
217    *
218    * @return  the new shortDesc value
219    */
220   final public String getShortDesc()
221   {
222     return ComponentUtils.resolveString(getProperty(SHORT_DESC_KEY));
223   }
224 
225   /**
226    * Sets The short description of the component. This text is commonly used by user agents to display tooltip help text.
227    * 
228    * @param shortDesc  the new shortDesc value
229    */
230   final public void setShortDesc(String shortDesc)
231   {
232     setProperty(SHORT_DESC_KEY, (shortDesc));
233   }
234 
235   /**
236    * Gets the IDs of the components that should trigger a partial update.
237    *         <p>
238    *         This component will listen on the trigger components. If one of the
239    *         trigger components receives an event that will cause it to update
240    *         in some way, this component will request to be updated too.</p>
241    *         <p>
242    *         Separate multiple triggers with a space. e.g., partialTriggers="cmp1 cmp2"
243    *         </p>
244    *         <p>
245    *         Identifiers must account for NamingContainers.  You can use a single colon to start the search from the root,
246    *         or use multiple colons to move up through the NamingContainer. For example,
247    *         "::" will pop out of this component's naming container (it pops out of itself if it is a naming container), 
248    *         ":::" will pop out of two naming containers, etc. The search for
249    *         the partialTrigger begins from there. e.g., partialTriggers=":::commandButton1" the search begins for the 
250    *         component with id = commandButton1 after popping out of two naming containers relative to this component.
251    *         To go into naming containers, you separate the naming containers with ':', e.g.,partialTriggers= "nc1:nc2:nc3:componentId".</p>
252    *
253    * @return  the new partialTriggers value
254    */
255   final public String[] getPartialTriggers()
256   {
257     return (String[])getProperty(PARTIAL_TRIGGERS_KEY);
258   }
259 
260   /**
261    * Sets the IDs of the components that should trigger a partial update.
262    *         <p>
263    *         This component will listen on the trigger components. If one of the
264    *         trigger components receives an event that will cause it to update
265    *         in some way, this component will request to be updated too.</p>
266    *         <p>
267    *         Separate multiple triggers with a space. e.g., partialTriggers="cmp1 cmp2"
268    *         </p>
269    *         <p>
270    *         Identifiers must account for NamingContainers.  You can use a single colon to start the search from the root,
271    *         or use multiple colons to move up through the NamingContainer. For example,
272    *         "::" will pop out of this component's naming container (it pops out of itself if it is a naming container), 
273    *         ":::" will pop out of two naming containers, etc. The search for
274    *         the partialTrigger begins from there. e.g., partialTriggers=":::commandButton1" the search begins for the 
275    *         component with id = commandButton1 after popping out of two naming containers relative to this component.
276    *         To go into naming containers, you separate the naming containers with ':', e.g.,partialTriggers= "nc1:nc2:nc3:componentId".</p>
277    * 
278    * @param partialTriggers  the new partialTriggers value
279    */
280   final public void setPartialTriggers(String[] partialTriggers)
281   {
282     setProperty(PARTIAL_TRIGGERS_KEY, (partialTriggers));
283   }
284 
285   /**
286    * Gets an onclick Javascript handler.
287    *
288    * @return  the new onclick value
289    */
290   final public String getOnclick()
291   {
292     return ComponentUtils.resolveString(getProperty(ONCLICK_KEY));
293   }
294 
295   /**
296    * Sets an onclick Javascript handler.
297    * 
298    * @param onclick  the new onclick value
299    */
300   final public void setOnclick(String onclick)
301   {
302     setProperty(ONCLICK_KEY, (onclick));
303   }
304 
305   /**
306    * Gets an ondblclick Javascript handler.
307    *
308    * @return  the new ondblclick value
309    */
310   final public String getOndblclick()
311   {
312     return ComponentUtils.resolveString(getProperty(ONDBLCLICK_KEY));
313   }
314 
315   /**
316    * Sets an ondblclick Javascript handler.
317    * 
318    * @param ondblclick  the new ondblclick value
319    */
320   final public void setOndblclick(String ondblclick)
321   {
322     setProperty(ONDBLCLICK_KEY, (ondblclick));
323   }
324 
325   /**
326    * Gets an onmousedown Javascript handler.
327    *
328    * @return  the new onmousedown value
329    */
330   final public String getOnmousedown()
331   {
332     return ComponentUtils.resolveString(getProperty(ONMOUSEDOWN_KEY));
333   }
334 
335   /**
336    * Sets an onmousedown Javascript handler.
337    * 
338    * @param onmousedown  the new onmousedown value
339    */
340   final public void setOnmousedown(String onmousedown)
341   {
342     setProperty(ONMOUSEDOWN_KEY, (onmousedown));
343   }
344 
345   /**
346    * Gets an onmouseup Javascript handler.
347    *
348    * @return  the new onmouseup value
349    */
350   final public String getOnmouseup()
351   {
352     return ComponentUtils.resolveString(getProperty(ONMOUSEUP_KEY));
353   }
354 
355   /**
356    * Sets an onmouseup Javascript handler.
357    * 
358    * @param onmouseup  the new onmouseup value
359    */
360   final public void setOnmouseup(String onmouseup)
361   {
362     setProperty(ONMOUSEUP_KEY, (onmouseup));
363   }
364 
365   /**
366    * Gets an onmouseover Javascript handler.
367    *
368    * @return  the new onmouseover value
369    */
370   final public String getOnmouseover()
371   {
372     return ComponentUtils.resolveString(getProperty(ONMOUSEOVER_KEY));
373   }
374 
375   /**
376    * Sets an onmouseover Javascript handler.
377    * 
378    * @param onmouseover  the new onmouseover value
379    */
380   final public void setOnmouseover(String onmouseover)
381   {
382     setProperty(ONMOUSEOVER_KEY, (onmouseover));
383   }
384 
385   /**
386    * Gets an onmousemove Javascript handler.
387    *
388    * @return  the new onmousemove value
389    */
390   final public String getOnmousemove()
391   {
392     return ComponentUtils.resolveString(getProperty(ONMOUSEMOVE_KEY));
393   }
394 
395   /**
396    * Sets an onmousemove Javascript handler.
397    * 
398    * @param onmousemove  the new onmousemove value
399    */
400   final public void setOnmousemove(String onmousemove)
401   {
402     setProperty(ONMOUSEMOVE_KEY, (onmousemove));
403   }
404 
405   /**
406    * Gets an onmouseout Javascript handler.
407    *
408    * @return  the new onmouseout value
409    */
410   final public String getOnmouseout()
411   {
412     return ComponentUtils.resolveString(getProperty(ONMOUSEOUT_KEY));
413   }
414 
415   /**
416    * Sets an onmouseout Javascript handler.
417    * 
418    * @param onmouseout  the new onmouseout value
419    */
420   final public void setOnmouseout(String onmouseout)
421   {
422     setProperty(ONMOUSEOUT_KEY, (onmouseout));
423   }
424 
425   /**
426    * Gets an onkeypress Javascript handler.
427    *
428    * @return  the new onkeypress value
429    */
430   final public String getOnkeypress()
431   {
432     return ComponentUtils.resolveString(getProperty(ONKEYPRESS_KEY));
433   }
434 
435   /**
436    * Sets an onkeypress Javascript handler.
437    * 
438    * @param onkeypress  the new onkeypress value
439    */
440   final public void setOnkeypress(String onkeypress)
441   {
442     setProperty(ONKEYPRESS_KEY, (onkeypress));
443   }
444 
445   /**
446    * Gets an onkeydown Javascript handler.
447    *
448    * @return  the new onkeydown value
449    */
450   final public String getOnkeydown()
451   {
452     return ComponentUtils.resolveString(getProperty(ONKEYDOWN_KEY));
453   }
454 
455   /**
456    * Sets an onkeydown Javascript handler.
457    * 
458    * @param onkeydown  the new onkeydown value
459    */
460   final public void setOnkeydown(String onkeydown)
461   {
462     setProperty(ONKEYDOWN_KEY, (onkeydown));
463   }
464 
465   /**
466    * Gets an onkeyup Javascript handler.
467    *
468    * @return  the new onkeyup value
469    */
470   final public String getOnkeyup()
471   {
472     return ComponentUtils.resolveString(getProperty(ONKEYUP_KEY));
473   }
474 
475   /**
476    * Sets an onkeyup Javascript handler.
477    * 
478    * @param onkeyup  the new onkeyup value
479    */
480   final public void setOnkeyup(String onkeyup)
481   {
482     setProperty(ONKEYUP_KEY, (onkeyup));
483   }
484 
485   /**
486    * Gets whether the panel should show an indicator that its contents are required.
487    *
488    * @return  the new showRequired value
489    */
490   final public boolean isShowRequired()
491   {
492     return ComponentUtils.resolveBoolean(getProperty(SHOW_REQUIRED_KEY), false);
493   }
494 
495   /**
496    * Sets whether the panel should show an indicator that its contents are required.
497    * 
498    * @param showRequired  the new showRequired value
499    */
500   final public void setShowRequired(boolean showRequired)
501   {
502     setProperty(SHOW_REQUIRED_KEY, showRequired ? Boolean.TRUE : Boolean.FALSE);
503   }
504 
505   /**
506    * Gets the label of the bean.
507    *
508    * @return  the new label value
509    */
510   final public String getLabel()
511   {
512     return ComponentUtils.resolveString(getProperty(LABEL_KEY));
513   }
514 
515   /**
516    * Sets the label of the bean.
517    * 
518    * @param label  the new label value
519    */
520   final public void setLabel(String label)
521   {
522     setProperty(LABEL_KEY, (label));
523   }
524 
525   /**
526    * Gets Specifies inline styles for the label portion of the component, e.g. "vertical-align: bottom;" to align the label to the bottom of the container.
527    *
528    * @return  the new labelStyle value
529    */
530   final public String getLabelStyle()
531   {
532     return ComponentUtils.resolveString(getProperty(LABEL_STYLE_KEY));
533   }
534 
535   /**
536    * Sets Specifies inline styles for the label portion of the component, e.g. "vertical-align: bottom;" to align the label to the bottom of the container.
537    * 
538    * @param labelStyle  the new labelStyle value
539    */
540   final public void setLabelStyle(String labelStyle)
541   {
542     setProperty(LABEL_STYLE_KEY, (labelStyle));
543   }
544 
545   /**
546    * Gets <html>
547    *  Character used to gain quick access to
548    *                the form element specified by the
549    *          <code>for</code>, if set (or this component itself,
550    *               if it is a "non-simple" form element).
551    *               For accessibility reasons, this functionality is not supported
552    *               in screen reader mode.
553    *               If the same access key appears in multiple locations in the
554    *               same page of output, the rendering user agent will cycle
555    *               among the elements accessed by the similar keys.
556    *               <p>
557    *                 This attribute is sometimes referred to as the "mnemonic".
558    *                 </p></html>
559    *
560    * @return  the new accessKey value
561    */
562   final public char getAccessKey()
563   {
564     return ComponentUtils.resolveCharacter((Character)getProperty(ACCESS_KEY_KEY));
565   }
566 
567   /**
568    * Sets <html>
569    *  Character used to gain quick access to
570    *                the form element specified by the
571    *          <code>for</code>, if set (or this component itself,
572    *               if it is a "non-simple" form element).
573    *               For accessibility reasons, this functionality is not supported
574    *               in screen reader mode.
575    *               If the same access key appears in multiple locations in the
576    *               same page of output, the rendering user agent will cycle
577    *               among the elements accessed by the similar keys.
578    *               <p>
579    *                 This attribute is sometimes referred to as the "mnemonic".
580    *                 </p></html>
581    * 
582    * @param accessKey  the new accessKey value
583    */
584   final public void setAccessKey(char accessKey)
585   {
586     setProperty(ACCESS_KEY_KEY, Character.valueOf(accessKey));
587   }
588 
589   /**
590    * Gets The ID of the component that this component's label refers to.
591    *
592    * @return  the new for value
593    */
594   final public String getFor()
595   {
596     return ComponentUtils.resolveString(getProperty(FOR_KEY));
597   }
598 
599   /**
600    * Sets The ID of the component that this component's label refers to.
601    * 
602    * @param forParam  the new for value
603    */
604   final public void setFor(String forParam)
605   {
606     setProperty(FOR_KEY, (forParam));
607   }
608 
609   @Override
610   public String getDefaultEventName()
611   {
612     return "click";
613   }
614 
615   @Override
616   public Collection<String> getEventNames()
617   {
618     return _EVENT_NAMES;
619   }
620 
621   @Override
622   public Map<String, List<ClientBehavior>> getClientBehaviors()
623   {
624     return super.getClientBehaviors();
625   }
626 
627   @Override
628   public void addClientBehavior(
629     String         eventName,
630     ClientBehavior behavior)
631   {
632     super.addClientBehavior(eventName, behavior);
633   }
634 
635   @Override
636   public String getFamily()
637   {
638     return COMPONENT_FAMILY;
639   }
640 
641   @Override
642   protected FacesBean.Type getBeanType()
643   {
644     return TYPE;
645   }
646 
647   /**
648    * Construct an instance of the CorePanelLabelAndMessage.
649    */
650   protected CorePanelLabelAndMessage(
651     String rendererType
652     )
653   {
654     super(rendererType);
655   }
656 
657   static
658   {
659     TYPE.lockAndRegister("org.apache.myfaces.trinidad.Panel","org.apache.myfaces.trinidad.LabelAndMessage");
660   }
661 }