You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Sandeep_Chittajallu <Sa...@satyam.com> on 2009/02/10 08:38:24 UTC
How to add tooltip to ListMultipleChoice.
Hi all,
Im new to wicket, I want a solution how we can add the tooltip to the options of the ListMultipleChoice.
Thanks
Sandeep
________________________________
DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.
Re: How to add tooltip to ListMultipleChoice.
Posted by Martin Grigorov <mg...@apache.org>.
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 <pr...@yahoo.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to add tooltip to ListMultipleChoice.
Posted by praveenhomkar <pr...@yahoo.com>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org