You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/08/10 22:59:45 UTC
svn commit: r684592 - in /myfaces/core/trunk_1.2.x/api/src/main:
java-templates/javax/faces/component/ java/javax/faces/component/
Author: skitching
Date: Sun Aug 10 13:59:44 2008
New Revision: 684592
URL: http://svn.apache.org/viewvc?rev=684592&view=rev
Log:
Clean up code to restore the comments lost during the 1.2.x period where this class was auto-generated via trinidad-faces-plugin.
Also restored sane order of variable and method declarations, cleaned up comments etc.
Remove corresponding template classes from which they were previously generated.
No logic changes made.
Removed:
myfaces/core/trunk_1.2.x/api/src/main/java-templates/javax/faces/component/UICommandTemplate.java
myfaces/core/trunk_1.2.x/api/src/main/java-templates/javax/faces/component/UIGraphicTemplate.java
myfaces/core/trunk_1.2.x/api/src/main/java-templates/javax/faces/component/UIInputTemplate.java
Modified:
myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UICommand.java
myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIGraphic.java
myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java
Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UICommand.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UICommand.java?rev=684592&r1=684591&r2=684592&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UICommand.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UICommand.java Sun Aug 10 13:59:44 2008
@@ -31,9 +31,9 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
/**
- *
+ *
* UICommand is a base abstraction for components that implement ActionSource.
- *
+ *
* <h4>Events:</h4>
* <table border="1" width="100%" cellpadding="3" summary="">
* <tr bgcolor="#CCCCFF" class="TableHeadingColor">
@@ -43,86 +43,103 @@
* </tr>
* <tr class="TableRowColor">
* <td valign="top"><code>javax.faces.event.ActionEvent</code></td>
- * <td valign="top" nowrap>Invoke Application<br>Apply Request Values</td>
+ * <td valign="top" nowrap>Invoke Application<br>
+ * Apply Request Values</td>
* <td valign="top">Event delivered when the "action" of the component has been
-invoked; for example, by clicking on a button. The action may result
-in page navigation.</td>
+ * invoked; for example, by clicking on a button. The action may result in page
+ * navigation.</td>
* </tr>
* </table>
*/
-@JSFComponent
-(defaultRendererType = "javax.faces.Button"
-)
-public class UICommand extends UIComponentBase
- implements ActionSource2
+@JSFComponent(defaultRendererType = "javax.faces.Button")
+public class UICommand extends UIComponentBase implements ActionSource2
{
+ static final String COMPONENT_TYPE = "javax.faces.Command";
+ private static final String COMPONENT_FAMILY = "javax.faces.Command";
- static public final String COMPONENT_FAMILY =
- "javax.faces.Command";
- static public final String COMPONENT_TYPE =
- "javax.faces.Command";
-
- /**
- * Construct an instance of the UICommand.
- */
- public UICommand()
- {
- setRendererType("javax.faces.Button");
- }
-
+ private boolean _immediate;
+ private boolean _immediateSet;
+ private Object _value;
+ private MethodExpression _actionExpression;
+ private MethodBinding _actionListener;
/**
- * @deprecated Use setActionExpression instead.
+ * Construct an instance of the UICommand.
*/
- public void setAction(MethodBinding action)
+ public UICommand()
{
- if(action != null)
- {
- setActionExpression(new _MethodBindingToMethodExpression(action));
- }
- else
- {
- setActionExpression(null);
- }
+ setRendererType("javax.faces.Button");
}
/**
+ * Specifies the action to take when this command is invoked.
+ * <p>
+ * If the value is an expression, it is expected to be a method
+ * binding EL expression that identifies an action method. An action method
+ * accepts no parameters and has a String return value, called the action
+ * outcome, that identifies the next view displayed. The phase that this
+ * event is fired in can be controlled via the immediate attribute.
+ * <p>
+ * If the value is a string literal, it is treated as a navigation outcome
+ * for the current view. This is functionally equivalent to a reference to
+ * an action method that returns the string literal.
+ *
* @deprecated Use getActionExpression() instead.
*/
+ @Deprecated
+ @JSFProperty(returnSignature="java.lang.String")
public MethodBinding getAction()
{
MethodExpression actionExpression = getActionExpression();
- if (actionExpression instanceof _MethodBindingToMethodExpression) {
- return ((_MethodBindingToMethodExpression)actionExpression).getMethodBinding();
+ if (actionExpression instanceof _MethodBindingToMethodExpression)
+ {
+ return ((_MethodBindingToMethodExpression) actionExpression)
+ .getMethodBinding();
}
- if(actionExpression != null)
+ if (actionExpression != null)
{
return new _MethodExpressionToMethodBinding(actionExpression);
}
return null;
}
+ /**
+ * @deprecated Use setActionExpression instead.
+ */
+ @Deprecated
+ public void setAction(MethodBinding action)
+ {
+ if (action != null)
+ {
+ setActionExpression(new _MethodBindingToMethodExpression(action));
+ }
+ else
+ {
+ setActionExpression(null);
+ }
+ }
+
@Override
- public void broadcast(FacesEvent event)
- throws AbortProcessingException
+ public void broadcast(FacesEvent event) throws AbortProcessingException
{
super.broadcast(event);
if (event instanceof ActionEvent)
{
FacesContext context = getFacesContext();
-
+
MethodBinding mb = getActionListener();
- if(mb != null)
+ if (mb != null)
{
- mb.invoke(context, new Object[] { event });
+ mb.invoke(context, new Object[]
+ { event });
}
- ActionListener defaultActionListener
- = context.getApplication().getActionListener();
+ ActionListener defaultActionListener = context.getApplication()
+ .getActionListener();
if (defaultActionListener != null)
{
- defaultActionListener.processAction((ActionEvent)event);
+ defaultActionListener.processAction((ActionEvent) event);
}
}
}
@@ -144,245 +161,170 @@
super.queueEvent(event);
}
- // Property: immediate
- private boolean _immediate;
- private boolean _immediateSet;
-
- /**
- * Gets A boolean value that identifies the phase during which action events
- * should fire. During normal event processing, action methods and
- * action listener methods are fired during the "invoke application"
- * phase of request processing. If this attribute is set to "true",
- * these methods are fired instead at the end of the "apply request
- * values" phase.
- *
- * @return the new immediate value
- */
- @JSFProperty
- public boolean isImmediate()
- {
- if (_immediateSet)
- {
- return _immediate;
- }
- ValueExpression expression = getValueExpression("immediate");
- if (expression != null)
- {
- return (Boolean)expression.getValue(getFacesContext().getELContext());
- }
- return false;
- }
-
- /**
- * Sets A boolean value that identifies the phase during which action events
- * should fire. During normal event processing, action methods and
- * action listener methods are fired during the "invoke application"
- * phase of request processing. If this attribute is set to "true",
- * these methods are fired instead at the end of the "apply request
- * values" phase.
- *
- * @param immediate the new immediate value
- */
- public void setImmediate(boolean immediate)
- {
- this._immediate = immediate;
- this._immediateSet = true;
- }
-
- // Property: value
- private Object _value;
-
- /**
- * Gets The initial value of this component.
- *
- * @return the new value value
- */
- @JSFProperty
- public Object getValue()
- {
- if (_value != null)
- {
- return _value;
- }
- ValueExpression expression = getValueExpression("value");
- if (expression != null)
- {
- return expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets The initial value of this component.
- *
- * @param value the new value value
- */
- public void setValue(Object value)
- {
- this._value = value;
- }
-
- // Property: actionExpression
- private MethodExpression _actionExpression;
-
- /**
- * Gets Specifies the action to take when this command is invoked.
- * If the value is an expression, it is expected to be a method
- * binding EL expression that identifies an action method. An action method
- * accepts no parameters and has a String return value, called the action
- * outcome, that identifies the next view displayed. The phase that this
- * event is fired in can be controlled via the immediate attribute.
- *
- * If the value is a string literal, it is treated as a navigation outcome
- * for the current view. This is functionally equivalent to a reference to
- * an action method that returns the string literal.
- *
- * @return the new actionExpression value
- */
- @JSFProperty
- (stateHolder = true,
- returnSignature = "java.lang.Object",
- jspName = "action")
- public MethodExpression getActionExpression()
- {
- if (_actionExpression != null)
- {
- return _actionExpression;
- }
- ValueExpression expression = getValueExpression("actionExpression");
- if (expression != null)
- {
- return (MethodExpression)expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets Specifies the action to take when this command is invoked.
- * If the value is an expression, it is expected to be a method
- * binding EL expression that identifies an action method. An action method
- * accepts no parameters and has a String return value, called the action
- * outcome, that identifies the next view displayed. The phase that this
- * event is fired in can be controlled via the immediate attribute.
- *
- * If the value is a string literal, it is treated as a navigation outcome
- * for the current view. This is functionally equivalent to a reference to
- * an action method that returns the string literal.
- *
- * @param actionExpression the new actionExpression value
- */
- public void setActionExpression(MethodExpression actionExpression)
- {
- this._actionExpression = actionExpression;
- }
-
- // Property: actionListener
- private MethodBinding _actionListener;
-
- /**
- * Gets A method binding EL expression that identifies an action listener method
- * to be invoked if this component is activated by the user. An action
- * listener method accepts a parameter of type javax.faces.event.ActionEvent
- * and returns void. The phase that this event is fired in can be controlled
- * via the immediate attribute.
- *
- * @return the new actionListener value
- * @deprecated
- */
- @JSFProperty
- (stateHolder = true,
- returnSignature = "void",
- methodSignature = "javax.faces.event.ActionEvent")
- public MethodBinding getActionListener()
- {
- if (_actionListener != null)
- {
- return _actionListener;
- }
- ValueExpression expression = getValueExpression("actionListener");
- if (expression != null)
- {
- return (MethodBinding)expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets A method binding EL expression that identifies an action listener method
- * to be invoked if this component is activated by the user. An action
- * listener method accepts a parameter of type javax.faces.event.ActionEvent
- * and returns void. The phase that this event is fired in can be controlled
- * via the immediate attribute.
- *
- * @param actionListener the new actionListener value
- * @deprecated
- */
- public void setActionListener(MethodBinding actionListener)
- {
- this._actionListener = actionListener;
- }
-
- /**
- * Adds a action listener.
- *
- * @param listener the action listener to add
- */
- public void addActionListener(
- ActionListener listener)
- {
- addFacesListener(listener);
- }
-
- /**
- * Removes a action listener.
- *
- * @param listener the action listener to remove
- */
- public void removeActionListener(
- ActionListener listener)
- {
- removeFacesListener(listener);
- }
-
- /**
- * Returns an array of attached action listeners.
- *
- * @return an array of attached action listeners.
- */
- public ActionListener[] getActionListeners()
- {
- return (ActionListener[])getFacesListeners(ActionListener.class);
- }
-
- @Override
- public Object saveState(FacesContext facesContext)
- {
- Object[] values = new Object[6];
- values[0] = super.saveState(facesContext);
- values[1] = _immediate;
- values[2] = _immediateSet;
- values[3] = _value;
- values[4] = saveAttachedState(facesContext, _actionExpression);
- values[5] = saveAttachedState(facesContext, _actionListener);
-
- return values;
- }
-
- @Override
- public void restoreState(FacesContext facesContext, Object state)
- {
- Object[] values = (Object[])state;
- super.restoreState(facesContext,values[0]);
- _immediate = (Boolean)values[1];
- _immediateSet = (Boolean)values[2];
- _value = values[3];
- _actionExpression = (MethodExpression)restoreAttachedState(facesContext, values[4]);
- _actionListener = (MethodBinding)restoreAttachedState(facesContext, values[5]);
- }
-
- @Override
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
+ /**
+ * A boolean value that identifies the phase during which action events
+ * should fire.
+ * <p>
+ * During normal event processing, action methods and action listener methods are fired during the
+ * "invoke application" phase of request processing. If this attribute is set to "true", these methods
+ * are fired instead at the end of the "apply request values" phase.
+ */
+ @JSFProperty
+ public boolean isImmediate()
+ {
+ if (_immediateSet)
+ {
+ return _immediate;
+ }
+ ValueExpression expression = getValueExpression("immediate");
+ if (expression != null)
+ {
+ return (Boolean) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return false;
+ }
+
+ public void setImmediate(boolean immediate)
+ {
+ this._immediate = immediate;
+ this._immediateSet = true;
+ }
+
+ /**
+ * The text to display to the user for this command component.
+ */
+ @JSFProperty
+ public Object getValue()
+ {
+ if (_value != null)
+ {
+ return _value;
+ }
+ ValueExpression expression = getValueExpression("value");
+ if (expression != null)
+ {
+ return expression.getValue(getFacesContext().getELContext());
+ }
+ return null;
+ }
+
+ public void setValue(Object value)
+ {
+ this._value = value;
+ }
+
+ /**
+ * The action to take when this command is invoked.
+ * <p>
+ * If the value is an expression, it is expected to be a method binding EL expression that identifies
+ * an action method. An action method accepts no parameters and has a String return value, called the
+ * action outcome, that identifies the next view displayed. The phase that this event is fired in
+ * can be controlled via the immediate attribute.
+ * <p>
+ * If the value is a string literal, it is treated as a navigation outcome for the current view. This
+ * is functionally equivalent to a reference to an action method that returns the string literal.
+ */
+ @JSFProperty(stateHolder = true, returnSignature = "java.lang.Object", jspName = "action")
+ public MethodExpression getActionExpression()
+ {
+ if (_actionExpression != null)
+ {
+ return _actionExpression;
+ }
+ ValueExpression expression = getValueExpression("actionExpression");
+ if (expression != null)
+ {
+ return (MethodExpression) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return null;
+ }
+
+ public void setActionExpression(MethodExpression actionExpression)
+ {
+ this._actionExpression = actionExpression;
+ }
+
+ /**
+ * A method binding EL expression that identifies an action listener method to be invoked if
+ * this component is activated by the user.
+ * <p>
+ * An action listener method accepts a parameter of type javax.faces.event.ActionEvent and returns void.
+ * The phase that this event is fired in can be controlled via the immediate attribute.
+ *
+ * @deprecated
+ */
+ @Deprecated
+ @JSFProperty(stateHolder = true, returnSignature = "void", methodSignature = "javax.faces.event.ActionEvent")
+ public MethodBinding getActionListener()
+ {
+ if (_actionListener != null)
+ {
+ return _actionListener;
+ }
+ ValueExpression expression = getValueExpression("actionListener");
+ if (expression != null)
+ {
+ return (MethodBinding) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return null;
+ }
+
+ @Deprecated
+ @JSFProperty(returnSignature="void",methodSignature="javax.faces.event.ActionEvent")
+ public void setActionListener(MethodBinding actionListener)
+ {
+ this._actionListener = actionListener;
+ }
+
+ public void addActionListener(ActionListener listener)
+ {
+ addFacesListener(listener);
+ }
+
+ public void removeActionListener(ActionListener listener)
+ {
+ removeFacesListener(listener);
+ }
+
+ public ActionListener[] getActionListeners()
+ {
+ return (ActionListener[]) getFacesListeners(ActionListener.class);
+ }
+
+ @Override
+ public Object saveState(FacesContext facesContext)
+ {
+ Object[] values = new Object[6];
+ values[0] = super.saveState(facesContext);
+ values[1] = _immediate;
+ values[2] = _immediateSet;
+ values[3] = _value;
+ values[4] = saveAttachedState(facesContext, _actionExpression);
+ values[5] = saveAttachedState(facesContext, _actionListener);
+
+ return values;
+ }
+
+ @Override
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(facesContext, values[0]);
+ _immediate = (Boolean) values[1];
+ _immediateSet = (Boolean) values[2];
+ _value = values[3];
+ _actionExpression = (MethodExpression) restoreAttachedState(
+ facesContext, values[4]);
+ _actionListener = (MethodBinding) restoreAttachedState(facesContext,
+ values[5]);
+ }
+
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
}
Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIGraphic.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIGraphic.java?rev=684592&r1=684591&r2=684592&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIGraphic.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIGraphic.java Sun Aug 10 13:59:44 2008
@@ -20,47 +20,56 @@
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
+
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
/**
- *
* Displays a graphical image.
+ * <p>
+ * See the javadoc for this class in the
+ * <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
+ * for further details.
*/
-@JSFComponent
-(defaultRendererType = "javax.faces.Image"
-)
+@JSFComponent(defaultRendererType = "javax.faces.Image")
public class UIGraphic extends UIComponentBase
{
+ static final String COMPONENT_TYPE = "javax.faces.Graphic";
+ private static final String COMPONENT_FAMILY = "javax.faces.Graphic";
- static public final String COMPONENT_FAMILY =
- "javax.faces.Graphic";
- static public final String COMPONENT_TYPE =
- "javax.faces.Graphic";
-
- /**
- * Construct an instance of the UIGraphic.
- */
- public UIGraphic()
- {
- setRendererType("javax.faces.Image");
- }
- private static final String URL_PROPERTY = "url";
+ private static final String URL_PROPERTY = "url";
private static final String VALUE_PROPERTY = "value";
-
-
- public void setUrl(String url)
+
+ private Object _value;
+
+ /**
+ * Construct an instance of the UIGraphic.
+ */
+ public UIGraphic()
+ {
+ setRendererType("javax.faces.Image");
+ }
+
+ @Override
+ public String getFamily()
{
- setValue(url);
+ return COMPONENT_FAMILY;
}
-
+
+ /**
+ * An alias for the "value" attribute.
+ */
@JSFProperty
public String getUrl()
{
- return (String)getValue();
+ return (String) getValue();
+ }
+
+ public void setUrl(String url)
+ {
+ setValue(url);
}
-
+
@Override
public ValueExpression getValueExpression(String name)
{
@@ -75,8 +84,7 @@
}
@Override
- public void setValueExpression(String name,
- ValueExpression binding)
+ public void setValueExpression(String name, ValueExpression binding)
{
if (URL_PROPERTY.equals(name))
{
@@ -88,65 +96,46 @@
}
}
- // Property: value
- private Object _value;
+ /**
+ * The URL of the image.
+ * <p>
+ * If the URL starts with a '/', it is relative to the context path of the web application.
+ */
+ @JSFProperty
+ public Object getValue()
+ {
+ if (_value != null)
+ {
+ return _value;
+ }
+ ValueExpression expression = getValueExpression("value");
+ if (expression != null)
+ {
+ return expression.getValue(getFacesContext().getELContext());
+ }
+ return null;
+ }
+
+ public void setValue(Object value)
+ {
+ this._value = value;
+ }
+
+ @Override
+ public Object saveState(FacesContext facesContext)
+ {
+ Object[] values = new Object[2];
+ values[0] = super.saveState(facesContext);
+ values[1] = _value;
+
+ return values;
+ }
- /**
- * Gets The value property of the UIGraphic
- *
- * @return the new value value
- */
- @JSFProperty
- public Object getValue()
- {
- if (_value != null)
- {
- return _value;
- }
- ValueExpression expression = getValueExpression("value");
- if (expression != null)
- {
- return expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets The value property of the UIGraphic
- *
- * @param value the new value value
- */
- public void setValue(Object value)
- {
- this._value = value;
- }
-
- // Property: url
- private String _url;
-
- @Override
- public Object saveState(FacesContext facesContext)
- {
- Object[] values = new Object[3];
- values[0] = super.saveState(facesContext);
- values[1] = _value;
- values[2] = _url;
-
- return values;
- }
-
- @Override
- public void restoreState(FacesContext facesContext, Object state)
- {
- Object[] values = (Object[])state;
- super.restoreState(facesContext,values[0]);
- _value = values[1];
- _url = (String)values[2];
- }
-
- @Override
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
+ @Override
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(facesContext, values[0]);
+ _value = values[1];
+ }
}
Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java?rev=684592&r1=684591&r2=684592&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/UIInput.java Sun Aug 10 13:59:44 2008
@@ -38,9 +38,12 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
/**
- *
* UICommand is a base abstraction for components that implement ActionSource.
- *
+ * <p>
+ * See the javadoc for this class in the <a
+ * href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF
+ * Specification</a> for further details.
+ * <p>
* <h4>Events:</h4>
* <table border="1" width="100%" cellpadding="3" summary="">
* <tr bgcolor="#CCCCFF" class="TableHeadingColor">
@@ -51,42 +54,64 @@
* <tr class="TableRowColor">
* <td valign="top"><code>javax.faces.event.ValueChangeEvent</code></td>
* <td valign="top" nowrap></td>
- * <td valign="top">The valueChange event is delivered when the value
- attribute is changed.</td>
+ * <td valign="top">The valueChange event is delivered when the value attribute
+ * is changed.</td>
* </tr>
* </table>
*/
-@JSFComponent
-(defaultRendererType = "javax.faces.Text"
-)
-public class UIInput extends UIOutput
- implements EditableValueHolder
+@JSFComponent(defaultRendererType = "javax.faces.Text")
+public class UIInput extends UIOutput implements EditableValueHolder
{
+ static final String COMPONENT_TYPE = "javax.faces.Input";
+ public static final String COMPONENT_FAMILY = "javax.faces.Input";
- static public final String COMPONENT_FAMILY =
- "javax.faces.Input";
- static public final String COMPONENT_TYPE =
- "javax.faces.Input";
-
- /**
- * Construct an instance of the UIInput.
- */
- public UIInput()
- {
- setRendererType("javax.faces.Text");
- }
- public static final String CONVERSION_MESSAGE_ID = "javax.faces.component.UIInput.CONVERSION";
+ public static final String CONVERSION_MESSAGE_ID = "javax.faces.component.UIInput.CONVERSION";
public static final String REQUIRED_MESSAGE_ID = "javax.faces.component.UIInput.REQUIRED";
public static final String UPDATE_MESSAGE_ID = "javax.faces.component.UIInput.UPDATE";
private static final String ERROR_HANDLING_EXCEPTION_LIST = "org.apache.myfaces.errorHandling.exceptionList";
+ private static final Validator[] EMPTY_VALIDATOR_ARRAY = new Validator[0];
+
+ private boolean _immediate;
+ private boolean _immediateSet;
+
+ private Object _submittedValue;
+ private boolean _localValueSet = false;
+
+ private boolean _valid = true;
+
+ private boolean _required;
+ private boolean _requiredSet;
+
+ private String _converterMessage;
+ private String _requiredMessage;
+ private String _validatorMessage;
+
+ private MethodBinding _validator;
+ private List<Validator> _validatorList;
+
+ private MethodBinding _valueChangeListener;
+
/**
- * Store the specified object as the "local value" of this component.
- * The value-binding named "value" (if any) is ignored; the object is
- * only stored locally on this component. During the "update model"
- * phase, if there is a value-binding named "value" then this local
- * value will be stored via that value-binding and the "local value"
- * reset to null.
+ * Construct an instance of the UIInput.
+ */
+ public UIInput()
+ {
+ setRendererType("javax.faces.Text");
+ }
+
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ /**
+ * Store the specified object as the "local value" of this component. The
+ * value-binding named "value" (if any) is ignored; the object is only
+ * stored locally on this component. During the "update model" phase, if
+ * there is a value-binding named "value" then this local value will be
+ * stored via that value-binding and the "local value" reset to null.
*/
public void setValue(Object value)
{
@@ -95,26 +120,32 @@
}
/**
- * Set the "submitted value" of this component from the relevant data
- * in the current servet request object.
+ * Set the "submitted value" of this component from the relevant data in the
+ * current servlet request object.
* <p>
- * If this component is not rendered, then do nothing; no output would
- * have been sent to the client so no input is expected.
+ * If this component is not rendered, then do nothing; no output would have
+ * been sent to the client so no input is expected.
* <p>
- * Invoke the inherited functionality, which typically invokes the
- * renderer associated with this component to extract and set this
- * component's "submitted value".
+ * Invoke the inherited functionality, which typically invokes the renderer
+ * associated with this component to extract and set this component's
+ * "submitted value".
* <p>
* If this component is marked "immediate", then immediately apply
- * validation to the submitted value found. On error, call context
- * method "renderResponse" which will force processing to leap to
- * the "render response" phase as soon as the "decode" step has
- * completed for all other components.
+ * validation to the submitted value found. On error, call context method
+ * "renderResponse" which will force processing to leap to the "render
+ * response" phase as soon as the "decode" step has completed for all other
+ * components.
*/
public void processDecodes(FacesContext context)
{
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
+ if (context == null)
+ {
+ throw new NullPointerException("context");
+ }
+ if (!isRendered())
+ {
+ return;
+ }
super.processDecodes(context);
if (isImmediate())
{
@@ -136,8 +167,14 @@
public void processValidators(FacesContext context)
{
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
+ if (context == null)
+ {
+ throw new NullPointerException("context");
+ }
+ if (!isRendered())
+ {
+ return;
+ }
super.processValidators(context);
@@ -161,8 +198,14 @@
public void processUpdates(FacesContext context)
{
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
+ if (context == null)
+ {
+ throw new NullPointerException("context");
+ }
+ if (!isRendered())
+ {
+ return;
+ }
super.processUpdates(context);
@@ -183,19 +226,19 @@
public void decode(FacesContext context)
{
- //We (re)set to valid, so that component automatically gets (re)validated
+ // We (re)set to valid, so that component automatically gets (re)validated
setValid(true);
super.decode(context);
}
- public void broadcast(FacesEvent event)
- throws AbortProcessingException
+ public void broadcast(FacesEvent event) throws AbortProcessingException
{
// invoke standard listeners attached to this component first
super.broadcast(event);
- //Check if the event is applicable for ValueChangeListener
- if (event instanceof ValueChangeEvent){
+ // Check if the event is applicable for ValueChangeListener
+ if (event instanceof ValueChangeEvent)
+ {
// invoke the single listener defined directly on the component
MethodBinding valueChangeListenerBinding = getValueChangeListener();
if (valueChangeListenerBinding != null)
@@ -203,14 +246,16 @@
try
{
valueChangeListenerBinding.invoke(getFacesContext(),
- new Object[]{event});
+ new Object[]
+ { event });
}
catch (EvaluationException e)
{
Throwable cause = e.getCause();
- if (cause != null && cause instanceof AbortProcessingException)
+ if (cause != null
+ && cause instanceof AbortProcessingException)
{
- throw (AbortProcessingException)cause;
+ throw (AbortProcessingException) cause;
}
else
{
@@ -223,10 +268,20 @@
public void updateModel(FacesContext context)
{
- if (!isValid()) return;
- if (!isLocalValueSet()) return;
+ if (!isValid())
+ {
+ return;
+ }
+ if (!isLocalValueSet())
+ {
+ return;
+ }
ValueExpression expression = getValueExpression("value");
- if (expression == null) return;
+ if (expression == null)
+ {
+ return;
+ }
+
try
{
expression.setValue(context.getELContext(), getLocalValue());
@@ -236,49 +291,61 @@
catch (Exception e)
{
context.getExternalContext().log(e.getMessage(), e);
- _MessageUtils.addErrorMessage(context, this, UPDATE_MESSAGE_ID, new Object[]{_MessageUtils.getLabel(context,this)});
+ _MessageUtils.addErrorMessage(context, this, UPDATE_MESSAGE_ID,
+ new Object[]
+ { _MessageUtils.getLabel(context, this) });
setValid(false);
- /* we are not allowed to throw exceptions here - we still need the full stack-trace later on
- * to process it later in our error-handler
+ /*
+ * we are not allowed to throw exceptions here - we still need the
+ * full stack-trace later on to process it later in our
+ * error-handler
*/
queueExceptionInRequest(context, expression, e);
}
}
/**
- * For development and production, we want to offer a single point
- * to which error-handlers can attach. So we queue up all ocurring
- * exceptions and later pass them to the configured error-handler.
- *
- * @param context
- * @param expression
- * @param e
+ * For development and production, we want to offer a single point to which
+ * error-handlers can attach. So we queue up all ocurring exceptions and
+ * later pass them to the configured error-handler.
*/
- private void queueExceptionInRequest(FacesContext context, ValueExpression expression, Exception e) {
+ private void queueExceptionInRequest(FacesContext context,
+ ValueExpression expression, Exception e)
+ {
List li = (List) context.getExternalContext().getRequestMap().get(ERROR_HANDLING_EXCEPTION_LIST);
- if(null==li) {
+ if (null == li)
+ {
li = new ArrayList();
context.getExternalContext().getRequestMap().put(ERROR_HANDLING_EXCEPTION_LIST, li);
}
- li.add(new FacesException("Exception while setting value for expression : "+
- expression.getExpressionString()+" of component with path : "
- + _ComponentUtils.getPathToComponent(this),e));
+ li.add(new FacesException(
+ "Exception while setting value for expression : "
+ + expression.getExpressionString()
+ + " of component with path : "
+ + _ComponentUtils.getPathToComponent(this), e));
}
- protected void validateValue(FacesContext context,Object convertedValue)
- {
- boolean empty = convertedValue == null ||
- (convertedValue instanceof String
- && ((String)convertedValue).length() == 0);
+ protected void validateValue(FacesContext context, Object convertedValue)
+ {
+ boolean empty = convertedValue == null
+ || (convertedValue instanceof String && ((String) convertedValue)
+ .length() == 0);
if (isRequired() && empty)
{
- if(getRequiredMessage() != null) {
+ if (getRequiredMessage() != null)
+ {
String requiredMessage = getRequiredMessage();
- context.addMessage(this.getClientId(context),new FacesMessage(FacesMessage.SEVERITY_ERROR,requiredMessage,requiredMessage));
- } else {
- _MessageUtils.addErrorMessage(context, this, REQUIRED_MESSAGE_ID,new Object[]{_MessageUtils.getLabel(context,this)});
+ context.addMessage(this.getClientId(context), new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, requiredMessage,
+ requiredMessage));
+ }
+ else
+ {
+ _MessageUtils.addErrorMessage(context, this,
+ REQUIRED_MESSAGE_ID, new Object[]
+ { _MessageUtils.getLabel(context, this) });
}
setValid(false);
return;
@@ -292,22 +359,22 @@
}
/**
- * Determine whether the new value is valid, and queue a ValueChangeEvent
- * if necessary.
+ * Determine whether the new value is valid, and queue a ValueChangeEvent if
+ * necessary.
* <p>
* The "submitted value" is converted to the necessary type; conversion
- * failure is reported as an error and validation processing terminates
- * for this component. See documentation for method getConvertedValue
- * for details on the conversion process.
- * <p>
- * Any validators attached to this component are then run, passing
- * the converted value.
- * <p>
- * The old value of this component is then fetched (possibly involving
- * the evaluation of a value-binding expression, ie invoking a method
- * on a user object). The old value is compared to the new validated
- * value, and if they are different then a ValueChangeEvent is queued
- * for later processing.
+ * failure is reported as an error and validation processing terminates for
+ * this component. See documentation for method getConvertedValue for
+ * details on the conversion process.
+ * <p>
+ * Any validators attached to this component are then run, passing the
+ * converted value.
+ * <p>
+ * The old value of this component is then fetched (possibly involving the
+ * evaluation of a value-binding expression, ie invoking a method on a user
+ * object). The old value is compared to the new validated value, and if
+ * they are different then a ValueChangeEvent is queued for later
+ * processing.
* <p>
* On successful completion of this method:
* <ul>
@@ -319,32 +386,40 @@
*/
public void validate(FacesContext context)
{
- if (context == null) throw new NullPointerException("context");
-
- try {
+ if (context == null)
+ throw new NullPointerException("context");
+
+ try
+ {
Object submittedValue = getSubmittedValue();
- if (submittedValue == null) return;
+ if (submittedValue == null)
+ return;
Object convertedValue = getConvertedValue(context, submittedValue);
- if (!isValid()) return;
+ if (!isValid())
+ return;
validateValue(context, convertedValue);
- if (!isValid()) return;
+ if (!isValid())
+ return;
Object previousValue = getValue();
setValue(convertedValue);
setSubmittedValue(null);
if (compareValues(previousValue, convertedValue))
{
- queueEvent(new ValueChangeEvent(this, previousValue, convertedValue));
+ queueEvent(new ValueChangeEvent(this, previousValue,
+ convertedValue));
}
}
catch (Exception ex)
{
- throw new FacesException("Exception while validating component with path : "+_ComponentUtils.getPathToComponent(this),ex);
+ throw new FacesException(
+ "Exception while validating component with path : "
+ + _ComponentUtils.getPathToComponent(this), ex);
}
}
@@ -353,22 +428,21 @@
* Convert the provided object to the desired value.
* <p>
* If there is a renderer for this component, then call the renderer's
- * getConvertedValue method. While this can of course be implemented in
- * any way the renderer desires, it typically performs exactly the same
+ * getConvertedValue method. While this can of course be implemented in any
+ * way the renderer desires, it typically performs exactly the same
* processing that this method would have done anyway (ie that described
* below for the no-renderer case).
* <p>
* Otherwise:
* <ul>
* <li>If the submittedValue is not a String then just return the
- * submittedValue unconverted.
+ * submittedValue unconverted.
* <li>If there is no "value" value-binding then just return the
- * submittedValue unconverted.
- * <li>Use introspection to determine the type of the target
- * property specified by the value-binding, and then use
- * Application.createConverter to find a converter that can
- * map from String to the required type. Apply the converter
- * to the submittedValue and return the result.
+ * submittedValue unconverted.
+ * <li>Use introspection to determine the type of the target property
+ * specified by the value-binding, and then use Application.createConverter
+ * to find a converter that can map from String to the required type. Apply
+ * the converter to the submittedValue and return the result.
* </ul>
*/
protected Object getConvertedValue(FacesContext context, Object submittedValue)
@@ -378,47 +452,53 @@
Renderer renderer = getRenderer(context);
if (renderer != null)
{
- return renderer.getConvertedValue(context, this, submittedValue);
+ return renderer
+ .getConvertedValue(context, this, submittedValue);
}
else if (submittedValue instanceof String)
{
- Converter converter = _SharedRendererUtils.findUIOutputConverter(context, this);
+ Converter converter = _SharedRendererUtils
+ .findUIOutputConverter(context, this);
if (converter != null)
{
- return converter.getAsObject(context, this, (String)submittedValue);
+ return converter.getAsObject(context, this,
+ (String) submittedValue);
}
}
}
catch (ConverterException e)
{
String converterMessage = getConverterMessage();
- if(converterMessage != null) {
- context.addMessage(getClientId(context),new FacesMessage(FacesMessage.SEVERITY_ERROR,converterMessage,converterMessage));
- } else {
- FacesMessage facesMessage = e.getFacesMessage();
- if (facesMessage != null)
- {
- context.addMessage(getClientId(context), facesMessage);
- }
- else
- {
- _MessageUtils.addErrorMessage(context, this, CONVERSION_MESSAGE_ID,new Object[]{_MessageUtils.getLabel(context,this)});
- }
+ if (converterMessage != null)
+ {
+ context.addMessage(getClientId(context), new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, converterMessage,
+ converterMessage));
+ }
+ else
+ {
+ FacesMessage facesMessage = e.getFacesMessage();
+ if (facesMessage != null)
+ {
+ context.addMessage(getClientId(context), facesMessage);
+ }
+ else
+ {
+ _MessageUtils.addErrorMessage(context, this,
+ CONVERSION_MESSAGE_ID, new Object[]
+ { _MessageUtils.getLabel(context, this) });
+ }
}
setValid(false);
}
return submittedValue;
}
-
-
- protected boolean compareValues(Object previous,
- Object value)
+ protected boolean compareValues(Object previous, Object value)
{
- return previous==null?(value!=null):(!previous.equals(value));
+ return previous == null ? (value != null) : (!previous.equals(value));
}
-
/**
* @since 1.2
*/
@@ -430,480 +510,350 @@
setValid(true);
}
- // Property: immediate
- private boolean _immediate;
- private boolean _immediateSet;
-
- /**
- * Gets A boolean value that identifies the phase during which action events
- * should fire. During normal event processing, action methods and
- * action listener methods are fired during the "invoke application"
- * phase of request processing. If this attribute is set to "true",
- * these methods are fired instead at the end of the "apply request
- * values" phase.
- *
- * @return the new immediate value
- */
- @JSFProperty
- public boolean isImmediate()
- {
- if (_immediateSet)
- {
- return _immediate;
- }
- ValueExpression expression = getValueExpression("immediate");
- if (expression != null)
- {
- return (Boolean)expression.getValue(getFacesContext().getELContext());
- }
- return false;
- }
-
- /**
- * Sets A boolean value that identifies the phase during which action events
- * should fire. During normal event processing, action methods and
- * action listener methods are fired during the "invoke application"
- * phase of request processing. If this attribute is set to "true",
- * these methods are fired instead at the end of the "apply request
- * values" phase.
- *
- * @param immediate the new immediate value
- */
- public void setImmediate(boolean immediate)
- {
- this._immediate = immediate;
- this._immediateSet = true;
- }
-
- // Property: required
- private boolean _required;
- private boolean _requiredSet;
-
- /**
- * Gets A boolean value that indicates whether a value is required. Default value: false.
- *
- * @return the new required value
- */
- @JSFProperty
- (defaultValue = "false")
- public boolean isRequired()
- {
- if (_requiredSet)
- {
- return _required;
- }
- ValueExpression expression = getValueExpression("required");
- if (expression != null)
- {
- return (Boolean)expression.getValue(getFacesContext().getELContext());
- }
- return false;
- }
-
- /**
- * Sets A boolean value that indicates whether a value is required. Default value: false.
- *
- * @param required the new required value
- */
- public void setRequired(boolean required)
- {
- this._required = required;
- this._requiredSet = true;
- }
-
- // Property: converterMessage
- private String _converterMessage;
-
- /**
- * Gets Text of the converter message.
- *
- * @return the new converterMessage value
- */
- @JSFProperty
- public String getConverterMessage()
- {
- if (_converterMessage != null)
- {
- return _converterMessage;
- }
- ValueExpression expression = getValueExpression("converterMessage");
- if (expression != null)
- {
- return (String)expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets Text of the converter message.
- *
- * @param converterMessage the new converterMessage value
- */
- public void setConverterMessage(String converterMessage)
- {
- this._converterMessage = converterMessage;
- }
-
- // Property: requiredMessage
- private String _requiredMessage;
-
- /**
- * Gets Text which will be shown if a required value is not submitted.
- *
- * @return the new requiredMessage value
- */
- @JSFProperty
- public String getRequiredMessage()
- {
- if (_requiredMessage != null)
- {
- return _requiredMessage;
- }
- ValueExpression expression = getValueExpression("requiredMessage");
- if (expression != null)
- {
- return (String)expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets Text which will be shown if a required value is not submitted.
- *
- * @param requiredMessage the new requiredMessage value
- */
- public void setRequiredMessage(String requiredMessage)
- {
- this._requiredMessage = requiredMessage;
- }
-
- // Property: validator
- private MethodBinding _validator;
-
- /**
- * Gets A method which is invoked during the validation phase for this component. It is
- * expected to check the submitted value for this component, and if not acceptable
- * then report a validation error for the component.
- *
- * @return the new validator value
- * @deprecated
- */
- @JSFProperty
- (stateHolder = true,
- returnSignature = "void",
- methodSignature = "javax.faces.context.FacesContext,javax.faces.component.UIComponent,java.lang.Object")
- public MethodBinding getValidator()
- {
- if (_validator != null)
- {
- return _validator;
- }
- ValueExpression expression = getValueExpression("validator");
- if (expression != null)
- {
- return (MethodBinding)expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets A method which is invoked during the validation phase for this component. It is
- * expected to check the submitted value for this component, and if not acceptable
- * then report a validation error for the component.
- *
- * @param validator the new validator value
- * @deprecated
- */
- public void setValidator(MethodBinding validator)
- {
- this._validator = validator;
- }
-
- // Property: validator
- private List<Validator> _validatorList;
-
- /**
- * Adds a A method which is invoked during the validation phase for this component. It is
- * expected to check the submitted value for this component, and if not acceptable
- * then report a validation error for the component.
- */
- public void addValidator( Validator validator)
- {
- if (validator == null) throw new NullPointerException("validator");
- if (_validatorList == null)
- _validatorList = new ArrayList<Validator>();
-
- _validatorList.add(validator);
- }
-
- /**
- * Removes a A method which is invoked during the validation phase for this component. It is
- * expected to check the submitted value for this component, and if not acceptable
- * then report a validation error for the component.
- */
- public void removeValidator( Validator validator)
- {
- if (validator == null || _validatorList == null)
- return;
-
- _validatorList.remove(validator);
- }
- private static final Validator[] EMPTY_VALIDATOR_ARRAY = new Validator[0];
-
- /**
- * Gets all A method which is invoked during the validation phase for this component. It is
- * expected to check the submitted value for this component, and if not acceptable
- * then report a validation error for the component.
- */
- public Validator[] getValidators()
- {
- return _validatorList== null? EMPTY_VALIDATOR_ARRAY : _validatorList.toArray(new Validator[_validatorList.size()]);
- }
-
- // Property: validatorMessage
- private String _validatorMessage;
-
- /**
- * Gets Text which will be shown, if validation fails.
- *
- * @return the new validatorMessage value
- */
- @JSFProperty
- public String getValidatorMessage()
- {
- if (_validatorMessage != null)
- {
- return _validatorMessage;
- }
- ValueExpression expression = getValueExpression("validatorMessage");
- if (expression != null)
- {
- return (String)expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets Text which will be shown, if validation fails.
- *
- * @param validatorMessage the new validatorMessage value
- */
- public void setValidatorMessage(String validatorMessage)
- {
- this._validatorMessage = validatorMessage;
- }
-
- // Property: valueChangeListener
- private MethodBinding _valueChangeListener;
-
- /**
- * Gets A method which is invoked during postback processing for the current view if the
- * submitted value for this component is not equal to the value which the "value" expression
- * for this component returns. The phase in which this method is invoked can be controlled
- * via the immediate attribute.
- *
- * @return the new valueChangeListener value
- * @deprecated
- */
- @JSFProperty
- (stateHolder = true,
- returnSignature = "void",
- methodSignature = "javax.faces.event.ValueChangeEvent")
- public MethodBinding getValueChangeListener()
- {
- if (_valueChangeListener != null)
- {
- return _valueChangeListener;
- }
- ValueExpression expression = getValueExpression("valueChangeListener");
- if (expression != null)
- {
- return (MethodBinding)expression.getValue(getFacesContext().getELContext());
- }
- return null;
- }
-
- /**
- * Sets A method which is invoked during postback processing for the current view if the
- * submitted value for this component is not equal to the value which the "value" expression
- * for this component returns. The phase in which this method is invoked can be controlled
- * via the immediate attribute.
- *
- * @param valueChangeListener the new valueChangeListener value
- * @deprecated
- */
- public void setValueChangeListener(MethodBinding valueChangeListener)
- {
- this._valueChangeListener = valueChangeListener;
- }
-
- // Property: valid
- private boolean _valid = true;
-
- /**
- * Gets whether the component's value is currently valid
- *
- * @return the new valid value
- */
- @JSFProperty
- (defaultValue = "true",
- tagExcluded = true)
- public boolean isValid()
- {
- return _valid;
- }
-
- /**
- * Sets whether the component's value is currently valid
- *
- * @param valid the new valid value
- */
- public void setValid(boolean valid)
- {
- this._valid = valid;
- }
-
- // Property: localValueSet
- private boolean _localValueSet = false;
-
- /**
- * Gets whether a local value is currently set. If false, values are being retrieved from any attached ValueBinding
- *
- * @return the new localValueSet value
- */
- @JSFProperty
- (defaultValue = "false",
- tagExcluded = true)
- public boolean isLocalValueSet()
- {
- return _localValueSet;
- }
-
- /**
- * Sets whether a local value is currently set. If false, values are being retrieved from any attached ValueBinding
- *
- * @param localValueSet the new localValueSet value
- */
- public void setLocalValueSet(boolean localValueSet)
- {
- this._localValueSet = localValueSet;
- }
-
- // Property: submittedValue
- private Object _submittedValue;
-
- /**
- * Gets the current submitted value. This value,
- * if non-null, is set by the Renderer to store a possibly invalid value
- * for later conversion or redisplay, and has not yet been converted
- * into the proper type for this component instance. This method
- * should only be used by the decode() and validate() method
- * of this component, or its corresponding Renderer; however, user code
- * may manually set it to null to erase any submitted value.
- *
- * @return the new submittedValue value
- */
- @JSFProperty
- (tagExcluded = true)
- public Object getSubmittedValue()
- {
- return _submittedValue;
- }
-
- /**
- * Sets the current submitted value. This value,
- * if non-null, is set by the Renderer to store a possibly invalid value
- * for later conversion or redisplay, and has not yet been converted
- * into the proper type for this component instance. This method
- * should only be used by the decode() and validate() method
- * of this component, or its corresponding Renderer; however, user code
- * may manually set it to null to erase any submitted value.
- *
- * @param submittedValue the new submittedValue value
- */
- public void setSubmittedValue(Object submittedValue)
- {
- this._submittedValue = submittedValue;
- }
-
- /**
- * Adds a valueChange listener.
- *
- * @param listener the valueChange listener to add
- */
- public void addValueChangeListener(
- ValueChangeListener listener)
- {
- addFacesListener(listener);
- }
-
- /**
- * Removes a valueChange listener.
- *
- * @param listener the valueChange listener to remove
- */
- public void removeValueChangeListener(
- ValueChangeListener listener)
- {
- removeFacesListener(listener);
- }
-
- /**
- * Returns an array of attached valueChange listeners.
- *
- * @return an array of attached valueChange listeners.
- */
- public ValueChangeListener[] getValueChangeListeners()
- {
- return (ValueChangeListener[])getFacesListeners(ValueChangeListener.class);
- }
-
- @Override
- public Object saveState(FacesContext facesContext)
- {
- Object[] values = new Object[14];
- values[0] = super.saveState(facesContext);
- values[1] = _immediate;
- values[2] = _immediateSet;
- values[3] = _required;
- values[4] = _requiredSet;
- values[5] = _converterMessage;
- values[6] = _requiredMessage;
- values[7] = saveAttachedState(facesContext, _validator);
- values[8] = saveAttachedState(facesContext, _validatorList);
- values[9] = _validatorMessage;
- values[10] = saveAttachedState(facesContext, _valueChangeListener);
- values[11] = _valid;
- values[12] = _localValueSet;
- values[13] = _submittedValue;
-
-
- return values;
- }
-
- @Override
- public void restoreState(FacesContext facesContext, Object state)
- {
- Object[] values = (Object[])state;
- super.restoreState(facesContext,values[0]);
- _immediate = (Boolean)values[1];
- _immediateSet = (Boolean)values[2];
- _required = (Boolean)values[3];
- _requiredSet = (Boolean)values[4];
- _converterMessage = (String)values[5];
- _requiredMessage = (String)values[6];
- _validator = (MethodBinding)restoreAttachedState(facesContext, values[7]);
- _validatorList = (List<Validator>) restoreAttachedState(facesContext, values[8]);
- _validatorMessage = (String)values[9];
- _valueChangeListener = (MethodBinding)restoreAttachedState(facesContext, values[10]);
- _valid = (Boolean)values[11];
- _localValueSet = (Boolean)values[12];
- _submittedValue = values[13];
- }
-
- @Override
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
+ /**
+ * A boolean value that identifies the phase during which action events should fire.
+ * <p>
+ * During normal event processing, action methods and action listener methods are fired during
+ * the "invoke application" phase of request processing. If this attribute is set to "true",
+ * these methods are fired instead at the end of the "apply request values" phase.
+ */
+ @JSFProperty
+ public boolean isImmediate()
+ {
+ if (_immediateSet)
+ {
+ return _immediate;
+ }
+ ValueExpression expression = getValueExpression("immediate");
+ if (expression != null)
+ {
+ return (Boolean) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return false;
+ }
+
+ public void setImmediate(boolean immediate)
+ {
+ this._immediate = immediate;
+ this._immediateSet = true;
+ }
+
+ /**
+ * A boolean value that indicates whether an input value is required.
+ * <p>
+ * If this value is true and no input value is provided by a postback operation, then
+ * the "requiredMessage" text is registered as a FacesMessage for the request, and
+ * validation fails.
+ * <p>
+ * Default value: false.
+ */
+ @JSFProperty(defaultValue = "false")
+ public boolean isRequired()
+ {
+ if (_requiredSet)
+ {
+ return _required;
+ }
+ ValueExpression expression = getValueExpression("required");
+ if (expression != null)
+ {
+ return (Boolean) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return false;
+ }
+
+ public void setRequired(boolean required)
+ {
+ this._required = required;
+ this._requiredSet = true;
+ }
+
+ /**
+ * Text to be displayed to the user as an error message when conversion of a
+ * submitted value to the target type fails.
+ * <p>
+ */
+ @JSFProperty
+ public String getConverterMessage()
+ {
+ if (_converterMessage != null)
+ {
+ return _converterMessage;
+ }
+ ValueExpression expression = getValueExpression("converterMessage");
+ if (expression != null)
+ {
+ return (String) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return null;
+ }
+
+ public void setConverterMessage(String converterMessage)
+ {
+ this._converterMessage = converterMessage;
+ }
+
+ /**
+ * Text to be displayed to the user as an error message when this component is
+ * marked as "required" but no input data is present during a postback (ie the
+ * user left the required field blank).
+ */
+ @JSFProperty
+ public String getRequiredMessage()
+ {
+ if (_requiredMessage != null)
+ {
+ return _requiredMessage;
+ }
+ ValueExpression expression = getValueExpression("requiredMessage");
+ if (expression != null)
+ {
+ return (String) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return null;
+ }
+
+ public void setRequiredMessage(String requiredMessage)
+ {
+ this._requiredMessage = requiredMessage;
+ }
+
+ /**
+ * A method-binding EL expression which is invoked during the validation phase for this
+ * component.
+ * <p>
+ * The invoked method is expected to check the submitted value for this component, and if not
+ * acceptable then report a validation error for the component.
+ * <p>
+ * The method is expected to have the prototype
+ * <code>public void aMethod(FacesContext, UIComponent,Object)</code>
+ *
+ * @deprecated
+ */
+ @JSFProperty(stateHolder = true, returnSignature = "void", methodSignature = "javax.faces.context.FacesContext,javax.faces.component.UIComponent,java.lang.Object")
+ public MethodBinding getValidator()
+ {
+ if (_validator != null)
+ {
+ return _validator;
+ }
+ ValueExpression expression = getValueExpression("validator");
+ if (expression != null)
+ {
+ return (MethodBinding) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return null;
+ }
+
+ /** See getValidator. */
+ @Deprecated
+ public void setValidator(MethodBinding validator)
+ {
+ this._validator = validator;
+ }
+
+ /** See getValidator. */
+ public void addValidator(Validator validator)
+ {
+ if (validator == null)
+ throw new NullPointerException("validator");
+ if (_validatorList == null)
+ _validatorList = new ArrayList<Validator>();
+
+ _validatorList.add(validator);
+ }
+
+ /** See getValidator. */
+ public void removeValidator(Validator validator)
+ {
+ if (validator == null || _validatorList == null)
+ return;
+
+ _validatorList.remove(validator);
+ }
+
+ /** See getValidator. */
+ public Validator[] getValidators()
+ {
+ return _validatorList == null ? EMPTY_VALIDATOR_ARRAY : _validatorList
+ .toArray(new Validator[_validatorList.size()]);
+ }
+
+ /**
+ * Text which will be shown if validation fails.
+ */
+ @JSFProperty
+ public String getValidatorMessage()
+ {
+ if (_validatorMessage != null)
+ {
+ return _validatorMessage;
+ }
+ ValueExpression expression = getValueExpression("validatorMessage");
+ if (expression != null)
+ {
+ return (String) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return null;
+ }
+
+ public void setValidatorMessage(String validatorMessage)
+ {
+ this._validatorMessage = validatorMessage;
+ }
+
+ /**
+ * A method which is invoked during postback processing for the current
+ * view if the submitted value for this component is not equal to the value
+ * which the "value" expression for this component returns.
+ * <p>
+ * The phase in which this method is invoked can be controlled via the immediate
+ * attribute.
+ *
+ * @deprecated
+ */
+ @Deprecated
+ @JSFProperty(stateHolder = true, returnSignature = "void", methodSignature = "javax.faces.event.ValueChangeEvent")
+ public MethodBinding getValueChangeListener()
+ {
+ if (_valueChangeListener != null)
+ {
+ return _valueChangeListener;
+ }
+ ValueExpression expression = getValueExpression("valueChangeListener");
+ if (expression != null)
+ {
+ return (MethodBinding) expression.getValue(getFacesContext()
+ .getELContext());
+ }
+ return null;
+ }
+
+ /**
+ * See getValueChangeListener.
+ *
+ * @deprecated
+ */
+ @Deprecated
+ public void setValueChangeListener(MethodBinding valueChangeListener)
+ {
+ this._valueChangeListener = valueChangeListener;
+ }
+
+ /**
+ * Specifies whether the component's value is currently valid, ie whether the
+ * validators attached to this component have allowed it.
+ */
+ @JSFProperty(defaultValue = "true", tagExcluded = true)
+ public boolean isValid()
+ {
+ return _valid;
+ }
+
+ public void setValid(boolean valid)
+ {
+ this._valid = valid;
+ }
+
+ /**
+ * Specifies whether a local value is currently set.
+ * <p>
+ * If false, values are being retrieved from any attached ValueBinding.
+ */
+ @JSFProperty(defaultValue = "false", tagExcluded = true)
+ public boolean isLocalValueSet()
+ {
+ return _localValueSet;
+ }
+
+ public void setLocalValueSet(boolean localValueSet)
+ {
+ this._localValueSet = localValueSet;
+ }
+
+ /**
+ * Gets the current submitted value. This value, if non-null, is set by the
+ * Renderer to store a possibly invalid value for later conversion or
+ * redisplay, and has not yet been converted into the proper type for this
+ * component instance. This method should only be used by the decode() and
+ * validate() method of this component, or its corresponding Renderer;
+ * however, user code may manually set it to null to erase any submitted
+ * value.
+ */
+ @JSFProperty(tagExcluded = true)
+ public Object getSubmittedValue()
+ {
+ return _submittedValue;
+ }
+
+ public void setSubmittedValue(Object submittedValue)
+ {
+ this._submittedValue = submittedValue;
+ }
+
+ public void addValueChangeListener(ValueChangeListener listener)
+ {
+ addFacesListener(listener);
+ }
+
+ public void removeValueChangeListener(ValueChangeListener listener)
+ {
+ removeFacesListener(listener);
+ }
+
+ public ValueChangeListener[] getValueChangeListeners()
+ {
+ return (ValueChangeListener[]) getFacesListeners(ValueChangeListener.class);
+ }
+
+ @Override
+ public Object saveState(FacesContext facesContext)
+ {
+ Object[] values = new Object[14];
+ values[0] = super.saveState(facesContext);
+ values[1] = _immediate;
+ values[2] = _immediateSet;
+ values[3] = _required;
+ values[4] = _requiredSet;
+ values[5] = _converterMessage;
+ values[6] = _requiredMessage;
+ values[7] = saveAttachedState(facesContext, _validator);
+ values[8] = saveAttachedState(facesContext, _validatorList);
+ values[9] = _validatorMessage;
+ values[10] = saveAttachedState(facesContext, _valueChangeListener);
+ values[11] = _valid;
+ values[12] = _localValueSet;
+ values[13] = _submittedValue;
+
+ return values;
+ }
+
+ @Override
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ Object[] values = (Object[]) state;
+ super.restoreState(facesContext, values[0]);
+ _immediate = (Boolean) values[1];
+ _immediateSet = (Boolean) values[2];
+ _required = (Boolean) values[3];
+ _requiredSet = (Boolean) values[4];
+ _converterMessage = (String) values[5];
+ _requiredMessage = (String) values[6];
+ _validator = (MethodBinding) restoreAttachedState(facesContext,
+ values[7]);
+ _validatorList = (List<Validator>) restoreAttachedState(facesContext,
+ values[8]);
+ _validatorMessage = (String) values[9];
+ _valueChangeListener = (MethodBinding) restoreAttachedState(
+ facesContext, values[10]);
+ _valid = (Boolean) values[11];
+ _localValueSet = (Boolean) values[12];
+ _submittedValue = values[13];
+ }
}