Diciamo che vuoi una lista di utenti del database
fai un bean chiamato UtenteBean
public class UtenteBean {
private String nome;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
Okay ora, vogliamo creare una lista di utenti
public class UtentiListaBean {
private List utentiList = null;
public UtentiListaBean() {
this.utentiList = new ArrayList();
populate();
}
private void populate() {
ResultSet rs = ...
while(rs....) {
UtenteBean utente = new UtenteBean();
utente.setNome(rs.getString("nome"));
this.utentiList.add(utente);
}
}
public List getUtenti() {
return utentiList;
}
}
poi nella pagina (dopo che hai fatto la configurazione nel face-config.xml)
<h:dataTable id="utente" value="#{utentiListaBean.utenti}">
<h:column>
<h:outputText value="${utente.nome}" />
</h:column>
</h:dataTable>
A presto
Mark
On Thu, 4 Nov 2004 14:36:48 +0100, Francesco Consumi
<[EMAIL PROTECTED]> wrote:
> Hi to all,
>
> I've a question, more relative to general Java programming.
> I would write a class for representing and editing data from a ResultSet in an
> UIData.
> I would use an ArrayList, where I copy data from ResultSet.
> Question: is there a way to reference "column" data with names instead of index
> ?
>
> I would be able to write something like <h:outputText value="#{row.COLUMN4}"/>
> instead of <h:outputText value="#{row[4]}"/>
>
> ...where "row" is the Var of dataTable.
>
> thanks.
>
> --
> Francesco Consumi
>
>