inputText和convertDateTime错误

时间:2011-11-23 14:44:17

标签: jsf-2

我有一个h:inputText字段,用于输入日期。我正在使用f:convertDateTime,但我收到了错误。

情况如下:

<h:inputText value="#{listModel.creationDate}" valueChangeListener="#{listController.filterFieldChanged}">
    <f:convertDateTime type="date" pattern="yyyy-MM-dd"/>
</h:inputText>

如果我输入“2011-11-23”,我会收到以下错误:

  

“... [exec] sourceId = j_idt3 [severity =(ERROR 2),summary =(转换错误设置值'Wed Nov 23 01:00:00 CET 2011'for'null Converter'。),detail = (转换错误设置值'Wed Nov 23 01:00:00 CET 2011'for'null Converter'。)] |#]“(此外,01:00:00来自哪里?)

如果我删除type="date"并仅保留pattern="yyyy-MM-dd"并输入相同的日期,则会收到相同的错误。

如果我删除该模式并仅保留type="date"并输入相同的日期,则会收到以下错误:

  

“[exec] sourceId = searchForm:j_idt72 [severity =(ERROR 2),summary =(searchForm:j_idt72:'2011-11-23'无法理解为日期。),detail =(searchForm:j_idt72 :'2011-11-23'不能被理解为日期。例如:23.11.2011)] |#]“

我有点困惑。如果我定义模式yyyy-MM-dd为什么不接受“2011-11-23”?

信息补充:

value =“#{listModel.creationDate}”

public Date getCreationDate()
{
    return creationDate;
}

这是类ListModel中creationDate的getter。 (它是一个java.Util.Date)

valueChangeListener = “#{listController.filterFieldChanged}”

public void filterFieldChanged( ValueChangeEvent event )
{
    // Note: value change events are handled in the PROCESS_VALIDATIONS
    // phase by default. The problem is that the model values are not
    // updated until later, so any changes we make here would normally be
    // overwritten.
    // By requeueing the event and targeting it to the UPDATE_MODEL_VALUES
    // phase we can make the model changes without them being overwritten.
    if ( event.getPhaseId().equals( PhaseId.ANY_PHASE ) )
    {
        event.setPhaseId( PhaseId.UPDATE_MODEL_VALUES );
        event.queue();
    }
    else
    {
        // reset the paging any time a filter field was changed
        listModel.setFirstResult( 0 );
    }
}

我希望这很有用......

0 个答案:

没有答案