where my link text is itemLabel? ...">

JSF link in SelectItem shortcut

Is it possible to set <a href />around mine <f:selectItem itemLabel="label" />where my link text is itemLabel?

I use the simple ingredients of the sun.

+3
source share
1 answer

The desired result is not . To do this, you need to add a snapshot of JavaScript.

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

Where bean.getLinks()returns List<SelectItem>with a full URL as an element value . If you want to show the link as a value and label, just use the constructor SelectItemusing one argument.

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

If you want to write them as hard code, you can, of course, take 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>
+6
source

Source: https://habr.com/ru/post/1730852/


All Articles