SelectItem标签中的JSF链接 [英] JSF link in SelectItem label

查看:248
本文介绍了SelectItem标签中的JSF链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在我的< f:selectItem itemLabel =label/>周围设置< a href /> 我的链接文字是 itemLabel

我正在使用普通太阳组件。

I'm using the plain sun components.

推荐答案

HTML中所需的结果 。你需要为此添加一个JavaScript镜头。

The desired result is not possible in HTML. You'll need to add a shot of JavaScript for this.

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

其中 bean.getLinks()返回一个列表< SelectItem> ,其中包含值为的完整网址。如果要将链接显示为两个值和标签,只需使用 SelectItem 构造函数,只需一个参数。

Where bean.getLinks() returns a List<SelectItem> with a fullworthy URL as item value. If you want to show the link as both value and label, just use the SelectItem constructor taking a single argument.

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

如果你想在视图中对它们进行硬编码,那么你当然可以抓住 f:selectItem

If you want to hardcode them in the view, then you can of course grab 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>

这篇关于SelectItem标签中的JSF链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆