Adding to database
hello, i'm a newbie to JSF so am not quite sure what to do!
i'm using mysql and have configured studio creator so they work together.
I'm creating a register/sign up page where the user fills out a few text fields and presses submit. I've read the tutorials but they all seem to have a table in the page or a drop down box blah blah... so i found them a bit confusing and am not sure how to adapt the info to work for my application.
What i'm asking is from filling out the text fields, how do i enter that data into my database?
Thanks.
# 1
Hi!
here's an example of how you can do it:
String name = (String) nameclass.getValue(); //textfield1
Integer status = (Integer) ddstatusclass.getValue(); //textfield2
try {
RowKey rk = productDataProvider2.appendRow();
productDataProvider2.setCursorRow(rk);
productDataProvider2.setValue("product.product_name",name);
productDataProvider2.setValue("product.status_class",status);
productDataProvider2.commitChanges();
} catch (Exception ex) {
log("Error Description", ex);
error(ex.getMessage());
}
In this case, the table is product and I'm storing the values I got from two text fields, sice the primary key is autoincrement there's no need to specify its value inside the try, because it does it automatically.
Hope it helps =)
Yese