jsp - set multiple default value in select tag in struts2 -
how can set multiple default value using select tag in struts2. e.g have list of names "namea, nameb, namec". want these 3 names selected default. can populate list struggling set multiple default value.
<s:select id = "name" size = "5" name = "nameform.nameids" cssstyle = "width:365px;margin-top:10px; margin-bottom:10px;" list = "name.namelist" listkey = "id" listvalue = "displayname" multiple = "true" ></s:select>
you need use value
attribute of <s:select>
tag. , because using bean generate <s:select>
values need create list of bean properties used in listkey
attribute. in case list of id
-s.
<s:set var="idslist" value="{'id1','id2','id3'}" /> <s:select list="name.namelist" listkey="id" listvalue="displayname" multiple="true" value="%{#idslist}" />
in order select use list ognl projection selecting id-s in it.
<s:select id = "name" size = "5" name = "nameform.nameids" cssstyle = "width:365px;margin-top:10px; margin-bottom:10px;" list = "name.namelist" listkey = "id" listvalue = "displayname" multiple = "true" value = "%{name.namelist.{id}}" ></s:select>
Comments
Post a Comment