Vous êtes sur la page 1sur 14

Ejemplos Java Studio Creator

DataBase
Requisito: Crear Base de Datos Music
Music Project
Eventos
public String addNewCategory_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
log("addNewCategory_action()");
if (musiccategoriesDataProvider.canAppendRow()) {
try {
RowKey rowKey = musiccategoriesDataProvider.appendRow();
// put the new data in the data provider
musiccategoriesDataProvider.setValue("MUSICCATEGORIES.MUSICCATEGORYID", rowKey,
getApplicationBean1().getNextCategoryId());
musiccategoriesDataProvider.setValue("MUSICCATEGORIES.MUSICCATEGORY", rowKey,
newCategory.getText());
musiccategoriesDataProvider.commitChanges();
info("New Category " + newCategory.getText() + " added to MUSICCATEGORIES table");
log("addNewCategory_action(): Added category " + newCategory.getText());
newCategory.setText(null);
} catch (Exception e) {
log("Cannot add new recording artist ", e);
error("Cannot add new recording artist: " + e.getMessage());
}
} else {
log("Cannot append new recording artist");
error("Cannot append new recording artist");
}
return null;
}
public void setSelected(boolean selected) {
// called for every row
TableRowDataProvider trdp = (TableRowDataProvider)getBean("currentRow");
RowKey rowKey = trdp.getTableRow();
if (checkbox1.isChecked()) {
// Add rowKey to selectedRows HashSet if checkbox is selected (checked)
selectedRows.add(rowKey);
} else {
// Remove rowKey from selectedRows HashSet if not checked
selectedRows.remove(rowKey);
}
}

Para Hacer efectivo el Borrado

musiccategoriesDataProvider.commitChanges();
public String update_action() {
// TODO: Process the button click action. Return value is a nav
// case name where null will return to the same page.
try {
musiccategoriesDataProvider.commitChanges();
log("update: changes committed");
info("Update committed");
} catch(Exception e) {
log("update: cannot commit changes ", e);
error("Cannot commit changes: " + e.getMessage());
}
return null;
}
public String cancel_action() {
// TODO: Process the button click action. Return value is a nav
// case name where null will return to the same page.
try {
musiccategoriesDataProvider.revertChanges();
log("cancel: revert changes");
info("Update cancelled");
} catch(Exception e) {
log("cancel: cannot revert changes ", e);
error("Cannot revert changes: " + e.getMessage());
}
return null;
}
Agregar Datos
public String update_action() {
// TODO: Process the button click action. Return value is a n
// case name where null will return to the same page.
try {
musiccategoriesDataProvider.commitChanges();
log("update: changes committed");
info("Update committed");
} catch(Exception e) {
log("update: cannot commit changes ", e);
error("Cannot commit changes: " + e.getMessage());
}
return null;
}
public String addNewCategory_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
log("addNewCategory_action()");
if (musiccategoriesDataProvider.canAppendRow()) {
try {
RowKey rowKey = musiccategoriesDataProvider.appendRow();
// put the new data in the data provider
musiccategoriesDataProvider.setValue("MUSICCATEGORIES.MUSICCATEGORYID", rowKey,
getApplicationBean1().getNextCategoryId());
musiccategoriesDataProvider.setValue("MUSICCATEGORIES.MUSICCATEGORY", rowKey,
newCategory.getText());
musiccategoriesDataProvider.commitChanges();
info("New Category " + newCategory.getText() + " added to MUSICCATEGORIES table");
log("addNewCategory_action(): Added category " + newCategory.getText());
newCategory.setText(null);
} catch (Exception e) {
log("Cannot add new recording artist ", e);
error("Cannot add new recording artist: " + e.getMessage());
}
} else {
log("Cannot append new recording artist");
error("Cannot append new recording artist");
}
return null;
}
}
Selección de Datos
public String hyperlinkTitle_action() {
// TODO: Replace with your code
TableRowDataProvider rowData = (TableRowDataProvider)getBean("currentRow");
getRequestBean1().setRecordingID((Integer)rowData.getValue("RECORDINGS.RECORDINGID"));
getRequestBean1().setRecordingTitle((String)rowData.getValue("RECORDINGS.RECORDINGTITLE"));
log("[hyperlinkTitle_action]: recording ID = " + rowData.getValue("RECORDINGS.RECORDINGID"));
return "tracks";
}
}
Tracks SessionBean

Vous aimerez peut-être aussi