Re:Duvida com <select>

3 respostas
robinsonbsilva

vc consegui resolver este caso??

Preciso resolver algo semelhante

&lt;label for="perfil"&gt;&lt;strong&gt;*&lt;/strong&gt;Perfil:<br>
               &lt;html:select property="idPerfil" value="dto.idPerfil"&gt; 
                  &lt;html:options collection="listPerfis" property="idPerfil" labelProperty="descricao"/&gt;  
               &lt;/html:select&gt;  
            &lt;/label&gt;

3 Respostas

alves.Felipe

Ola…

vc consegui resolver este caso??

Preciso resolver algo semelhante

view plaincopy to clipboardprint?
*Perfil:

<html:select property="idPerfil" value="dto.idPerfil"> <html:options collection="listPerfis" property="idPerfil" labelProperty="descricao"/> </html:select>

Supondo que sua lista tem objetos Perfil…
tenta fazer assim:

<html:select property="perfil.idPerfil"> <html:optionsCollection name="listPerfis" label="descricao" value="idPerfil"/> </html:select>

robinsonbsilva

Eu resolvi assim:

&lt;%
    FuncionarioDTO dto = (FuncionarioDTO) request.getAttribute("dto");
%&gt;

               &lt;html:select property="idPerfil" value="${dto.idPerfil}"&gt; 
                  &lt;html:options collection="listPerfis" property="idPerfil" labelProperty="descricao"/&gt;  
               &lt;/html:select&gt;

Assim quando carrega a página, ele já seleciona o valor correto !

Valew!

everson_z

Duvida com

No Struts eu pego o id da sessão para informar o que deve ser selecionado, no html puro, qual a melhor maneira para fazer isso?

Ex: O valor a ser selecionado é dinamico value=

<html:select property="variavel" value="${variavel.id}">
	                   <html:option value="1">Nome 1</html:option>
	                   <html:option value="2">Nome 2</html:option>
	                   <html:option value="3">Nome 3</html:option>
	                   <html:option value="4">Nome 4</html:option>
	                   <html:option value="5">Nome 5</html:option>
	                   <html:option value="6">Nome 6</html:option>
	                   <html:option value="7">Nome 7</html:option>
	                   <html:option value="8">Nome 8</html:option>
	                   <html:option value="9">Nome 9</html:option>
	                   <html:option value="10">Nome 10</html:option>
	                </html:select>

vlw

Criado 30 de maio de 2008
Ultima resposta 15 de fev. de 2008
Respostas 3
Participantes 3