tags:

views:

46

answers:

1

I want to implement mailto: link in jsf on selected option in selectOneMenu(dropdown list)

how can i implement this ?

+2  A: 

So you want to end up with something like

<select>
    <option><a href="mailto:[email protected]">link</a></option>
</select>

?

That's already not possible in HTML, so JSF can't do much for you here. Your best bet is to mimic a dropdown with <div><ul><li> and a good shot of JavaScript and CSS.

Alternatively, if you can live with non-styleable dropdown options (you can for example not color or underline them, so that they look like links), you can also just add a little shot of JS to achieve your needs.

<h:selectOneMenu onchange="var link = this.options[this.selectedIndex].value; if (link) window.location = link;">
    <f:selectItem itemLabel="Please select" itemValue="null" />
    <f:selectItems value="#{bean.mailLinks}" />
</h:selectOneMenu>

Assuming that the item values are already strings with the mailto:[email protected] values.

BalusC
thanks for gr8 responce...this is nearer to my answer but i have list of contact person and i want to send mail to on selected option from SelectOneMenu....what thing i have to change ?and what will be the javascript for it ?
yakub_moriss
I don't see any need for changes. Maybe at highest bean and property names?
BalusC