O tópico é estranho mas vou tentar explicar.
Tenho os seguintes beans:
public class Artigo{
private int id;
private String titulo;
private String conteudo;
private Collection<Site> sites;
// getters e setters omitidos
}
public class Site{
private int id;
private String textoLink;
private String urlLink;
// getters e setters omitidos
}
Segue o Form:
public class ArtigoForm extends ActionForm {
private Artigo bean;
private Collection<Site> sites;
// getters e setters omitidos
public ArtigoForm(){
bean = new Artigo();
sites = new ArrayList();
}
public void reset(ActionMapping mapping, HttpServletRequest request){
bean = new Artigo();
sites = new ArrayList();
}
}
E, por fim, o meu formulário (onde está a minha dúvida):
<html:html>
<head></head>
<body>
<html:form action="artigoAction.do" enctype="multipart/form-data">
<html:hidden property="acao" value="cadastrar"/>
<html:hidden property="bean.id"/>
<h2>Cadastro de Artigo</h2>
<br/>
<b>Titulo</b>:<html:text property="bean.titulo"/>
<b>Conteudo</b>:
<br/>
<html:textarea property="bean.conteudo" rows="5" cols="70"></html:textarea>
<b>Sites</b>
<br/>
<table>
<tr>
<td>Site chamada:</td>
<td><input type="text" name="textoLink"></td>
</tr>
<tr> <td>Site link:</td>
<td><input type="text" name="urlLink"></td>
</tr>
</table>
<br/>
<table>
<tr>
<td>Site chamada:</td>
<td><input type="text" name="textoLink"></td>
</tr>
<tr> <td>Site link:</td>
<td><input type="text" name="urlLink"></td>
</tr>
</table>
</html:form>
</body>
</html:html>
Finalmente a(s) dúvida(s): como faço para cadastrar vários sites no mesmo formulário do artigo? A associação do bean com o form está correta?