是否可以在JSF中为标记添加"title"属性,例如:
<f:selectItems value="#{foo.fooList}" title="{foo.fooDescription}"/>
Run Code Online (Sandbox Code Playgroud)
生成的HTML:
<select>
<option value="foo1" title="description1">foo ex1</option>
<option value="foo2" title="description2">foo ex2</option>
</select>
Run Code Online (Sandbox Code Playgroud) 我想为a中的每个元素添加一个工具提示p:selectManyCheckBox.但是我无法想出解决方案.
我有一个Role有3个属性的类,"id"(长),"name"(字符串)和"description"(字符串).显示名称,我希望将描述作为工具提示.
这是一段有效的代码:
<p:selectManyCheckbox layout="pageDirection" value="#{roleBean.selectedRoles}" converter="roleConverter">
<f:selectItems value="#{roleBean.roles}" var="role" itemLabel="#{role.name}" itemValue="#{role}"/>
</p:selectManyCheckbox>
Run Code Online (Sandbox Code Playgroud)
这roleConverter是一个FacesConverter转换Role为id,反之亦然.
我想出了这个:
<p:selectManyCheckbox layout="pageDirection" value="#{roleBean.selectedRoles}" converter="roleConverter">
<c:forEach var="role" items="#{roleBean.roles}">
<f:selectItem id="role#{role.id}" itemLabel="#{role.name}" itemValue="#{role}" />
<p:tooltip for="role#{role.id}" value="#{role.description}"/>
</c:forEach>
</p:selectManyCheckbox>
Run Code Online (Sandbox Code Playgroud)
但不幸的是它不起作用.
我可以将表达式传递给JSF 2 passthrough-attributes吗?以下代码无效.#{country.isoCode}不评估表达式.
<h:selectOneMenu value="#{bean.selectedCountry}" styleClass="selectlist">
<f:selectItems
value="#{bean.countries}" var="country"
itemLabel="#{country.countryName}"
pt:data-icon="flag flag-#{country.isoCode}"/>
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
我正在使用命名空间
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
Run Code Online (Sandbox Code Playgroud)
和bootstrap-select.属性"data-icon"用于显示图像.看到:
http://silviomoreto.github.io/bootstrap-select/#data-icon
渲染输出:
<i class="glyphicon flag flag-"></i>
Run Code Online (Sandbox Code Playgroud)