You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lorne Malvo <ca...@gmail.com> on 2017/09/26 10:41:37 UTC

How to add tooltips to dropdown choices

Is there a simple way to insert a "title" HTML attribute into each option of
a DropDownChoice, in order to display a different tool tip with each choice?

I tried doing it simply by adding HTML in a ChoiceRenderer, but could not
get Wicket to not escape the HTML (can't call setEscapeModelStrings(false))
on a DropDownChoice. 

I also tried this...
https://stackoverflow.com/questions/12234738/wicket-dropdownchoice-titles-tooltips-for-options
... but it didn't work for me. First, that method was always calling
toString() on my model object to display the option, which is not what I
wanted, and I couldn't see a way to make that subclass non-generic.
Secondly, even if I had had the aforementioned problem, the tooltip didn't
even show up. 

Anyway to do this simply?

Thanks in advance!


--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to add tooltips to dropdown choices

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You can override #setOptionAttributes() -
https://github.com/apache/wicket/blob/77d8bf32d2063ac0174fc383da81ac2d6bcc482b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java#L457

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Sep 26, 2017 at 1:41 PM, Lorne Malvo <ca...@gmail.com>
wrote:

>
> Is there a simple way to insert a "title" HTML attribute into each option
> of
> a DropDownChoice, in order to display a different tool tip with each
> choice?
>
> I tried doing it simply by adding HTML in a ChoiceRenderer, but could not
> get Wicket to not escape the HTML (can't call setEscapeModelStrings(false))
> on a DropDownChoice.
>
> I also tried this...
> https://stackoverflow.com/questions/12234738/wicket-dropdownchoice-titles-
> tooltips-for-options
> ... but it didn't work for me. First, that method was always calling
> toString() on my model object to display the option, which is not what I
> wanted, and I couldn't see a way to make that subclass non-generic.
> Secondly, even if I had had the aforementioned problem, the tooltip didn't
> even show up.
>
> Anyway to do this simply?
>
> Thanks in advance!
>
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-
> f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>