Pergunta

One thing I learned today is "there is no selected property in

<html:option>

like plain old option" , we can give value in

<html:select>

that matches the value against each option and if match found marks the option selected.

but I want to make multiple options pre-selected on page load(am using

<html:select multiple="true">

How can it be achieved?

Foi útil?

Solução

Implement the following:

  1. If possible use JavaScript to make the selected entries true for the multiple entries u had made in that select list
  2. Make it selected by using Java-script first by calling javascript function before any action OR with that action :

function callSelectAll(selectName)  
{   
    var i;  
    for(i=0;i<...) {  
        document.getElementById(selectName).options[i].selected = true;
    }  

}

And use String[] array name as a property name for that html:select property form bean property. And the name of that array as a property of that html:select in jsp page.

You will ultimatly gate the all selected values un the that string array of form bean.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top