Monday, December 28, 2020

Re: 2.9.0 ListBox getItemText(i) trims result [possible bug]

And workaround is to encode all string put into/extracted from list with function:

private String encodeString(String s) {
  StringBuilder sb = new StringBuilder(s.trim().replaceAll(" +", " "));
  return sb.toString();

Maybe this will help someone
понедельник, 28 декабря 2020 г. в 11:34:30 UTC+4, Joker Joker:
This html example explains the source of problem. 
I don't know why JS implementaion of ListBox doesn't mask space symbol with  
It's a normal practic for JS implementations for GWT components?

  <meta charset="utf-8">
  <title>Тег OPTION</title>

  <form action="option1.php">
   <p><select size="5" name="hero">
    <option disabled>     Выберите героя    </option>
    <option value="t1" selected>&nbsp&nbsp&nbsp&nbsp&nbspЧебурашка</option>
    <option value="t2">Крокодил Гена&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</option>
    <option value="t3">Шапокляк</option>
    <option value="t4">Крыса&nbsp&nbsp&nbsp&nbsp&nbspЛариса</option>
   <p><input type="submit" value="Отправить"></p>


понедельник, 28 декабря 2020 г. в 11:11:28 UTC+4, Joker Joker:
I think I found the reason. It's the JS Implementation of  OptionElement#setText.
It discards the last spaces in the string. I see that in debugger. 
Here method input parametr "String text" contains space symbol at the end. 
But after executing  the line "this.text = text;"
this.text contains string without space symbol at the end; 

So do I need to replace all leading and trailing white space characters with "&nbsp;"?
* The text contained within the option element.
public final native void setText(String text) /*-{
this.text = text;

пятница, 25 декабря 2020 г. в 16:11:54 UTC+4, Joker Joker:
I have an issue with GWT 2.9.0 ListBox#getItemText():

String name = listBox.getItemText(i);

The result is a string with extra spaces removed at the end.

Have anybody run into the same problem?

Browser - Chrome/Firefox(latest)

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment