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.application.FacesMessage;
23  import javax.faces.component.behavior.ClientBehaviorHolder;
24  import javax.faces.context.FacesContext;
25  import org.apache.myfaces.tobago.context.Markup;
26  import org.apache.myfaces.tobago.internal.component.AbstractUIMessages;
27  import org.apache.myfaces.tobago.layout.OrderBy;
28  import org.apache.myfaces.tobago.renderkit.css.CustomClass;
29  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
30  import org.apache.myfaces.tobago.internal.util.StringUtils;
31  import org.apache.myfaces.tobago.internal.util.Deprecation;
32  import org.apache.myfaces.tobago.component.Tags;
33  import javax.annotation.Generated;
34  import javax.el.ELException;
35  import javax.faces.FacesException;
36  import java.util.Arrays;
37  import java.util.ArrayList;
38  import java.util.Collection;
39  import java.util.List;
40  import javax.el.MethodExpression;
41  import javax.el.ValueExpression;
42  
43  /**
44   Renders error/validation messages.
45    * UIComponent class, generated from template {@code component.stg} with class
46    * {@link org.apache.myfaces.tobago.internal.taglib.component.MessagesTagDeclaration}.
47   */
48  @Generated("component.stg")
49  public class UIMessages
50      extends AbstractUIMessages implements ClientBehaviorHolder {
51  
52    public static final String COMPONENT_TYPE = Tags.messages.componentType();
53  
54    public static final String COMPONENT_FAMILY = "javax.faces.Messages";
55  
56  
57    enum PropertyKeys {
58      minSeverity,
59      maxNumber,
60      markup,
61      customClass,
62      orderBy,
63      confirmation,
64      maxSeverity,
65    }
66  
67    public String getFamily() {
68      return COMPONENT_FAMILY;
69    }
70  
71  
72    /**
73    Sets the mininum severity to be shown. E. g. "warn" shows only "warn", "error" and "fatal".
74    <br>Default: <code>info</code>
75    */
76    public javax.faces.application.FacesMessage.Severity getMinSeverity() {
77      javax.faces.application.FacesMessage.Severity minSeverity = (javax.faces.application.FacesMessage.Severity) getStateHelper().eval(PropertyKeys.minSeverity);
78      if (minSeverity != null) {
79        return minSeverity;
80      }
81      return javax.faces.application.FacesMessage.SEVERITY_INFO;
82    }
83  
84    public void setMinSeverity(javax.faces.application.FacesMessage.Severity minSeverity) {
85      getStateHelper().put(PropertyKeys.minSeverity, minSeverity);
86    }
87  
88    /**
89    Sets the maximum number of messages to show.
90    <br>Default: <code>2147483647</code>
91    */
92    public java.lang.Integer getMaxNumber() {
93      Number value  = (Number) getStateHelper().eval(PropertyKeys.maxNumber);
94      if (value != null) {
95        return value.intValue();
96      }
97      return 2147483647;
98    }
99  
100   public void setMaxNumber(java.lang.Integer maxNumber) {
101     getStateHelper().put(PropertyKeys.maxNumber, maxNumber);
102   }
103 
104   public org.apache.myfaces.tobago.context.Markup getMarkup() {
105     Object object = getStateHelper().eval(PropertyKeys.markup);
106     if (object != null) {
107       return Markup.valueOf(object);
108     }
109     return null;
110   }
111 
112   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
113     getStateHelper().put(PropertyKeys.markup, markup);
114   }
115 
116   /**
117   Sets a CSS class in its parent, if the parent supports it.
118 
119    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
120 
121    <pre>
122    &lt;tc:in&gt;
123      &lt;tc:style customClass="my-emphasized"/&gt;
124    &lt;/tc:in&gt;
125    </pre>
126 
127    One capability is, to used external CSS libs.
128    <br>
129    This feature should not be used imprudent.
130    Because it might be unstable against changes in the renderered HTML code.
131 
132   */
133   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
134     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
135   }
136 
137   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
138     getStateHelper().put(PropertyKeys.customClass, customClass);
139   }
140 
141   /**
142   Sets the order of the messages.
143   <br>Default: <code>occurrence</code><br>Allowed Values: <code>occurrence,severity</code>
144   */
145   public org.apache.myfaces.tobago.layout.OrderBy getOrderBy() {
146     org.apache.myfaces.tobago.layout.OrderBy orderBy = (org.apache.myfaces.tobago.layout.OrderBy) getStateHelper().eval(PropertyKeys.orderBy);
147     if (orderBy != null) {
148       return orderBy;
149     }
150     return org.apache.myfaces.tobago.layout.OrderBy.occurrence;
151   }
152 
153   public void setOrderBy(org.apache.myfaces.tobago.layout.OrderBy orderBy) {
154     getStateHelper().put(PropertyKeys.orderBy, orderBy);
155   }
156 
157   /**
158   Has the user to confirm this message?
159    This attributes handles the case, if the application wants to warn the user about a problem,
160    and the user has to confirm the message before he/she can continue.
161   <br>Default: <code>false</code>
162   */
163   public boolean isConfirmation() {
164     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.confirmation);
165     if (bool != null) {
166       return bool;
167     }
168     return false;
169   }
170 
171   public void setConfirmation(boolean confirmation) {
172     getStateHelper().put(PropertyKeys.confirmation, confirmation);
173   }
174 
175   /**
176   Sets the maximum severity to be shown. E. g. "warn" shows only "warn" and "info".
177    When setting this attribute you usually shoud take care, that you have a second message tag to show the
178    higher severity levels.
179   <br>Default: <code>fatal</code>
180   */
181   public javax.faces.application.FacesMessage.Severity getMaxSeverity() {
182     javax.faces.application.FacesMessage.Severity maxSeverity = (javax.faces.application.FacesMessage.Severity) getStateHelper().eval(PropertyKeys.maxSeverity);
183     if (maxSeverity != null) {
184       return maxSeverity;
185     }
186     return javax.faces.application.FacesMessage.SEVERITY_FATAL;
187   }
188 
189   public void setMaxSeverity(javax.faces.application.FacesMessage.Severity maxSeverity) {
190     getStateHelper().put(PropertyKeys.maxSeverity, maxSeverity);
191   }
192 
193 
194   @Override
195   public void restoreState(FacesContext context, Object state) {
196     // FIXME HACK for mojarra SystemEventListener state restoring bug
197     pushComponentToEL(context, this);
198     super.restoreState(context, state);
199     popComponentFromEL(context);
200   }
201 
202 }