- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在研究复合组件,但遇到了一些我无法理解的问题。如果不使用复合组件,我会得到这样的东西:
<h:outputText value="Some Label:"/>
<h:selectOneMenu">
<f:selectItem itemLabel="Item 1"/>
<f:selectItem itemLabel="Item 2"/>
<f:selectItem itemLabel="Item 3"/>
</h:selectOneMenu>
我基本上将该片段变成了复合组件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="label" required="true"/>
<composite:attribute name="options" required="true"/>
</composite:interface>
<!-- IMPLEMENTATION -->
<composite:implementation>
<h:outputText value="#{cc.attrs.label}"/>
<h:selectOneMenu style="width:140px;">
<f:selectItem value="#{cc.attrs.options}" />
</h:selectOneMenu>
</composite:implementation>
</html>
现在这就是我难住的地方。我知道我可以将我想在组件中使用的项目列表放在支持 bean 中并像这样使用它:
<util:dropdown label="Some Label:" options="#{backingBean.list}"/>
真正的问题是是否有一种方法可以在不使用支持 bean 的情况下传递选项?我猜是这样的:
<util:dropdown label="Some Label:" options="Item 1, Item 2, Item 3"/>
或者也许
<util:dropdown label="Some Label:" options="#{backingBean.list}">
<f:selectItem itemLabel="Item 1"/>
<f:selectItem itemLabel="Item 2"/>
<f:selectItem itemLabel="Item 3"/>
</util:dropdown>
注意:显然这两个不起作用,否则我不会问这个问题。
最佳答案
The real question is if there is a way to pass in the options without having to use a backing bean? I guess something like:
<util:dropdown label="Some Label:" options="Item 1, Item 2, Item 3"/>
您可以使用 JSTL fn:split()
将它们分成 String[]
. <f:selectItems>
也接受为 value
.我只会删除 options
中逗号周围的空格。属性。
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
...
<h:selectOneMenu>
<f:selectItems value="#{fn:split(cc.attrs.options, ',')}" />
</h:selectOneMenu>
or maybe
<util:dropdown label="Some Label:">
<f:selectItem itemLabel="Item 1"/>
<f:selectItem itemLabel="Item 2"/>
<f:selectItem itemLabel="Item 3"/>
</util:dropdown>
您可以使用 <composite:insertChildren>
在复合组件中声明必须插入复合组件的子组件的位置。
<h:selectOneMenu>
<composite:insertChildren />
</h:selectOneMenu>
关于java - JSF 复合组件和 selectItems,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6298226/
jsf中selectitem和selectitems标签有什么区别? 最佳答案 差异正是您所期望的。 selectitem 标签将单个项目添加到 HTML 列表,而 selectitems 标签添加多
我正在尝试根据查询将 asp:dropdownlist 绑定(bind)到一些站点核心项目。通过查询,我想返回继承模板“站点根”的项目。 当我使用: Sitecore.Context.Database
例如,在某些版本的JSF中,f:selectItems组件不支持title属性。 是否可以使用JSFC将JSF组件替换为纯HTML对应的组件,并执行类似的操作? 代替
我有一个数字列表(范围 500 - 5000,步长 500)。我想添加一个小数点 1000 -> 1.000; 2500 -> 2.500 等,但只是为了不将标签保存为值。我尝试了以下但没有用:
我有一个数字列表(范围 500 - 5000,步长 500)。我想添加一个小数点 1000 -> 1.000; 2500 -> 2.500 等,但只是为了不将标签保存为值。我尝试了以下但没有用:
如何从 List 中删除“abcd”的值. public class Sample { public static void main(String[] args) { List list=
我试图在我的 selectItem 中为每个默认添加一个选项,它绑定(bind)了一个数据源,之后我尝试为每个默认添加一个选项。我的问题是我总是看到数据源中的项目,但从来没有看到我的默认选项。这些是我
我试图让用户从 JSF 的下拉列表中选择一个集合的项目。 这是我正在使用的代码: 这是 MyBean 的代码: @ManagedBean
是否可以使用xpath语法进行基于日期的查询?我研究的一切都表明这是不可能的。我正在查询一组日历,只想取回一个月的数据-我可以使用哪些策略来实现这一目标? 2010年8月10日:编辑以获取更多信息 我
是否可以设置我周围我的链接文本是 itemLabel ? 我正在使用普通的太阳组件。 最佳答案 在 HTML 中不可能获得所需的结果。您需要为此添加一段 JavaScript。 哪里be
我有以下失败的 Facelet 代码: 支持 bean: public class StaticInfoBea
我是 SmartGWT 的新手,尝试以编程方式选择 SelectItem Widget 的项目。但没有找到解决方案。 这就是我想要的: 这是我当前的 SmartGWT 示例代码: SelectIte
我有一个乡村类(class): public class Country{ private Long id; private String name; } 以及具有两个 Count
我一直在研究复合组件,但遇到了一些我无法理解的问题。如果不使用复合组件,我会得到这样的东西: 我基本上将该片段变成了复合组件:
抱歉图片上有捷克语,但这并不重要。 在图片上,您可以在单击其下拉按钮后看到 SelectItem。在此下拉菜单的第一行,您可以看到额外的过滤输入,我需要将其删除。 我认为只有当您使用 DataSour
我正在尝试使用 selectOneMenu 制作过滤器。 我有两个类别,当一个类别被选中时,必须过滤显示的结果,还有第二个类别。 JSF 代码: Filter by topi
这个问题已经有答案了: How to populate options of h:selectOneMenu from database? (5 个回答) 已关闭 4 年前。 目标是正确获取 Sele
我有一个 SelectItem,它从数据库中获取数据。我需要向我选择的项目添加一个空字段。 我的代码看起来像这样,而且效果很好。 SelectItem editor = new SelectItem(
在 ContextMenu shell 扩展中创建文件后,如何在资源管理器中选择它? 我使用 IFileOperation 创建了文件API,并尝试使用 IShellView::SelectItem(
试图将所有演示 Material 保留在该项目的 xhtml 中,我需要将 selectItem 标记中的某些值格式化为具有 BigDecimal 值,并且需要使其看起来像货币。有没有办法申请在 里
我是一名优秀的程序员,十分优秀!