Width of a component implementing AbstractSelect

I have a own implementation out of a select field which is technically working, but I’ve run into a graphical problem. AbstractSelects consist out of two components, a textfield and a button (before clicking the button and getting a option popup). The problem is that in my implementation the textfield doesn’t expand to reflect the width of the select as a whole. This leaves whitespace between the textfield and the button. Looking at firebug i noticed that the code for my select is:


&lt;div class="i-filterselect" style="width: 504px;"&gt;<img ...../>&lt;input type="text" tabindex="0" class="i-filterselect-input"&gt;

While for a normal new Select(); i get


&lt;div class="i-filterselect" style="width: 318px;"&gt;<img  ...../>&lt;input type="text" tabindex="0" class="i-filterselect-input" style="width: 287px;"/&gt;

As you can notice, my implementation lacks the calculated width injected into the html. Is this something that I have done wrong or is it a toolkit bug? Do you need the code to figure this out?

Thanks,
Jens

bump.

So if I understand you correctly you have an own client implementation of a Select and this implementation does not generate the DOM structure you want. The component included in 5.3.0RC9 contains explicit code for calculating the width of the various parts of the component and this, as you are saying, works correctly.

It’s really hard to give any useful advice with this little information but my best guesses are:

  • you have extended the existing component and removed vital calls for calculating the width
  • you have created an own client component from scratch and not included any width calculations for the textfield

If you have special operations that need to be performed when the size (height or width) is updated you need to override the setWidth and setHeight methods. These are called whenever the size of the component is updated and automatically sets width and height for the component root element. If you need to update other stuff (like the textfield width in this case) you should implement you own setWidth/setHeight. For example:


@Override
public void setWidth(String width) {
    // Sets the width of the root element
    super.setWidth(width);
    // Just an example which sets textfield width to 20 pixels less than the whole component
    textfield.setWidth(getOffsetWidth()-20); 
}

The component is actually implementing AbstractSelect - and not extending the basic select. Now I however know what to look in so i’ll give it a swing.