ListSelect and setId

Hi,
I have a question about how to setId to components.

This is my Example code:

[code]
public void layout() {

layout = new CssLayout();

multiSelectList = new ListSelect();
multiSelectList.setNullSelectionAllowed(false);
multiSelectList.setMultiSelect(true);
multiSelectList.setId(uuid.toString());
if (availableComponents != null)
for (String value : availableComponents) {
multiSelectList.addItem(value);
}
if(selectedComponents!=null){
for(String value : selectedComponents){
multiSelectList.select(value);
}
}

layout.addComponent(multiSelectList);
setCompositionRoot(layout);

}
[/code]the above code generates this code:

[code]

<select class="v-select-select" multiple="" size="10" tabindex="0">
    <option value="1"></option>
    <option value="2"></option>
    <option value="3"></option>
</select>
[/code]My Question : How can i add the id directly to the select element ? the result should be looking like : [code]
[/code]

@Johannes Dahlström

Hi thx for the answer.
In my case, i want to create a dropdown multiselect list. For this i use a jquery http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos. This lib need a uniq id on the select element to create a new html element.
My first solution is to set the id in the javascript connector
like this
$(“#”+divID).children(“select”).attr({“multiple”:“multiple”,“name”:selectID,“id”:selectID});

i hoped there will be a better solution for this, so i can add the id on the server side.

Sorry, I accidentally submitted a partial message and deleted it but of course it already sent the email notification. I think you’ll have to write a small Extension to set the id - it can be a JavaScriptExtension so the clientside should be pretty tiny.

You could also use Page.getJavaScript().execute(“your jQuery expression”)

Ok, than there is no way to do it on server side in java.

I still have a question:
How can i change the value of the generated options elements.

[code]

</optio [/code]that the generated code looks like [code] [/code]is there a way to change this on the java side ? somewhere during this part of code [code] multiSelectList.addItem(value); [/code]

A KeyMapper is used to map item IDs (which can be arbitrary Java objects) to strings to be used on the clientside. By default, simple sequential integer keys are used. I was pretty sure this cannot be customized except perhaps with reflection, but it appears the itemIdMapper field in AbstractSelect is protected! You’d have to override most of the KeyMapper class, but if your item IDs are simple Strings, for instance, the custom KeyMapper could be very trivial. Then you’d have to extend the Select component you’re using and set your own KeyMapper in the constructor.

Note that passing server-side data to the client side is always a potential security risk, so be mindful of what sort of item IDs you use.