List - ComboBox - Option - Socorro

3 respostas
J

Boa tarde,

Por favor alguém me ajude, já olhei no fórum dúvidas parecidas com as minha, mas não consegui resolver meu problema. Não consigo criar uma lista/ComboBox

meu form

public class DvdsForm extends ActionForm

{

private int          cod = 0;

private String     nome = “”;

private String     sql = “”;
private Collection dvds = null;


public String getSql() {
	return sql;
}

public void setSql(String sql) {
	this.sql = sql;
}

public String getNome() {
	return nome;
}

public void setNome(String nome) {
	this.nome = nome;
}

public int getCod() {
	return cod;
}

public void setCod(int cod) {
	this.cod = cod;
}

public Collection getDvds() {
	return dvds;
}

public void setDvds(Collection dvds) {
	this.dvds = dvds;
}

}

na minha Action

public class DvdsAction extends DispatchAction

{

public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

{

DvdsForm dvdForm = (DvdsForm)form;

DvdsDAO  service = new DvdsDAO();
dvdForm.setDvds(service.search());
	
	return mapping.getInputForward();
}

}

meu VO

public class DvdsVo implements Serializable

{

private int cod = 0;

private String nome = “”;
public String getNome() {
	return nome;
}

public void setNome(String nome) {
	this.nome = nome;
}

public int getCod() {
	return cod;
}

public void setCod(int cod) {
	this.cod = cod;
}

}

meu jsp
<%@ taglib uri=“struts-html” prefix=“html” %>
<%@ taglib uri=“struts-bean” prefix=“bean” %>
<%@ taglib uri=“struts-logic” prefix=“logic” %>
<%@ taglib uri=“http://java.sun.com/jstl/core” prefix=“c” %>

DVDS FILMES

ID NOME

na minha tabela blz, traz o código e o nome, mas eu nao consigo criar uma list/combo com esses dados para testar…

obrigado.

3 Respostas

ViniGodoy

Que tal antes de tudo editar o seu post e coloca-lo entre as tags code, como descrito aqui? Ajude-nos a ajuda-lo! :wink:

J

meu form

public class DvdsForm extends ActionForm 
{ 
       private int cod = 0; 
       private String nome = ""; 
       private String sql = ""; 

       private Collection dvds = null;

       public String getSql() { 
              return sql; 
       } 

       public void setSql(String sql) { 
              this.sql = sql; 
       } 

       public String getNome() { 
              return nome; 
       } 

       public void setNome(String nome) { 
              this.nome = nome; 
       } 

       public int getCod() { 
              return cod; 
       } 

       public void setCod(int cod) { 
              this.cod = cod; 
      } 

       public Collection getDvds() { 
             return dvds; 
       } 

       public void setDvds(Collection dvds) { 
              this.dvds = dvds; 
       } 
}

na minha Action

public class DvdsAction extends DispatchAction 
{ 
       public ActionForward search(ActionMapping mapping, ActionForm   form, HttpServletRequest request, HttpServletResponse response) throws Exception 
       { 
              DvdsForm dvdForm = (DvdsForm)form; 
              DvdsDAO service = new DvdsDAO(); 

              dvdForm.setDvds(service.search()); 

              return mapping.getInputForward(); 
       } 
}

meu VO

public class DvdsVo implements Serializable 
{ 
       private int cod = 0; 
       private String nome = ""; 

       public String getNome() { 
              return nome; 
       } 

       public void setNome(String nome) { 
              this.nome = nome; 
       } 

       public int getCod() { 
              return cod; 
       } 

       public void setCod(int cod) { 
              this.cod = cod; 
       } 
}

meu jsp

<%@ taglib uri="struts-html" prefix="html" %> 
<%@ taglib uri="struts-bean" prefix="bean" %> 
<%@ taglib uri="struts-logic" prefix="logic" %> 
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> 

<HTML> 
     <HEAD> 
          <TITLE>DVDS</TITLE> 
     </HEAD> 
     <BODY> 
          <html:form action="/lista"> 
          <html:hidden property="sql"/> 
          <center> 
               <b>FILMES</b> 
          </center> 
          <hr width="80%"><br> 
          <table border"1" align="center" width="80%"> 
               <tr> 
                    <td>ID</td> 
                    <td>NOME</td> 
               </tr> 
               <logic:notEmpty name="DvdsForm" property="dvds"> 
                    <logic:iterate name="DvdsForm" property="dvds" id="dvd" type="br.com.dvds.vo.DvdsVo"> 
               <tr> 
                    <td><bean:write name="dvd" roperty="cod"/></td>  <td><bean:write name="dvd" property="nome"/></td> 
               </tr> 
               <tr> 
                    <html:select property="dvds"> 
                    <html:options collection="dvds" property="cod" labelName="nome"/> </html:select> 
                    </logic:iterate> 
              </logic:notEmpty> 
          </table> 
          <center> 
               <html:submit value="Listar" onclick="document.DvdsForm.sql.value='search'"/> 
          </center> 
          </html:form> 
     </BODY> 
</HTML>
J

opa, agora acho sim…
desculpa ae e valeu pela dica
e for favor alguém me ajude…

Criado 7 de abril de 2007
Ultima resposta 8 de abr. de 2007
Respostas 3
Participantes 2