【问题标题】:How to show previewtext in JSF components?如何在 JSF 组件中显示预览文本?
【发布时间】:2013-10-30 23:41:00
【问题描述】:

是否可以在 JSF 1.2 组件中显示预览文本,例如在输入字段、选择菜单或输出文本中,如果用户单击这些组件之一,预览文本会消失?

我看到属性 defaultLabel 可以用在 Rich faces 中? JSF 组件有类似的属性吗?

感谢和问候 马尔维夫

【问题讨论】:

  • 我以label属性为例

标签: java jsf


【解决方案1】:

如果您打算使用占位符,您可以查找 Primefaces watermark 或 RichFaces placeholder

另一种方法:看看 JSF2.2 的透传

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:p="http://xmlns.jcp.org/jsf/passthrough">

<h:inputText value="#{item.name}" p:placeholder="my item"/>
 ...

将呈现为:

 <input type="text" ... placeholder="my item">

但要小心,这是HTML5

【讨论】:

    猜你喜欢
    • 2016-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-12
    • 2021-04-27
    • 1970-01-01
    • 2020-03-07
    相关资源
    最近更新 更多