【问题标题】:JSF Convert dates for title attributeJSF 转换标题属性的日期
【发布时间】:2011-01-23 04:49:46
【问题描述】:

我需要将日期放入图像的标题属性中,以便在用户将鼠标悬停时显示。问题是我想更改日期格式。

有什么想法吗?

<ice:graphicImage value="bean.image" title="#{bean.date}"/>

【问题讨论】:

  • 到目前为止你得到了什么代码?

标签: jsf date converter


【解决方案1】:

要么直接在getter方法中进行

public String getDate() {
    return new SimpleDateFormat("yyyy-MM-dd").format(this.date); 
}

或获取 JSTL 的 &lt;fmt:formatDate&gt;

<fmt:formatDate value="#{bean.date}" pattern="yyyy-MM-dd" var="date" />
<ice:graphicImage value="bean.image" title="#{date}"/>

(在 UIData 这样的重复组件中不起作用)

【讨论】:

  • 嗨,Balus...非常快速的问题。我将 JSTL 添加到 pom 中,并将以下内容添加到标题中: xmlns:fmt="java.sun.com/jsp/jstl/fmt" 我无法让它工作......任何想法出了什么问题?它只是没有在标题上显示任何内容。
  • 那么它要么在重复组件内,要么在恢复视图期间日期值不可用。
  • 我什至无法获得一个简单的 hello world 来工作stackoverflow.com/questions/2373592/how-do-you-use-jstl。不确定是否需要做其他事情来启用标签库。
猜你喜欢
  • 2011-01-06
  • 2012-02-20
  • 2012-09-29
  • 1970-01-01
  • 2013-11-07
  • 2013-01-10
  • 1970-01-01
  • 2012-07-23
  • 2020-05-26
相关资源
最近更新 更多