リンク テキストが である場所の<a href />
周りにを設定することは可能ですか?<f:selectItem itemLabel="label" />
itemLabel
私は普通の太陽のコンポーネントを使用しています。
リンク テキストが である場所の<a href />
周りにを設定することは可能ですか?<f:selectItem itemLabel="label" />
itemLabel
私は普通の太陽のコンポーネントを使用しています。
HTML では、期待どおりの結果が得られません。これには、JavaScript のショットを追加する必要があります。
<h:selectOneMenu onchange="window.location=this.options[this.selectedIndex].value">
<f:selectItems value="#{bean.links}" />
<h:selectOneMenu>
Whereは、完全に価値のある URL を項目値bean.getLinks()
として を返します。リンクを値とラベルの両方で表示したい場合は、引数を 1 つ取るコンストラクタを使用してください。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>