Skip to content
Advertisement

Add one more option field in the Struts2 select tag

i have one struts 2 select tag like below.

<s:select list="myList" listKey="myListVal"  listValue="myListDesc"></s:select>

it rendered as below

<select data-inputs="myListInput" >
     <option value="myListVal1" >myListDesc1</option>
     <option value="myListVal2" >myListDesc2</option>
     <option value="myListVal3" >myListDesc3</option>
</select>

i want to add one more option field with null value

<option value="" ></option>

to the Option field with modification in the list.

In struts 1 it is possible like below

<html:option value=""></html:option>

like that is it possible in the struts 2

note:i couldn’t able to modifiy the list before the page load in the java

Advertisement

Answer

There is an Attribute called emptyOption in the select tag. It worked as below.

<s:select list="myList" listKey="myListVal"  listValue="myListDesc" emptyOption="true"  ></s:select> 
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement