0

I have a dropdown list like this

<form:select path="component" multiple="true" id="componentId">
    <form:option value="" label="--- Select Components---" />
    <form:options items="${componentList}" />
</form:select>

Here the componentLits prints the vaues stored in the db in the below format

 Boot Up(bootup),
              Channel Tuning(channelTuning)
              TOCOD(tocvod) 

I have to display values in dropdown list UI as Boot Up , Channel Tuning, TOCOD.dont need to display the values inside brackets. And while selecting the above values (for example if i choose Boot UP from dropdown its value will be bootup not the displaying one(Boot UP)) how it is possible with spring mvc form

5
  • do you have a arraylist with this values? what is the problem? are the values not displayed? Commented Nov 19, 2015 at 10:57
  • values are displying in the dropdown in the Boot Up(bootup) Channel Tuning(channelTuning) format..i have to display Boot Up, hannel Tuning only but while selecting Boot Up from dropdown list the value will be bootup..i mean the value inside the bracket.. Commented Nov 19, 2015 at 11:01
  • i understand. the label should be Boot Up and the value "bootup". Is componentList a arrayList or a map or set or ... ? Commented Nov 19, 2015 at 11:04
  • Yes u r right !componetList is arrayList Commented Nov 19, 2015 at 11:05
  • ok, change it to a hashmap .. Map< String, String > ttt = new HashMap<string, string="">(); ttt.put(" Boot Up", "bootup"); Commented Nov 19, 2015 at 11:08

1 Answer 1

1

Change the arrayList to a hashMap.

Map< String, String > componentList= new HashMap<string, string>(); 
componentList.put(" Boot Up", "bootup");

After that the key will be displayed as value, and the value of the map as label.

<form:select path="component" multiple="true" id="componentId">
    <form:option value="" label="--- Select Components---" />
    <form:options items="${componentList}" />
</form:select>
Sign up to request clarification or add additional context in comments.

4 Comments

how can i display tt in UI<form:select path="component" multiple="true" id="componentId"> <form:option value="" label="--- Select Components---" /> <form:options items="${tt}" /> </form:select>
could you please how it can be displying in the form select of dropdown list
one more doubt using java how can i split key values Boot Up(bootup)
Is the string "Boot Up(bootup)" like this stored in one column in the database? Use StringUtils from apache commons. The method is StringUtils.split("(") and please flag my answer as accepted. examples.javacodegeeks.com/core-java/apache/commons/lang3/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.