Accessing datatable row....

G

gbattine

Hi guys,
i need a little help.
I've developed a datatable and an actionListener as commandlink for
each row,when it's clicked an insert on a table is performed.
The problem is that when i insert value and click my table is filled
with null values!
I think the error is in actionListener,can you help me?

public void editBiosample(ActionEvent event) throws SQLException {
FacesContext facesContext=FacesContext.getCurrentInstance();
setBiosampleItem((Biosample) getBiosampleDataTable().getRowData());
DataSource dataSource = Singleton.getInstance().getDataSource();

Connection conn = dataSource.getConnection();

Biosample bean6 = (Biosample) ViewUtils
.eval("#{biosample}");
if (conn != null) {
PreparedStatement pst3 = null;
pst3 = conn .prepareStatement("INSERT INTO
campione(id_,organismo,protocollotrattamento,metodoestrazione,tipoamplificazione,protocolloibridazione,protocollomarcatura,valore1,valore2,valore3,valore4)
VALUES(?,?,?,?,?,?,?,?,?,?,?)",
Statement.RETURN_GENERATED_KEYS);
pst3.setInt(1, 11);
pst3.setString(2, "ciao");
pst3.setInt(3, nrows);
pst3.setString(4, bean6.getExtractionMethod());
pst3.setString(5, bean6.getAmplification());
pst3.setString(6, bean6.getHybridation());
pst3.setString(7, bean6.getLabel());
pst3.setString(8, bean6.getExpFact1());
pst3.setString(9, bean6.getExpFact2());
pst3.setString(10, bean6.getExpFact3());
pst3.setString(11, bean6.getExpFact4());
pst3.executeUpdate();
pst3.close();
conn.close();
}

}



The values i return from bean6 are NULL!
Can you help me?It seems the data aren't loaded into row object....
Thanks very much
 
J

Jon Martin Solaas

gbattine said:
Hi guys,
i need a little help.
I've developed a datatable and an actionListener as commandlink for
each row,when it's clicked an insert on a table is performed.
The problem is that when i insert value and click my table is filled
with null values!
I think the error is in actionListener,can you help me?

public void editBiosample(ActionEvent event) throws SQLException {
FacesContext facesContext=FacesContext.getCurrentInstance();
setBiosampleItem((Biosample) getBiosampleDataTable().getRowData());
DataSource dataSource = Singleton.getInstance().getDataSource();

Connection conn = dataSource.getConnection();

Biosample bean6 = (Biosample) ViewUtils
.eval("#{biosample}");
if (conn != null) {
PreparedStatement pst3 = null;
pst3 = conn .prepareStatement("INSERT INTO
campione(id_,organismo,protocollotrattamento,metodoestrazione,tipoamplificazione,protocolloibridazione,protocollomarcatura,valore1,valore2,valore3,valore4)
VALUES(?,?,?,?,?,?,?,?,?,?,?)",
Statement.RETURN_GENERATED_KEYS);
pst3.setInt(1, 11);
pst3.setString(2, "ciao");
pst3.setInt(3, nrows);
pst3.setString(4, bean6.getExtractionMethod());
pst3.setString(5, bean6.getAmplification());
pst3.setString(6, bean6.getHybridation());
pst3.setString(7, bean6.getLabel());
pst3.setString(8, bean6.getExpFact1());
pst3.setString(9, bean6.getExpFact2());
pst3.setString(10, bean6.getExpFact3());
pst3.setString(11, bean6.getExpFact4());
pst3.executeUpdate();
pst3.close();
conn.close();
}

}



The values i return from bean6 are NULL!
Can you help me?It seems the data aren't loaded into row object....
Thanks very much

Use a debugger and check the attributes of bean6 to see if they actually
have values and aren't null. Or use the classic
System.err.println(bean6.getExtractionMethod()); and so forth ...

I don't see any obvious errors in the code...
 
G

gbattine

thanks very much...
i'm new of jsf and i've never made a real debug of application..
i use ExadelStudio with eclipse but i find its debug more
complicated....
can you say me some simplier debugger e links to learn use it?
thanks very much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top