Hi,

In latest versions of Wicket 1.5  you can override
org.apache.wicket.markup.html.form.AbstractChoice#setOptionAttributes()
instead of #appendOptionHtml().

On Tue, Jun 19, 2012 at 9:28 AM, praveenhomkar <[email protected]> wrote:
> Hi Sandeep,
>
> Notice the solution
>
>                buffer.append("title=\"");
>                buffer.append(displayValue + "\" ");
>
> in the following code. Let me know if you get a better solution
>
>
> ListMultipleChoice<String> availRolesChoice = new
> ListMultipleChoice<String>(
>                "selectedRolesToAdd", availableRoles) {
>            @Override
>            protected void appendOptionHtml(AppendingStringBuffer buffer,
>                    String choice, int index, String selected) {
>                Object objectValue = (Object) getChoiceRenderer()
>                        .getDisplayValue(choice);
>                Class<String> objectClass = (Class<String>) (objectValue == 
> null ? null
>                        : objectValue.getClass());
>
>                String displayValue = "";
>                if (objectClass != null && objectClass != String.class) {
>                    final IConverter converter = getConverter(objectClass);
>
>                    displayValue = converter.convertToString(objectValue,
>                            getLocale());
>                } else if (objectValue != null) {
>                    displayValue = objectValue.toString();
>                }
>                buffer.append("\n<option ");
>                if (isSelected(choice, index, selected)) {
>                    buffer.append("selected=\"selected\" ");
>                }
>
>                buffer.append("title=\"");
>                buffer.append(displayValue + "\" ");
>
>                if (isDisabled(choice, index, selected)) {
>                    buffer.append("disabled=\"disabled\" ");
>                }
>                buffer.append("value=\"");
>                buffer.append(Strings.escapeMarkup(getChoiceRenderer()
>                        .getIdValue(choice, index)));
>                buffer.append("\">");
>
>                String display = displayValue;
>                if (localizeDisplayValues()) {
>                    display = getLocalizer().getString(displayValue, this,
>                            displayValue);
>                }
>                CharSequence escaped = display;
>                if (getEscapeModelStrings()) {
>                    escaped = escapeOptionHtml(display);
>                }
>                buffer.append(escaped);
>                buffer.append("</option>");
>            }
>
>        };
>
>
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/How-to-add-tooltip-to-ListMultipleChoice-tp1858030p4650047.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to