|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM Platform, Enterprise Edition, v 5.0
javax.faces.convert
|
Field Summary | |
---|---|
static String |
CONVERTER_ID
The standard converter id for this converter. |
static String |
DATE_ID
The message identifier of the FacesMessage to be created if
the conversion to Date fails. |
static String |
DATETIME_ID
The message identifier of the FacesMessage to be created if
the conversion to DateTime fails. |
static String |
STRING_ID
The message identifier of the FacesMessage to be created if
the conversion of the DateTime value to
String fails. |
static String |
TIME_ID
The message identifier of the FacesMessage to be created if
the conversion to Time fails. |
Constructor Summary | |
---|---|
DateTimeConverter()
|
Method Summary | |
---|---|
Object |
getAsObject(FacesContext context,
UIComponent component,
String value)
Convert the specified string value, which is associated with the specified UIComponent , into a model data object that
is appropriate for being stored during the Apply Request
Values phase of the request processing lifecycle. |
String |
getAsString(FacesContext context,
UIComponent component,
Object value)
Convert the specified model object value, which is associated with the specified UIComponent , into a String that is suitable
for being included in the response generated during the
Render Response phase of the request processing
lifeycle. |
String |
getDateStyle()
Return the style to be used to format or parse dates. |
Locale |
getLocale()
Return the Locale to be used when parsing or formatting
dates and times. |
String |
getPattern()
Return the format pattern to be used when formatting and parsing dates and times. |
String |
getTimeStyle()
Return the style to be used to format or parse times. |
TimeZone |
getTimeZone()
Return the TimeZone used to interpret a time value. |
String |
getType()
Return the type of value to be formatted or parsed. |
boolean |
isTransient()
If true, the Object implementing this interface must not participate in state saving or restoring. |
void |
restoreState(FacesContext context,
Object state)
Perform any processing required to restore the state from the entries in the state Object. |
Object |
saveState(FacesContext context)
Gets the state of the instance as a Serializable Object. |
void |
setDateStyle(String dateStyle)
Set the style to be used to format or parse dates. |
void |
setLocale(Locale locale)
Set the Locale to be used when parsing or formatting
dates and times. |
void |
setPattern(String pattern)
Set the format pattern to be used when formatting and parsing dates and times. |
void |
setTimeStyle(String timeStyle)
Set the style to be used to format or parse times. |
void |
setTimeZone(TimeZone timeZone)
Set the TimeZone used to interpret a time value. |
void |
setTransient(boolean transientFlag)
Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring. |
void |
setType(String type)
Set the type of value to be formatted or parsed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CONVERTER_ID
The standard converter id for this converter.
public static final String DATE_ID
The message identifier of the FacesMessage
to be created if
the conversion to Date
fails. The message format
string for this message may optionally include the following
placeholders:
{0}
replaced by the unconverted value.{1}
replaced by an example value.{2}
replaced by a String
whose value
is the label of the input component that produced this message.
public static final String TIME_ID
The message identifier of the FacesMessage
to be created if
the conversion to Time
fails. The message format
string for this message may optionally include the following
placeholders:
{0}
replaced by the unconverted value.{1}
replaced by an example value.{2}
replaced by a String
whose value
is the label of the input component that produced this message.
public static final String DATETIME_ID
The message identifier of the FacesMessage
to be created if
the conversion to DateTime
fails. The message format
string for this message may optionally include the following
placeholders:
{0}
replaced by the unconverted value.{1}
replaced by an example value.{2}
replaced by a String
whose value
is the label of the input component that produced this message.
public static final String STRING_ID
The message identifier of the FacesMessage
to be created if
the conversion of the DateTime
value to
String
fails. The message format string for this message
may optionally include the following placeholders:
{0}
relaced by the unconverted value.{1}
replaced by a String
whose value
is the label of the input component that produced this message.
Constructor Detail |
---|
public DateTimeConverter()
Method Detail |
---|
public String getDateStyle()
Return the style to be used to format or parse dates. If not set,
the default value, default
, is returned.
public void setDateStyle(String dateStyle)
Set the style to be used to format or parse dates. Valid values
are default
, short
, medium
,
long
, and full
.
An invalid value will cause a ConverterException
when
getAsObject()
or getAsString()
is called.
dateStyle
- The new style codepublic Locale getLocale()
Return the Locale
to be used when parsing or formatting
dates and times. If not explicitly set, the Locale
stored
in the UIViewRoot
for the current
request is returned.
public void setLocale(Locale locale)
Set the Locale
to be used when parsing or formatting
dates and times. If set to null
, the Locale
stored in the UIViewRoot
for the current
request will be utilized.
locale
- The new Locale
(or null
)public String getPattern()
Return the format pattern to be used when formatting and parsing dates and times.
public void setPattern(String pattern)
Set the format pattern to be used when formatting and parsing
dates and times. Valid values are those supported by
java.text.SimpleDateFormat
.
An invalid value will cause a ConverterException
when
getAsObject()
or getAsString()
is called.
pattern
- The new format patternpublic String getTimeStyle()
Return the style to be used to format or parse times. If not set,
the default value, default
, is returned.
public void setTimeStyle(String timeStyle)
Set the style to be used to format or parse times. Valid values
are default
, short
, medium
,
long
, and full
.
An invalid value will cause a ConverterException
when
getAsObject()
or getAsString()
is called.
timeStyle
- The new style codepublic TimeZone getTimeZone()
Return the TimeZone
used to interpret a time value.
If not explicitly set, the default time zone of GMT
returned.
public void setTimeZone(TimeZone timeZone)
Set the TimeZone
used to interpret a time value.
timeZone
- The new time zonepublic String getType()
Return the type of value to be formatted or parsed.
If not explicitly set, the default type, date
is returned.
public void setType(String type)
Set the type of value to be formatted or parsed.
Valid values are both
, date
, or
time
.
An invalid value will cause a ConverterException
when
getAsObject()
or getAsString()
is called.
type
- The new date stylepublic Object getAsObject(FacesContext context, UIComponent component, String value)
Converter
Convert the specified string value, which is associated with
the specified UIComponent
, into a model data object that
is appropriate for being stored during the Apply Request
Values phase of the request processing lifecycle.
getAsObject
in interface Converter
context
- FacesContext
for the request being processedcomponent
- UIComponent
with which this model object
value is associatedvalue
- String value to be converted (may be null
)
null
if the value to convert is null
,
otherwise the result of the conversion
ConverterException
- if conversion cannot be successfully
performed
NullPointerException
- if context
or
component
is null
public String getAsString(FacesContext context, UIComponent component, Object value)
Converter
Convert the specified model object value, which is associated with
the specified UIComponent
, into a String that is suitable
for being included in the response generated during the
Render Response phase of the request processing
lifeycle.
getAsString
in interface Converter
context
- FacesContext
for the request being processedcomponent
- UIComponent
with which this model object
value is associatedvalue
- Model object value to be converted
(may be null
)
null
,
otherwise the result of the conversion
ConverterException
- if conversion cannot be successfully
performed
NullPointerException
- if context
or
component
is null
public Object saveState(FacesContext context)
StateHolder
Gets the state of the instance as a
Serializable
Object.
If the class that implements this interface has references to
instances that implement StateHolder (such as a
UIComponent
with event handlers, validators, etc.)
this method must call the StateHolder.saveState(javax.faces.context.FacesContext)
method on all those
instances as well. This method must not save the state
of children and facets. That is done via the StateManager
This method must not alter the state of the implementing object. In other words, after executing this code:
Object state = component.saveState(facesContext);
component
should be the same as before executing
it.
The return from this method must be Serializable
saveState
in interface StateHolder
public void restoreState(FacesContext context, Object state)
StateHolder
Perform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to
instances that also implement StateHolder (such as a
UIComponent
with event handlers, validators, etc.)
this method must call the StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
method on all those
instances as well.
restoreState
in interface StateHolder
public boolean isTransient()
StateHolder
If true, the Object implementing this interface must not participate in state saving or restoring.
isTransient
in interface StateHolder
public void setTransient(boolean transientFlag)
StateHolder
Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
setTransient
in interface StateHolder
transientFlag
- boolean pass true
if this Object
will participate in state saving or restoring, otherwise
pass false
.