[
https://issues.apache.org/jira/browse/MYFACES-1845?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Leonardo Uribe resolved MYFACES-1845.
-------------------------------------
Resolution: Fixed
Fix Version/s: 1.2.3-SNAPSHOT
I have changed the implementation for this method on tag class for
convertDateTime to this for solve the problem.
private void setConverterType(ELContext elContext,
DateTimeConverter converter,
ValueExpression value)
{
String type;
if (value == null)
{
type = null;
}
else
{
type = (String)
UIComponentELTagUtils.evaluateValueExpression(elContext, value);
}
if (type == null)
{
//Now check the conditions on the spec, for type is not defined
// page 9-20
String timeStyle = (_timeStyle == null) ? null :
(String)
UIComponentELTagUtils.evaluateValueExpression(elContext, _timeStyle);
String dateStyle = (_dateStyle == null) ? null :
(String)
UIComponentELTagUtils.evaluateValueExpression(elContext, _dateStyle);
if (dateStyle == null)
{
if (timeStyle == null)
{
// if none type defaults to DEFAULT_TYPE
type = DEFAULT_TYPE;
}
else
{
// if timeStyle is set and dateStyle is not, type
defaults to TYPE_TIME
type = TYPE_TIME;
}
}
else
{
if (timeStyle == null)
{
// if dateStyle is set and timeStyle is not, type
defaults to TYPE_DATE
type = TYPE_DATE;
}
else
{
// if both dateStyle and timeStyle are set, type
defaults to TYPE_BOTH
type = TYPE_BOTH;
}
}
}else {
if (!TYPE_DATE.equals(type) &&
!TYPE_TIME.equals(type) &&
!TYPE_BOTH.equals(type))
{
type = DEFAULT_TYPE;
}
}
converter.setType(type);
}
> Only date is returned wihen both dateStyle and timeStyle are set without
> specifying type
> ----------------------------------------------------------------------------------------
>
> Key: MYFACES-1845
> URL: https://issues.apache.org/jira/browse/MYFACES-1845
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 1.2.2
> Environment: MyFaces 1.2.2
> Reporter: Michael Concini
> Assignee: Leonardo Uribe
> Fix For: 1.2.3-SNAPSHOT
>
>
> Given the following snippet, MyFaces should be rendering both the date and
> time but only renders the date.
> <h:outputText value="#{MyBean.someTime}">
> <f:convertDateTime dateStyle="full" timeStyle="full" />
> </h:outputText>
> According to the spec, if type is not specified:
> ■ if dateStyle is set and timeStyle is not, type defaults to date
> ■ if timeStyle is set and dateStyle is not, type defaults to time
> ■ if both dateStyle and timeStyle are set, type defaults to both
> The 1.2.2 implemtation always returns date. I believe the problem is in the
> getType method of javax.faces.convert.DateTimeConverter.
> Currently, anytime _type is null, its returning TYPE_DATE.
> return _type != null ? _type : TYPE_DATE;
> What might better comply with the spec would be to do something like this:
> if(_type == null){
> if(_dateStyle != null && _timeStyle != null){
> return TYPE_BOTH;
> }else if(_timeStyle != null){
> return TYPE_TIME;
> }else {
> return TYPE_DATE;
> }
> }
> return _type;
> I've tested this code locally and it does fix the above behavior.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.