2010-02-01 49 views
3

是否可以在我的<f:selectItem itemLabel="label" />附近设置<a href />,我的链接文本是itemLabelSelectItem标签中的JSF链接

我使用的是简单的太阳组件。

+1

是HTML可能期望的结果? f:selectItem的父级是什么? – Bozho 2010-02-01 12:34:34

回答

6

期望的结果是而不是可能在HTML中。你需要为此添加一个JavaScript镜头。

<h:selectOneMenu onchange="window.location=this.options[this.selectedIndex].value"> 
    <f:selectItems value="#{bean.links}" /> 
<h:selectOneMenu> 

bean.getLinks()与fullworthy URL作为项目返回List<SelectItem>。如果您想要显示链接均为值和标签,只需使用带有单个参数的SelectItem构造函数。

links = new List<SelectItem>(); 
links.add(new SelectItem("http://google.com")); 
links.add(new SelectItem("http://stackoverflow.com")); 
// ... 

如果你想硬编码它们的观点,那么你当然可以抢f:selectItem

<h:selectOneMenu onchange="window.location=this.options[this.selectedIndex].value"> 
    <f:selectItem itemValue="http://google.com" /> 
    <f:selectItem itemValue="http://stackoverflow.com" /> 
<h:selectOneMenu>