views:

1395

answers:

2

Hello All...

I am using spring web mvc for my app's UI part..

By using following code, i am getting List Box where i can select more then 1 value..

<form:select path="domainsList">
<form:options items="${domainsList}" itemValue="domain" itemLabel="domain"/>
</form:select>

But I need a drop down combo box...

Can any one suggest how can i convert it to combo box ?

Thanks in advance..

A: 

The spring "form:select" tag just wraps the HTML select element. It also has an attribute size which has to be set to a value of 1 to let this selection become rendered as a combobox (in most browsers).

this is basic HTML: http://www.w3.org/TR/html4/interact/forms.html#adef-size-SELECT

<form:select path="domainsList" size="1">
   <form:options items="${domainsList}" itemValue="domain" itemLabel="domain"/>
</form:select>

@Nirmal please check your markup. This should work.

<html>
    <SELECT name="selection" size="1">
        <OPTION selected label="none" value="none">None</OPTION>
        <OPTION label="1" value="1">OPTION 1</OPTION>
        <OPTION label="2" value="2">OPTION 2</OPTION>
        <OPTION label="3" value="3">OPTION 3</OPTION>
    </SELECT>
</html>
squiddle
Hi, squiddle.. thanks for reply.. But from your ans, i am not getting a pure combo box where user can select only 1 option from given list.. Can you please recheck your answer ?
Nirmal
oh, this is just a drop-down list not a combobox (there is no such thing in html, yet)and multiple selection is normally not possible with a drop-down.
squiddle
Hi, I just need a single selection... not a multiple selection..
Nirmal
Sorry boss for inconvenience.. I got the solution by just adding multiple="false" property...
Nirmal
@squiddle: Multiple selection is certainly possible using the 'multiple' attribute.
BalusC
@BalusC but not as a drop-down. it will be rendered as a list (at least here in Chromium, Firefox and Safari on Mac OS). In Firefox even as just a list with one row, which makes it quite unusable.
squiddle
A: 

Sorry, for asking silly question.. But i got working combo box by following code :

<form:select path="domainsList" multiple="false" size="1">
<form:options items="${domainsList}" itemValue="domain" itemLabel="domain"/>
</form:select>
</form:form>
Nirmal
This is not a combo box. This is a dropdown. A combo box is an editable dropdown and such thing does by default not exist in HTML (and thus also not in the component based MVC frameworks providing basic HTML components) :)
BalusC