silveta 17 de jul. de 2008
cara posta o código ai, como você está gerado esse combobox?
no html para deixar uma option como selecionada basta por a propriedade selected
Não
[]'s
vinny767 17 de jul. de 2008
To usando uma taglib propria que o pessoal desenvolveu aqui.. Segue o código da lib e da declaração do campo
Taglib
<% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<% @ taglib uri = "/webwork" prefix = "ww" %>
<% @ tag body - content = "empty" %>
<% @ attribute name = "ultlinha" %>
<% @ attribute name = "valorinicial" %>
<% @ attribute name = "titulo" %>
<% @ attribute name = "nome" %>
<% @ attribute name = "leitura" %>
<% @ attribute name = "collection" %>
<% @ attribute name = "selecionado" %>
<% @ attribute name = "notnull" %>
<c:if test= "${not empty collection}" >
<c:set var= "jcollection" > ${collection}</c:set>
</c:if>
<c:if test= "${leitura=='sim'}" >
<c:set var= "jleitura" > onfocus="this.blur() </c:set>
</c:if>
<c:if test= "${empty valorinicial}" >
<c:set var= "valorinicial" > [Selecione um item]</c:set>
</c:if>
<c:if test= "${empty ultlinha}" >
<c:set var= "jultlinha" > class="floatleft"</c:set>
</c:if>
<c:if test= "${!empty ultlinha}" >
<c:set var= "jultlinha" > class="nofloat"</c:set>
</c:if>
<c:set var= "selecionado" >
<ww:property value= "${nome}" />
</c:set>
<c:if test= "${not empty titulo}" >
<c:set var= "jtitulo" > ${titulo}</c:set>
</c:if>
<c:if test= "${not empty fieldErrors[nome]}" >
<c:set var= "corerro" > style="color:red; " </c:set>
</c:if>
<c:if test= "${notnull=='sim'}" >
<div ${jultlinha}${corerro} > ${titulo}<font color= "black" > (</font><font color= "Red" > *</font><font color= "black" > )</font> :
</c:if>
<c:if test= "${notnull=='nao'}" >
<div ${jultlinha}${corerro} > ${titulo}:
</c:if>
<c:if test= "${empty notnull}" >
<div ${jultlinha}${corerro} > ${titulo}:
</c:if>
<c:if test= "${(not empty leitura)or(leitura=='sim')}" >
<ww:iterator value= "${collection}" >
<c:if test= "${selecionado == pIdGenerica}" >
<c:set var= "valor" >
${pDesc}
</c:set>
</c:if>
</ww:iterator>
<input type= "text" size= "25" name= "${nome}" value= "${valor}" readonly= "readonly" >
</c:if>
<c:if test= "${(empty leitura)or(leitura!='sim')}" >
<select name= "${nome}" >
<option value= "" > ${valorinicial}</option>
<ww:iterator value= "${collection}" >
<c:set var= "pIdGenerica" ><ww:property value= "pIdGenerica" /></c:set>
<c:set var= "pDesc" ><ww:property value= "pDesc" /></c:set>
<option value= "${pIdGenerica}" <c:if test= "${pIdGenerica == selecionado}" > selected </c:if> >${pDesc}</option>
</ww:iterator>
</select>
</c:if>
</div>
Declaracao do campo no JSP:
<ft:selecttabgenerica collection="colTabtemconceitoversao" titulo="Tem Conceito Versao" notnull="sim" nome="temconceitoversao"/>
Sds,
_Renatu 17 de jul. de 2008
“The bracket operator ([]) can be used to retrieve a named property, as in ${customer[“name”]}. The bracket operator can also be used as ${customers[0]} to refer to the first item in the customers collection.”
fonte:
http://java.sun.com/developer/technicalArticles/javaserverpages/faster/
vinny767 17 de jul. de 2008
Eu tentei isso…
Minha dúvida é a seguinte…
Se eu acessar assim ${customers[0]} eu estaria acessando o endereco de memoria onde está o objeto, certo?
Por exemplo… Eu quero o nome do meu cliente da primeira posicao: Seria ${customers[0].nome} ou ${customers[0]}?