문제

I have problem with f:convertDateTime, that it seems to use the error message javax.faces.converter.DateTimeConverter.DATE_detail when I convert time (i.e. it should use javax.faces.converter.DateTimeConverter.TIME_detail).

The issue, I'm guessing, is that I use a pattern, and thus it does not know if it's a date or a time that it is tying to convert. This is what I'm trying ("timePattern" is "hh.mm"):

<f:convertDateTime type="time" pattern="#{timePattern}" />

Even though type="time" is specified, it still uses the DATE_detail error message. Is this an bug or is my assumption that it should use the TIME_detail error message wrong, and I have to create my own converter?

도움이 되었습니까?

해결책

Unfortunately, that's also what the DateTimeConverter javadoc is telling. Here's an extract of relevance:

If a pattern has been specified, its syntax must conform the rules specified by java.text.SimpleDateFormat. Such a pattern will be used to parse, and the type, dateStyle, and timeStyle properties will be ignored.

I must however admit that the JSF boys had to specify it explicitly in the f:convertDateTime pdldoc as well. It's not obvious from there. I'd report an issue to the JSF boys to get them to clarify this part.

To get it to work, your best bet is either not relying on the pattern, but on type, dateStyle and timeStyle (and the locale) instead, or create a custom date time converter which extends DateTimeConverter and overrides the methods accordingly.

다른 팁

You have also to define javax.faces.converter.DateTimeConverter.TIME in your messages.

Look here: http://www.icefaces.org/JForum/posts/list/16119.page One post before last one.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top