You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Мария Григорьева <ma...@gmail.com> on 2008/10/10 15:19:53 UTC
pass repeater to the database using javaflow
Hello!
I need to pass the repeater params to the database.
Here the function:
public void addRepeater(RepeaterAsList repeater, int compositionID) throws
SQLException {
for (int i=0;i<repeater.size();i++) {
PreparedStatement p_stmt =
con.prepareStatement("insert into component_in_composition(id_composition,
component, amount) " +
"values(?, ?, ?)");
p_stmt.setInt(1,
compositionID);
BigDecimal type =
(BigDecimal) ((RepeaterAsList)
repeater.get(i)).getWidget("type").getValue();
BigDecimal amount =
(BigDecimal) ((RepeaterAsList)
repeater.get(i)).getWidget("amount").getValue();
p_stmt.setBigDecimal(2,
type);
p_stmt.setBigDecimal(3,
amount);
p_stmt.execute();
}
}
But I've got java.lang.ClassCastException!!!!
Please help! How to do it right?
RE: pass repeater to the database using javaflow
Posted by Мария Григорьева <ma...@gmail.com>.
Hello!
I'm using RepeaterAsList, because when I try to pass Repeater to the
procedure
public void addRepeater(Repeater repeater, int compositionID),
I got the exception:
org.mozilla.javascript.EvaluatorException: Can't find method
org.apache.cocoon.mysamples.jdbc.postgresJDBCConn.addRepeater(org.apache.coc
oon.forms.util.RepeaterAsList,number)
I can't imagine why flowscript needs RepeaterAsList:
From: Christofer Dutz [mailto:christofer.dutz@c-ware.de]
Sent: Friday, October 10, 2008 5:40 PM
To: users@cocoon.apache.org
Subject: AW: pass repeater to the database using javaflow
Hi,
Well I have never used RepeaterAsList so I can't really say what type the
elements are, but in the Web I could find:
A List view of a
<http://www.jdocs.com/link/org/apache/cocoon/forms/formmodel/Repeater.html>
Repeater , each element of the list being a Map wrapping a repeater row, as
defined by
<http://www.jdocs.com/link/org/apache/cocoon/forms/util/ContainerWidgetAsMap
.html> ContainerWidgetAsMap .
You are explicitly casting your RepeaterAsList Elements to Repeater as List
: I would guess that casting to "Map" would be better.
By the way : I always access Repeater rows by:
Repeater.RepeaterRow repeaterRow = (Repeater.RepeaterRow)
repeaterObj.getRow(rowIndex);
Works like a charm for me.
Hope this helps,
Chris
Von: Мария Григорьева [mailto:magsend@gmail.com]
Gesendet: Freitag, 10. Oktober 2008 15:20
An: users@cocoon.apache.org
Betreff: pass repeater to the database using javaflow
Hello!
I need to pass the repeater params to the database.
Here the function:
public void addRepeater(RepeaterAsList repeater, int compositionID) throws
SQLException {
for (int i=0;i<repeater.size();i++) {
PreparedStatement p_stmt =
con.prepareStatement("insert into component_in_composition(id_composition,
component, amount) " +
"values(?, ?, ?)");
p_stmt.setInt(1,
compositionID);
BigDecimal type =
(BigDecimal) ((RepeaterAsList)
repeater.get(i)).getWidget("type").getValue();
BigDecimal amount =
(BigDecimal) ((RepeaterAsList)
repeater.get(i)).getWidget("amount").getValue();
p_stmt.setBigDecimal(2,
type);
p_stmt.setBigDecimal(3,
amount);
p_stmt.execute();
}
}
But I've got java.lang.ClassCastException!!!!
Please help! How to do it right?
AW: pass repeater to the database using javaflow
Posted by Christofer Dutz <ch...@c-ware.de>.
Hi,
Well I have never used RepeaterAsList so I can't really say what type the
elements are, but in the Web I could find:
A List view of a
<http://www.jdocs.com/link/org/apache/cocoon/forms/formmodel/Repeater.html>
Repeater , each element of the list being a Map wrapping a repeater row, as
defined by
<http://www.jdocs.com/link/org/apache/cocoon/forms/util/ContainerWidgetAsMap
.html> ContainerWidgetAsMap .
You are explicitly casting your RepeaterAsList Elements to Repeater as List
: I would guess that casting to "Map" would be better.
By the way : I always access Repeater rows by:
Repeater.RepeaterRow repeaterRow = (Repeater.RepeaterRow)
repeaterObj.getRow(rowIndex);
Works like a charm for me.
Hope this helps,
Chris
Von: Мария Григорьева [mailto:magsend@gmail.com]
Gesendet: Freitag, 10. Oktober 2008 15:20
An: users@cocoon.apache.org
Betreff: pass repeater to the database using javaflow
Hello!
I need to pass the repeater params to the database.
Here the function:
public void addRepeater(RepeaterAsList repeater, int compositionID) throws
SQLException {
for (int i=0;i<repeater.size();i++) {
PreparedStatement p_stmt =
con.prepareStatement("insert into component_in_composition(id_composition,
component, amount) " +
"values(?, ?, ?)");
p_stmt.setInt(1,
compositionID);
BigDecimal type =
(BigDecimal) ((RepeaterAsList)
repeater.get(i)).getWidget("type").getValue();
BigDecimal amount =
(BigDecimal) ((RepeaterAsList)
repeater.get(i)).getWidget("amount").getValue();
p_stmt.setBigDecimal(2,
type);
p_stmt.setBigDecimal(3,
amount);
p_stmt.execute();
}
}
But I've got java.lang.ClassCastException!!!!
Please help! How to do it right?